6e010e90c77eafde677ebab9f3787465942647ce
[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 _0x01c6=['error','code','message','SmsQueueReport,\x20%s,\x20%s','info','result','CreateSmsQueueReport','options','debug','catch','UpdateSmsQueueReport','SmsQueueReport','update','body','raw','where','attributes','limit','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','SmsQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0x2e4e19,_0x493b50){var _0x9ba20b=function(_0x2f6456){while(--_0x2f6456){_0x2e4e19['push'](_0x2e4e19['shift']());}};_0x9ba20b(++_0x493b50);}(_0x01c6,0x1aa));var _0x601c=function(_0x47e93d,_0x26bbdd){_0x47e93d=_0x47e93d-0x0;var _0xe86c46=_0x01c6[_0x47e93d];return _0xe86c46;};'use strict';var _=require(_0x601c('0x0'));var util=require(_0x601c('0x1'));var moment=require(_0x601c('0x2'));var BPromise=require(_0x601c('0x3'));var rs=require(_0x601c('0x4'));var fs=require('fs');var Redis=require(_0x601c('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x601c('0x6'));var logger=require(_0x601c('0x7'))(_0x601c('0x8'));var config=require(_0x601c('0x9'));var jayson=require(_0x601c('0xa'));var client=jayson['client'][_0x601c('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x4a3d5c,_0x290a6e,_0x3776a4){return new BPromise(function(_0x50cdb6,_0x3d948a){return client['request'](_0x4a3d5c,_0x3776a4)[_0x601c('0xc')](function(_0x44160c){logger['info']('SmsQueueReport,\x20%s,\x20%s',_0x290a6e,'request\x20sent');logger['debug'](_0x601c('0xd'),_0x290a6e,_0x601c('0xe'),JSON[_0x601c('0xf')](_0x44160c));if(_0x44160c[_0x601c('0x10')]){if(_0x44160c['error'][_0x601c('0x11')]===0x1f4){logger[_0x601c('0x10')]('SmsQueueReport,\x20%s,\x20%s',_0x290a6e,_0x44160c[_0x601c('0x10')][_0x601c('0x12')]);return _0x3d948a(_0x44160c['error'][_0x601c('0x12')]);}logger[_0x601c('0x10')](_0x601c('0x13'),_0x290a6e,_0x44160c[_0x601c('0x10')][_0x601c('0x12')]);return _0x50cdb6(_0x44160c['error']['message']);}else{logger[_0x601c('0x14')](_0x601c('0x13'),_0x290a6e,_0x601c('0xe'));_0x50cdb6(_0x44160c[_0x601c('0x15')][_0x601c('0x12')]);}})['catch'](function(_0x2b3767){logger['error'](_0x601c('0x13'),_0x290a6e,_0x2b3767);_0x3d948a(_0x2b3767);});});}exports[_0x601c('0x16')]=function(_0x2dfe0b){var _0x39756a=this;return new Promise(function(_0x5489b7,_0x2600bc){return db['SmsQueueReport']['create'](_0x2dfe0b['body'],{'raw':_0x2dfe0b[_0x601c('0x17')]?_0x2dfe0b[_0x601c('0x17')]['raw']===undefined?!![]:![]:!![]})[_0x601c('0xc')](function(_0x517d58){logger[_0x601c('0x14')](_0x601c('0x16'),_0x2dfe0b);logger[_0x601c('0x18')](_0x601c('0x16'),_0x2dfe0b,JSON[_0x601c('0xf')](_0x517d58));_0x5489b7(_0x517d58);})[_0x601c('0x19')](function(_0x19227a){logger['error'](_0x601c('0x16'),_0x19227a[_0x601c('0x12')],_0x2dfe0b);_0x2600bc(_0x39756a[_0x601c('0x10')](0x1f4,_0x19227a[_0x601c('0x12')]));});});};exports[_0x601c('0x1a')]=function(_0x5d18c8){var _0x3c9bed=this;return new Promise(function(_0x101303,_0x3d3f30){return db[_0x601c('0x1b')][_0x601c('0x1c')](_0x5d18c8[_0x601c('0x1d')],{'raw':_0x5d18c8['options']?_0x5d18c8[_0x601c('0x17')][_0x601c('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5d18c8['options']?_0x5d18c8[_0x601c('0x17')][_0x601c('0x1f')]||null:null,'attributes':_0x5d18c8[_0x601c('0x17')]?_0x5d18c8[_0x601c('0x17')][_0x601c('0x20')]||null:null,'limit':_0x5d18c8[_0x601c('0x17')]?_0x5d18c8[_0x601c('0x17')][_0x601c('0x21')]||null:null})[_0x601c('0xc')](function(_0x8abf05){logger['info']('UpdateSmsQueueReport',_0x5d18c8);logger[_0x601c('0x18')](_0x601c('0x1a'),_0x5d18c8,JSON['stringify'](_0x8abf05));_0x101303(_0x8abf05);})[_0x601c('0x19')](function(_0x4a17e7){logger[_0x601c('0x10')](_0x601c('0x1a'),_0x4a17e7[_0x601c('0x12')],_0x5d18c8);_0x3d3f30(_0x3c9bed[_0x601c('0x10')](0x1f4,_0x4a17e7[_0x601c('0x12')]));});});};