Built motion from commit 3c2ce842.|2.6.31
[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 _0x734f=['raw','attributes','limit','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','SmsQueueReport,\x20%s,\x20%s','debug','SmsQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','SmsQueueReport','options','then','CreateSmsQueueReport','UpdateSmsQueueReport','body'];(function(_0x5834bc,_0x3d4801){var _0x3e183a=function(_0x18b023){while(--_0x18b023){_0x5834bc['push'](_0x5834bc['shift']());}};_0x3e183a(++_0x3d4801);}(_0x734f,0x1df));var _0xf734=function(_0x54833a,_0x2b5714){_0x54833a=_0x54833a-0x0;var _0x4f3dc6=_0x734f[_0x54833a];return _0x4f3dc6;};'use strict';var _=require(_0xf734('0x0'));var util=require(_0xf734('0x1'));var moment=require(_0xf734('0x2'));var BPromise=require(_0xf734('0x3'));var rs=require(_0xf734('0x4'));var fs=require('fs');var Redis=require(_0xf734('0x5'));var db=require(_0xf734('0x6'))['db'];var utils=require(_0xf734('0x7'));var logger=require(_0xf734('0x8'))(_0xf734('0x9'));var config=require('../../config/environment');var jayson=require(_0xf734('0xa'));var client=jayson[_0xf734('0xb')][_0xf734('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x5bf7bd,_0x752efa,_0x5f92bc){return new BPromise(function(_0xcc1e6a,_0x2c70d4){return client[_0xf734('0xd')](_0x5bf7bd,_0x5f92bc)['then'](function(_0x27f78c){logger['info'](_0xf734('0xe'),_0x752efa,'request\x20sent');logger[_0xf734('0xf')](_0xf734('0x10'),_0x752efa,_0xf734('0x11'),JSON[_0xf734('0x12')](_0x27f78c));if(_0x27f78c[_0xf734('0x13')]){if(_0x27f78c['error'][_0xf734('0x14')]===0x1f4){logger[_0xf734('0x13')](_0xf734('0xe'),_0x752efa,_0x27f78c[_0xf734('0x13')][_0xf734('0x15')]);return _0x2c70d4(_0x27f78c[_0xf734('0x13')][_0xf734('0x15')]);}logger[_0xf734('0x13')]('SmsQueueReport,\x20%s,\x20%s',_0x752efa,_0x27f78c[_0xf734('0x13')][_0xf734('0x15')]);return _0xcc1e6a(_0x27f78c[_0xf734('0x13')][_0xf734('0x15')]);}else{logger[_0xf734('0x16')](_0xf734('0xe'),_0x752efa,_0xf734('0x11'));_0xcc1e6a(_0x27f78c[_0xf734('0x17')]['message']);}})[_0xf734('0x18')](function(_0x1e2ec3){logger['error'](_0xf734('0xe'),_0x752efa,_0x1e2ec3);_0x2c70d4(_0x1e2ec3);});});}exports['CreateSmsQueueReport']=function(_0x2fd838){var _0x5db2c3=this;return new Promise(function(_0x2e62ec,_0xca0c13){return db[_0xf734('0x19')]['create'](_0x2fd838['body'],{'raw':_0x2fd838[_0xf734('0x1a')]?_0x2fd838[_0xf734('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0xf734('0x1b')](function(_0x34d1fe){logger[_0xf734('0x16')](_0xf734('0x1c'),_0x2fd838);logger[_0xf734('0xf')](_0xf734('0x1c'),_0x2fd838,JSON['stringify'](_0x34d1fe));_0x2e62ec(_0x34d1fe);})[_0xf734('0x18')](function(_0x15f7b6){logger['error'](_0xf734('0x1c'),_0x15f7b6[_0xf734('0x15')],_0x2fd838);_0xca0c13(_0x5db2c3[_0xf734('0x13')](0x1f4,_0x15f7b6['message']));});});};exports[_0xf734('0x1d')]=function(_0x4fc350){var _0x3aecca=this;return new Promise(function(_0x3e32a0,_0x4ecf02){return db['SmsQueueReport']['update'](_0x4fc350[_0xf734('0x1e')],{'raw':_0x4fc350[_0xf734('0x1a')]?_0x4fc350[_0xf734('0x1a')][_0xf734('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4fc350[_0xf734('0x1a')]?_0x4fc350['options']['where']||null:null,'attributes':_0x4fc350[_0xf734('0x1a')]?_0x4fc350[_0xf734('0x1a')][_0xf734('0x20')]||null:null,'limit':_0x4fc350[_0xf734('0x1a')]?_0x4fc350[_0xf734('0x1a')][_0xf734('0x21')]||null:null})['then'](function(_0x28b706){logger['info'](_0xf734('0x1d'),_0x4fc350);logger[_0xf734('0xf')]('UpdateSmsQueueReport',_0x4fc350,JSON[_0xf734('0x12')](_0x28b706));_0x3e32a0(_0x28b706);})['catch'](function(_0x575b8c){logger[_0xf734('0x13')]('UpdateSmsQueueReport',_0x575b8c[_0xf734('0x15')],_0x4fc350);_0x4ecf02(_0x3aecca[_0xf734('0x13')](0x1f4,_0x575b8c['message']));});});};