38dc39a548afad4acb768de5cd4f0ab743af691e
[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 _0xc90f=['jayson/promise','client','http','request','then','info','SmsQueueReport,\x20%s,\x20%s','request\x20sent','debug','SmsQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','SmsQueueReport','create','options','raw','CreateSmsQueueReport','UpdateSmsQueueReport','update','where','attributes','limit','lodash','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x228c6b,_0x4fbfed){var _0x5a2edb=function(_0x34e7f8){while(--_0x34e7f8){_0x228c6b['push'](_0x228c6b['shift']());}};_0x5a2edb(++_0x4fbfed);}(_0xc90f,0x142));var _0xfc90=function(_0xf71120,_0x25b7f9){_0xf71120=_0xf71120-0x0;var _0xbe2fd3=_0xc90f[_0xf71120];return _0xbe2fd3;};'use strict';var _=require(_0xfc90('0x0'));var util=require('util');var moment=require(_0xfc90('0x1'));var BPromise=require(_0xfc90('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xfc90('0x3'))['db'];var utils=require(_0xfc90('0x4'));var logger=require(_0xfc90('0x5'))(_0xfc90('0x6'));var config=require(_0xfc90('0x7'));var jayson=require(_0xfc90('0x8'));var client=jayson[_0xfc90('0x9')][_0xfc90('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x429a16,_0x59b7ae,_0x20bae2){return new BPromise(function(_0x219dd6,_0x709ec7){return client[_0xfc90('0xb')](_0x429a16,_0x20bae2)[_0xfc90('0xc')](function(_0x40e6a2){logger[_0xfc90('0xd')](_0xfc90('0xe'),_0x59b7ae,_0xfc90('0xf'));logger[_0xfc90('0x10')](_0xfc90('0x11'),_0x59b7ae,_0xfc90('0xf'),JSON[_0xfc90('0x12')](_0x40e6a2));if(_0x40e6a2[_0xfc90('0x13')]){if(_0x40e6a2[_0xfc90('0x13')][_0xfc90('0x14')]===0x1f4){logger['error']('SmsQueueReport,\x20%s,\x20%s',_0x59b7ae,_0x40e6a2['error'][_0xfc90('0x15')]);return _0x709ec7(_0x40e6a2[_0xfc90('0x13')][_0xfc90('0x15')]);}logger[_0xfc90('0x13')](_0xfc90('0xe'),_0x59b7ae,_0x40e6a2[_0xfc90('0x13')]['message']);return _0x219dd6(_0x40e6a2[_0xfc90('0x13')][_0xfc90('0x15')]);}else{logger[_0xfc90('0xd')](_0xfc90('0xe'),_0x59b7ae,_0xfc90('0xf'));_0x219dd6(_0x40e6a2['result'][_0xfc90('0x15')]);}})[_0xfc90('0x16')](function(_0x56a55b){logger[_0xfc90('0x13')]('SmsQueueReport,\x20%s,\x20%s',_0x59b7ae,_0x56a55b);_0x709ec7(_0x56a55b);});});}exports['CreateSmsQueueReport']=function(_0x28306d){var _0x20c5c0=this;return new Promise(function(_0x4fa1f0,_0x34f530){return db[_0xfc90('0x17')][_0xfc90('0x18')](_0x28306d['body'],{'raw':_0x28306d['options']?_0x28306d[_0xfc90('0x19')][_0xfc90('0x1a')]===undefined?!![]:![]:!![]})[_0xfc90('0xc')](function(_0x1432ee){logger['info'](_0xfc90('0x1b'),_0x28306d);logger[_0xfc90('0x10')](_0xfc90('0x1b'),_0x28306d,JSON[_0xfc90('0x12')](_0x1432ee));_0x4fa1f0(_0x1432ee);})[_0xfc90('0x16')](function(_0x2ed069){logger[_0xfc90('0x13')](_0xfc90('0x1b'),_0x2ed069[_0xfc90('0x15')],_0x28306d);_0x34f530(_0x20c5c0[_0xfc90('0x13')](0x1f4,_0x2ed069[_0xfc90('0x15')]));});});};exports[_0xfc90('0x1c')]=function(_0x305c08){var _0x250218=this;return new Promise(function(_0x48f400,_0x261de0){return db[_0xfc90('0x17')][_0xfc90('0x1d')](_0x305c08['body'],{'raw':_0x305c08[_0xfc90('0x19')]?_0x305c08[_0xfc90('0x19')][_0xfc90('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x305c08[_0xfc90('0x19')]?_0x305c08['options'][_0xfc90('0x1e')]||null:null,'attributes':_0x305c08[_0xfc90('0x19')]?_0x305c08[_0xfc90('0x19')][_0xfc90('0x1f')]||null:null,'limit':_0x305c08[_0xfc90('0x19')]?_0x305c08['options'][_0xfc90('0x20')]||null:null})[_0xfc90('0xc')](function(_0x265ba8){logger['info'](_0xfc90('0x1c'),_0x305c08);logger['debug'](_0xfc90('0x1c'),_0x305c08,JSON[_0xfc90('0x12')](_0x265ba8));_0x48f400(_0x265ba8);})['catch'](function(_0x1c9e07){logger[_0xfc90('0x13')]('UpdateSmsQueueReport',_0x1c9e07[_0xfc90('0x15')],_0x305c08);_0x261de0(_0x250218[_0xfc90('0x13')](0x1f4,_0x1c9e07[_0xfc90('0x15')]));});});};