Built motion from commit 6f14c8ba.|2.6.29
[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 _0xca01=['error','code','message','result','catch','SmsQueueReport','create','body','options','debug','stringify','CreateSmsQueueReport','UpdateSmsQueueReport','update','raw','where','attributes','limit','then','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','info','SmsQueueReport,\x20%s,\x20%s','request\x20sent','SmsQueueReport,\x20%s,\x20%s,\x20%s'];(function(_0xe1ef1d,_0x51c03b){var _0x650f6b=function(_0x347649){while(--_0x347649){_0xe1ef1d['push'](_0xe1ef1d['shift']());}};_0x650f6b(++_0x51c03b);}(_0xca01,0xa3));var _0x1ca0=function(_0x1906f1,_0x5d9978){_0x1906f1=_0x1906f1-0x0;var _0x28ca50=_0xca01[_0x1906f1];return _0x28ca50;};'use strict';var _=require(_0x1ca0('0x0'));var util=require(_0x1ca0('0x1'));var moment=require(_0x1ca0('0x2'));var BPromise=require(_0x1ca0('0x3'));var rs=require(_0x1ca0('0x4'));var fs=require('fs');var Redis=require(_0x1ca0('0x5'));var db=require(_0x1ca0('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x1ca0('0x7'))(_0x1ca0('0x8'));var config=require(_0x1ca0('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x1ca0('0xa')][_0x1ca0('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3d496b,_0x190a53,_0x113b2f){return new BPromise(function(_0x4ca7ce,_0x4a604b){return client[_0x1ca0('0xc')](_0x3d496b,_0x113b2f)['then'](function(_0x3169d6){logger[_0x1ca0('0xd')](_0x1ca0('0xe'),_0x190a53,_0x1ca0('0xf'));logger['debug'](_0x1ca0('0x10'),_0x190a53,_0x1ca0('0xf'),JSON['stringify'](_0x3169d6));if(_0x3169d6[_0x1ca0('0x11')]){if(_0x3169d6[_0x1ca0('0x11')][_0x1ca0('0x12')]===0x1f4){logger[_0x1ca0('0x11')](_0x1ca0('0xe'),_0x190a53,_0x3169d6[_0x1ca0('0x11')]['message']);return _0x4a604b(_0x3169d6[_0x1ca0('0x11')][_0x1ca0('0x13')]);}logger['error']('SmsQueueReport,\x20%s,\x20%s',_0x190a53,_0x3169d6['error'][_0x1ca0('0x13')]);return _0x4ca7ce(_0x3169d6['error']['message']);}else{logger[_0x1ca0('0xd')](_0x1ca0('0xe'),_0x190a53,_0x1ca0('0xf'));_0x4ca7ce(_0x3169d6[_0x1ca0('0x14')][_0x1ca0('0x13')]);}})[_0x1ca0('0x15')](function(_0x53ff1e){logger[_0x1ca0('0x11')](_0x1ca0('0xe'),_0x190a53,_0x53ff1e);_0x4a604b(_0x53ff1e);});});}exports['CreateSmsQueueReport']=function(_0x55bc59){var _0xbeb9d3=this;return new Promise(function(_0x5a5328,_0x28473a){return db[_0x1ca0('0x16')][_0x1ca0('0x17')](_0x55bc59[_0x1ca0('0x18')],{'raw':_0x55bc59[_0x1ca0('0x19')]?_0x55bc59[_0x1ca0('0x19')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x46bbb0){logger['info']('CreateSmsQueueReport',_0x55bc59);logger[_0x1ca0('0x1a')]('CreateSmsQueueReport',_0x55bc59,JSON[_0x1ca0('0x1b')](_0x46bbb0));_0x5a5328(_0x46bbb0);})['catch'](function(_0x583034){logger[_0x1ca0('0x11')](_0x1ca0('0x1c'),_0x583034[_0x1ca0('0x13')],_0x55bc59);_0x28473a(_0xbeb9d3[_0x1ca0('0x11')](0x1f4,_0x583034['message']));});});};exports[_0x1ca0('0x1d')]=function(_0xb3d3c9){var _0x508494=this;return new Promise(function(_0x2c228a,_0x33526e){return db[_0x1ca0('0x16')][_0x1ca0('0x1e')](_0xb3d3c9['body'],{'raw':_0xb3d3c9[_0x1ca0('0x19')]?_0xb3d3c9[_0x1ca0('0x19')][_0x1ca0('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xb3d3c9[_0x1ca0('0x19')]?_0xb3d3c9['options'][_0x1ca0('0x20')]||null:null,'attributes':_0xb3d3c9[_0x1ca0('0x19')]?_0xb3d3c9[_0x1ca0('0x19')][_0x1ca0('0x21')]||null:null,'limit':_0xb3d3c9['options']?_0xb3d3c9[_0x1ca0('0x19')][_0x1ca0('0x22')]||null:null})[_0x1ca0('0x23')](function(_0x232287){logger['info']('UpdateSmsQueueReport',_0xb3d3c9);logger[_0x1ca0('0x1a')](_0x1ca0('0x1d'),_0xb3d3c9,JSON[_0x1ca0('0x1b')](_0x232287));_0x2c228a(_0x232287);})[_0x1ca0('0x15')](function(_0x24b3f0){logger[_0x1ca0('0x11')](_0x1ca0('0x1d'),_0x24b3f0[_0x1ca0('0x13')],_0xb3d3c9);_0x33526e(_0x508494[_0x1ca0('0x11')](0x1f4,_0x24b3f0['message']));});});};