d5d05b222990c8f2b98fd1efdf1a6792be76f103
[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 _0xc531=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','http','request','then','info','SmsQueueReport,\x20%s,\x20%s','request\x20sent','debug','SmsQueueReport,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateSmsQueueReport','SmsQueueReport','options','stringify','UpdateSmsQueueReport','update','where','attributes','limit','lodash','util','moment'];(function(_0x3b545e,_0x3c98ac){var _0x470129=function(_0x1a59ac){while(--_0x1a59ac){_0x3b545e['push'](_0x3b545e['shift']());}};_0x470129(++_0x3c98ac);}(_0xc531,0x13d));var _0x1c53=function(_0x17cde7,_0x1f2a1d){_0x17cde7=_0x17cde7-0x0;var _0x256338=_0xc531[_0x17cde7];return _0x256338;};'use strict';var _=require(_0x1c53('0x0'));var util=require(_0x1c53('0x1'));var moment=require(_0x1c53('0x2'));var BPromise=require(_0x1c53('0x3'));var rs=require(_0x1c53('0x4'));var fs=require('fs');var Redis=require(_0x1c53('0x5'));var db=require(_0x1c53('0x6'))['db'];var utils=require(_0x1c53('0x7'));var logger=require(_0x1c53('0x8'))(_0x1c53('0x9'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x1c53('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x39ee58,_0x5af494,_0x4f0985){return new BPromise(function(_0x417b1f,_0x165bee){return client[_0x1c53('0xb')](_0x39ee58,_0x4f0985)[_0x1c53('0xc')](function(_0x474633){logger[_0x1c53('0xd')](_0x1c53('0xe'),_0x5af494,_0x1c53('0xf'));logger[_0x1c53('0x10')](_0x1c53('0x11'),_0x5af494,'request\x20sent',JSON['stringify'](_0x474633));if(_0x474633[_0x1c53('0x12')]){if(_0x474633[_0x1c53('0x12')][_0x1c53('0x13')]===0x1f4){logger[_0x1c53('0x12')](_0x1c53('0xe'),_0x5af494,_0x474633['error'][_0x1c53('0x14')]);return _0x165bee(_0x474633['error'][_0x1c53('0x14')]);}logger[_0x1c53('0x12')](_0x1c53('0xe'),_0x5af494,_0x474633['error'][_0x1c53('0x14')]);return _0x417b1f(_0x474633[_0x1c53('0x12')][_0x1c53('0x14')]);}else{logger[_0x1c53('0xd')]('SmsQueueReport,\x20%s,\x20%s',_0x5af494,_0x1c53('0xf'));_0x417b1f(_0x474633[_0x1c53('0x15')][_0x1c53('0x14')]);}})[_0x1c53('0x16')](function(_0x32c4dd){logger[_0x1c53('0x12')]('SmsQueueReport,\x20%s,\x20%s',_0x5af494,_0x32c4dd);_0x165bee(_0x32c4dd);});});}exports[_0x1c53('0x17')]=function(_0x5a3647){var _0x251511=this;return new Promise(function(_0x20096d,_0x570a6b){return db[_0x1c53('0x18')]['create'](_0x5a3647['body'],{'raw':_0x5a3647['options']?_0x5a3647[_0x1c53('0x19')]['raw']===undefined?!![]:![]:!![]})[_0x1c53('0xc')](function(_0x352f60){logger['info'](_0x1c53('0x17'),_0x5a3647);logger[_0x1c53('0x10')](_0x1c53('0x17'),_0x5a3647,JSON[_0x1c53('0x1a')](_0x352f60));_0x20096d(_0x352f60);})[_0x1c53('0x16')](function(_0x1f8b50){logger[_0x1c53('0x12')](_0x1c53('0x17'),_0x1f8b50['message'],_0x5a3647);_0x570a6b(_0x251511['error'](0x1f4,_0x1f8b50[_0x1c53('0x14')]));});});};exports[_0x1c53('0x1b')]=function(_0x3b64cc){var _0x3ecb16=this;return new Promise(function(_0x47d256,_0x1fe90a){return db[_0x1c53('0x18')][_0x1c53('0x1c')](_0x3b64cc['body'],{'raw':_0x3b64cc[_0x1c53('0x19')]?_0x3b64cc[_0x1c53('0x19')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3b64cc['options']?_0x3b64cc[_0x1c53('0x19')][_0x1c53('0x1d')]||null:null,'attributes':_0x3b64cc[_0x1c53('0x19')]?_0x3b64cc[_0x1c53('0x19')][_0x1c53('0x1e')]||null:null,'limit':_0x3b64cc[_0x1c53('0x19')]?_0x3b64cc[_0x1c53('0x19')][_0x1c53('0x1f')]||null:null})['then'](function(_0x57e7ba){logger['info'](_0x1c53('0x1b'),_0x3b64cc);logger[_0x1c53('0x10')](_0x1c53('0x1b'),_0x3b64cc,JSON[_0x1c53('0x1a')](_0x57e7ba));_0x47d256(_0x57e7ba);})['catch'](function(_0x18f581){logger[_0x1c53('0x12')]('UpdateSmsQueueReport',_0x18f581[_0x1c53('0x14')],_0x3b64cc);_0x1fe90a(_0x3ecb16[_0x1c53('0x12')](0x1f4,_0x18f581['message']));});});};