4d5ef54b1de41250d4f1f226189999f72abf265e
[motion2.git] / server / api / smsQueueReport / smsQueueReport.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xcfc6=['SmsQueueReport,\x20%s,\x20%s','request\x20sent','debug','SmsQueueReport,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','create','body','options','raw','CreateSmsQueueReport','UpdateSmsQueueReport','SmsQueueReport','update','where','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','then'];(function(_0x1dcbd5,_0x4403d3){var _0x35e746=function(_0x5b60e3){while(--_0x5b60e3){_0x1dcbd5['push'](_0x1dcbd5['shift']());}};_0x35e746(++_0x4403d3);}(_0xcfc6,0x69));var _0x6cfc=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xcfc6[_0x321bb2];return _0x9c12ed;};'use strict';var _=require(_0x6cfc('0x0'));var util=require('util');var moment=require(_0x6cfc('0x1'));var BPromise=require(_0x6cfc('0x2'));var rs=require(_0x6cfc('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6cfc('0x4'))['db'];var utils=require(_0x6cfc('0x5'));var logger=require(_0x6cfc('0x6'))(_0x6cfc('0x7'));var config=require('../../config/environment');var jayson=require(_0x6cfc('0x8'));var client=jayson['client'][_0x6cfc('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1ff239,_0x5ecb3d,_0x24d524){return new BPromise(function(_0x4738c6,_0x424110){return client['request'](_0x1ff239,_0x24d524)[_0x6cfc('0xa')](function(_0x1873d8){logger['info'](_0x6cfc('0xb'),_0x5ecb3d,_0x6cfc('0xc'));logger[_0x6cfc('0xd')](_0x6cfc('0xe'),_0x5ecb3d,'request\x20sent',JSON['stringify'](_0x1873d8));if(_0x1873d8[_0x6cfc('0xf')]){if(_0x1873d8[_0x6cfc('0xf')][_0x6cfc('0x10')]===0x1f4){logger[_0x6cfc('0xf')](_0x6cfc('0xb'),_0x5ecb3d,_0x1873d8[_0x6cfc('0xf')][_0x6cfc('0x11')]);return _0x424110(_0x1873d8['error'][_0x6cfc('0x11')]);}logger[_0x6cfc('0xf')](_0x6cfc('0xb'),_0x5ecb3d,_0x1873d8['error'][_0x6cfc('0x11')]);return _0x4738c6(_0x1873d8[_0x6cfc('0xf')][_0x6cfc('0x11')]);}else{logger['info']('SmsQueueReport,\x20%s,\x20%s',_0x5ecb3d,_0x6cfc('0xc'));_0x4738c6(_0x1873d8[_0x6cfc('0x12')][_0x6cfc('0x11')]);}})[_0x6cfc('0x13')](function(_0x592df3){logger['error']('SmsQueueReport,\x20%s,\x20%s',_0x5ecb3d,_0x592df3);_0x424110(_0x592df3);});});}exports['CreateSmsQueueReport']=function(_0x4daed2){var _0x2ee630=this;return new Promise(function(_0x1bdbf7,_0x5ebb88){return db['SmsQueueReport'][_0x6cfc('0x14')](_0x4daed2[_0x6cfc('0x15')],{'raw':_0x4daed2[_0x6cfc('0x16')]?_0x4daed2[_0x6cfc('0x16')][_0x6cfc('0x17')]===undefined?!![]:![]:!![]})[_0x6cfc('0xa')](function(_0xb95a2a){logger['info'](_0x6cfc('0x18'),_0x4daed2);logger[_0x6cfc('0xd')](_0x6cfc('0x18'),_0x4daed2,JSON['stringify'](_0xb95a2a));_0x1bdbf7(_0xb95a2a);})[_0x6cfc('0x13')](function(_0x538e9e){logger[_0x6cfc('0xf')]('CreateSmsQueueReport',_0x538e9e[_0x6cfc('0x11')],_0x4daed2);_0x5ebb88(_0x2ee630[_0x6cfc('0xf')](0x1f4,_0x538e9e[_0x6cfc('0x11')]));});});};exports[_0x6cfc('0x19')]=function(_0x2774f2){var _0x5a7ad5=this;return new Promise(function(_0x5c139d,_0x450ba8){return db[_0x6cfc('0x1a')][_0x6cfc('0x1b')](_0x2774f2[_0x6cfc('0x15')],{'raw':_0x2774f2['options']?_0x2774f2[_0x6cfc('0x16')][_0x6cfc('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2774f2[_0x6cfc('0x16')]?_0x2774f2['options'][_0x6cfc('0x1c')]||null:null,'attributes':_0x2774f2[_0x6cfc('0x16')]?_0x2774f2['options']['attributes']||null:null,'limit':_0x2774f2[_0x6cfc('0x16')]?_0x2774f2['options']['limit']||null:null})['then'](function(_0x49df69){logger['info'](_0x6cfc('0x19'),_0x2774f2);logger[_0x6cfc('0xd')](_0x6cfc('0x19'),_0x2774f2,JSON['stringify'](_0x49df69));_0x5c139d(_0x49df69);})[_0x6cfc('0x13')](function(_0x26bf04){logger['error'](_0x6cfc('0x19'),_0x26bf04[_0x6cfc('0x11')],_0x2774f2);_0x450ba8(_0x5a7ad5[_0x6cfc('0xf')](0x1f4,_0x26bf04[_0x6cfc('0x11')]));});});};