Built motion from commit 3a7e82ea.|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 _0xa826=['then','info','SmsQueueReport,\x20%s,\x20%s','request\x20sent','SmsQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CreateSmsQueueReport','SmsQueueReport','options','raw','debug','update','body','where','attributes','UpdateSmsQueueReport','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','http','request'];(function(_0x3092d6,_0x2c22ff){var _0x1fe374=function(_0x21fd12){while(--_0x21fd12){_0x3092d6['push'](_0x3092d6['shift']());}};_0x1fe374(++_0x2c22ff);}(_0xa826,0x1f4));var _0x6a82=function(_0x5b644e,_0x2e5e07){_0x5b644e=_0x5b644e-0x0;var _0x49c6bf=_0xa826[_0x5b644e];return _0x49c6bf;};'use strict';var _=require('lodash');var util=require(_0x6a82('0x0'));var moment=require('moment');var BPromise=require(_0x6a82('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6a82('0x2'));var db=require(_0x6a82('0x3'))['db'];var utils=require(_0x6a82('0x4'));var logger=require(_0x6a82('0x5'))(_0x6a82('0x6'));var config=require(_0x6a82('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0x6a82('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x549474,_0x58b247,_0x5bea26){return new BPromise(function(_0xfe64f3,_0x2f73a9){return client[_0x6a82('0x9')](_0x549474,_0x5bea26)[_0x6a82('0xa')](function(_0x463702){logger[_0x6a82('0xb')](_0x6a82('0xc'),_0x58b247,_0x6a82('0xd'));logger['debug'](_0x6a82('0xe'),_0x58b247,_0x6a82('0xd'),JSON[_0x6a82('0xf')](_0x463702));if(_0x463702[_0x6a82('0x10')]){if(_0x463702['error']['code']===0x1f4){logger[_0x6a82('0x10')]('SmsQueueReport,\x20%s,\x20%s',_0x58b247,_0x463702['error'][_0x6a82('0x11')]);return _0x2f73a9(_0x463702['error'][_0x6a82('0x11')]);}logger[_0x6a82('0x10')](_0x6a82('0xc'),_0x58b247,_0x463702[_0x6a82('0x10')][_0x6a82('0x11')]);return _0xfe64f3(_0x463702[_0x6a82('0x10')]['message']);}else{logger[_0x6a82('0xb')]('SmsQueueReport,\x20%s,\x20%s',_0x58b247,'request\x20sent');_0xfe64f3(_0x463702[_0x6a82('0x12')][_0x6a82('0x11')]);}})[_0x6a82('0x13')](function(_0x36d7a7){logger[_0x6a82('0x10')](_0x6a82('0xc'),_0x58b247,_0x36d7a7);_0x2f73a9(_0x36d7a7);});});}exports[_0x6a82('0x14')]=function(_0x26e5dd){var _0xb4c503=this;return new Promise(function(_0xc3625f,_0x9641c){return db[_0x6a82('0x15')]['create'](_0x26e5dd['body'],{'raw':_0x26e5dd[_0x6a82('0x16')]?_0x26e5dd['options'][_0x6a82('0x17')]===undefined?!![]:![]:!![]})[_0x6a82('0xa')](function(_0x4112c3){logger['info']('CreateSmsQueueReport',_0x26e5dd);logger[_0x6a82('0x18')]('CreateSmsQueueReport',_0x26e5dd,JSON['stringify'](_0x4112c3));_0xc3625f(_0x4112c3);})[_0x6a82('0x13')](function(_0x3d0f1f){logger['error'](_0x6a82('0x14'),_0x3d0f1f[_0x6a82('0x11')],_0x26e5dd);_0x9641c(_0xb4c503['error'](0x1f4,_0x3d0f1f[_0x6a82('0x11')]));});});};exports['UpdateSmsQueueReport']=function(_0x2a0ced){var _0x502f2f=this;return new Promise(function(_0x16a19b,_0x20aacc){return db[_0x6a82('0x15')][_0x6a82('0x19')](_0x2a0ced[_0x6a82('0x1a')],{'raw':_0x2a0ced['options']?_0x2a0ced['options'][_0x6a82('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2a0ced[_0x6a82('0x16')]?_0x2a0ced[_0x6a82('0x16')][_0x6a82('0x1b')]||null:null,'attributes':_0x2a0ced[_0x6a82('0x16')]?_0x2a0ced['options'][_0x6a82('0x1c')]||null:null,'limit':_0x2a0ced['options']?_0x2a0ced[_0x6a82('0x16')]['limit']||null:null})[_0x6a82('0xa')](function(_0x130aa9){logger[_0x6a82('0xb')](_0x6a82('0x1d'),_0x2a0ced);logger[_0x6a82('0x18')](_0x6a82('0x1d'),_0x2a0ced,JSON[_0x6a82('0xf')](_0x130aa9));_0x16a19b(_0x130aa9);})[_0x6a82('0x13')](function(_0x257a21){logger[_0x6a82('0x10')](_0x6a82('0x1d'),_0x257a21[_0x6a82('0x11')],_0x2a0ced);_0x20aacc(_0x502f2f[_0x6a82('0x10')](0x1f4,_0x257a21['message']));});});};