e6a39f5bfcbf22b0eeedcd939a31f8cf4f5505b2
[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 _0x7bc0=['limit','then','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','SmsQueueReport,\x20%s,\x20%s','request\x20sent','debug','SmsQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CreateSmsQueueReport','SmsQueueReport','create','options','UpdateSmsQueueReport','update','body','where','attributes'];(function(_0x4cb7fc,_0x44939b){var _0x16f4c9=function(_0xb5c17e){while(--_0xb5c17e){_0x4cb7fc['push'](_0x4cb7fc['shift']());}};_0x16f4c9(++_0x44939b);}(_0x7bc0,0x19a));var _0x07bc=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x7bc0[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var util=require(_0x07bc('0x0'));var moment=require(_0x07bc('0x1'));var BPromise=require('bluebird');var rs=require(_0x07bc('0x2'));var fs=require('fs');var Redis=require(_0x07bc('0x3'));var db=require(_0x07bc('0x4'))['db'];var utils=require(_0x07bc('0x5'));var logger=require(_0x07bc('0x6'))(_0x07bc('0x7'));var config=require(_0x07bc('0x8'));var jayson=require(_0x07bc('0x9'));var client=jayson[_0x07bc('0xa')][_0x07bc('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x9ae3a5,_0x1c75c7,_0x56035b){return new BPromise(function(_0xa41d42,_0x669085){return client[_0x07bc('0xc')](_0x9ae3a5,_0x56035b)['then'](function(_0x1b5d69){logger[_0x07bc('0xd')](_0x07bc('0xe'),_0x1c75c7,_0x07bc('0xf'));logger[_0x07bc('0x10')](_0x07bc('0x11'),_0x1c75c7,_0x07bc('0xf'),JSON[_0x07bc('0x12')](_0x1b5d69));if(_0x1b5d69[_0x07bc('0x13')]){if(_0x1b5d69[_0x07bc('0x13')]['code']===0x1f4){logger[_0x07bc('0x13')]('SmsQueueReport,\x20%s,\x20%s',_0x1c75c7,_0x1b5d69[_0x07bc('0x13')][_0x07bc('0x14')]);return _0x669085(_0x1b5d69[_0x07bc('0x13')][_0x07bc('0x14')]);}logger[_0x07bc('0x13')](_0x07bc('0xe'),_0x1c75c7,_0x1b5d69['error'][_0x07bc('0x14')]);return _0xa41d42(_0x1b5d69['error'][_0x07bc('0x14')]);}else{logger[_0x07bc('0xd')](_0x07bc('0xe'),_0x1c75c7,_0x07bc('0xf'));_0xa41d42(_0x1b5d69[_0x07bc('0x15')]['message']);}})[_0x07bc('0x16')](function(_0x384747){logger[_0x07bc('0x13')](_0x07bc('0xe'),_0x1c75c7,_0x384747);_0x669085(_0x384747);});});}exports[_0x07bc('0x17')]=function(_0x3531b9){var _0xd71e09=this;return new Promise(function(_0x4ba70b,_0x9ac830){return db[_0x07bc('0x18')][_0x07bc('0x19')](_0x3531b9['body'],{'raw':_0x3531b9[_0x07bc('0x1a')]?_0x3531b9[_0x07bc('0x1a')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x5ad895){logger['info'](_0x07bc('0x17'),_0x3531b9);logger[_0x07bc('0x10')]('CreateSmsQueueReport',_0x3531b9,JSON['stringify'](_0x5ad895));_0x4ba70b(_0x5ad895);})['catch'](function(_0x2c0431){logger[_0x07bc('0x13')](_0x07bc('0x17'),_0x2c0431[_0x07bc('0x14')],_0x3531b9);_0x9ac830(_0xd71e09[_0x07bc('0x13')](0x1f4,_0x2c0431[_0x07bc('0x14')]));});});};exports[_0x07bc('0x1b')]=function(_0x2bb7a8){var _0x1ea664=this;return new Promise(function(_0x215e9d,_0x579c15){return db[_0x07bc('0x18')][_0x07bc('0x1c')](_0x2bb7a8[_0x07bc('0x1d')],{'raw':_0x2bb7a8[_0x07bc('0x1a')]?_0x2bb7a8['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2bb7a8[_0x07bc('0x1a')]?_0x2bb7a8[_0x07bc('0x1a')][_0x07bc('0x1e')]||null:null,'attributes':_0x2bb7a8[_0x07bc('0x1a')]?_0x2bb7a8['options'][_0x07bc('0x1f')]||null:null,'limit':_0x2bb7a8[_0x07bc('0x1a')]?_0x2bb7a8[_0x07bc('0x1a')][_0x07bc('0x20')]||null:null})[_0x07bc('0x21')](function(_0xa6177){logger['info'](_0x07bc('0x1b'),_0x2bb7a8);logger[_0x07bc('0x10')](_0x07bc('0x1b'),_0x2bb7a8,JSON[_0x07bc('0x12')](_0xa6177));_0x215e9d(_0xa6177);})[_0x07bc('0x16')](function(_0x225510){logger[_0x07bc('0x13')](_0x07bc('0x1b'),_0x225510[_0x07bc('0x14')],_0x2bb7a8);_0x579c15(_0x1ea664[_0x07bc('0x13')](0x1f4,_0x225510['message']));});});};