b467ca1136733ffe022f3448e911cdbfcc47271e
[motion2.git] / server / api / voiceDialReport / voiceDialReport.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 _0xfd44=['VoiceDialReport,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','VoiceDialReport','create','raw','CreateVoiceDialReport','UpdateVoiceDialReport','update','body','options','where','attributes','limit','debug','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info'];(function(_0x546140,_0x2c4dbb){var _0x1a82d2=function(_0x20f4b6){while(--_0x20f4b6){_0x546140['push'](_0x546140['shift']());}};_0x1a82d2(++_0x2c4dbb);}(_0xfd44,0x149));var _0x4fd4=function(_0x4a3fca,_0x6905e2){_0x4a3fca=_0x4a3fca-0x0;var _0x34e59a=_0xfd44[_0x4a3fca];return _0x34e59a;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x4fd4('0x0'));var fs=require('fs');var Redis=require(_0x4fd4('0x1'));var db=require(_0x4fd4('0x2'))['db'];var utils=require(_0x4fd4('0x3'));var logger=require(_0x4fd4('0x4'))(_0x4fd4('0x5'));var config=require(_0x4fd4('0x6'));var jayson=require(_0x4fd4('0x7'));var client=jayson[_0x4fd4('0x8')][_0x4fd4('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xd8524,_0x6fd4dd,_0x4113d2){return new BPromise(function(_0x246e76,_0x3db893){return client['request'](_0xd8524,_0x4113d2)[_0x4fd4('0xa')](function(_0x549bed){logger[_0x4fd4('0xb')](_0x4fd4('0xc'),_0x6fd4dd,_0x4fd4('0xd'));logger['debug']('VoiceDialReport,\x20%s,\x20%s,\x20%s',_0x6fd4dd,_0x4fd4('0xd'),JSON[_0x4fd4('0xe')](_0x549bed));if(_0x549bed['error']){if(_0x549bed[_0x4fd4('0xf')]['code']===0x1f4){logger['error'](_0x4fd4('0xc'),_0x6fd4dd,_0x549bed[_0x4fd4('0xf')][_0x4fd4('0x10')]);return _0x3db893(_0x549bed[_0x4fd4('0xf')][_0x4fd4('0x10')]);}logger['error'](_0x4fd4('0xc'),_0x6fd4dd,_0x549bed[_0x4fd4('0xf')][_0x4fd4('0x10')]);return _0x246e76(_0x549bed[_0x4fd4('0xf')][_0x4fd4('0x10')]);}else{logger[_0x4fd4('0xb')](_0x4fd4('0xc'),_0x6fd4dd,_0x4fd4('0xd'));_0x246e76(_0x549bed[_0x4fd4('0x11')][_0x4fd4('0x10')]);}})[_0x4fd4('0x12')](function(_0x1ee2fc){logger[_0x4fd4('0xf')](_0x4fd4('0xc'),_0x6fd4dd,_0x1ee2fc);_0x3db893(_0x1ee2fc);});});}exports['CreateVoiceDialReport']=function(_0x3828f9){var _0x4c90fd=this;return new Promise(function(_0x23fcbd,_0x20f33d){return db[_0x4fd4('0x13')][_0x4fd4('0x14')](_0x3828f9['body'],{'raw':_0x3828f9['options']?_0x3828f9['options'][_0x4fd4('0x15')]===undefined?!![]:![]:!![]})[_0x4fd4('0xa')](function(_0x38f142){logger[_0x4fd4('0xb')]('CreateVoiceDialReport',_0x3828f9);logger['debug']('CreateVoiceDialReport',_0x3828f9,JSON[_0x4fd4('0xe')](_0x38f142));_0x23fcbd(_0x38f142);})[_0x4fd4('0x12')](function(_0x45679a){logger[_0x4fd4('0xf')](_0x4fd4('0x16'),_0x45679a['message'],_0x3828f9);_0x20f33d(_0x4c90fd[_0x4fd4('0xf')](0x1f4,_0x45679a[_0x4fd4('0x10')]));});});};exports[_0x4fd4('0x17')]=function(_0x156bea){var _0x3e2817=this;return new Promise(function(_0x442542,_0x557f0a){return db['VoiceDialReport'][_0x4fd4('0x18')](_0x156bea[_0x4fd4('0x19')],{'raw':_0x156bea[_0x4fd4('0x1a')]?_0x156bea[_0x4fd4('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x156bea[_0x4fd4('0x1a')]?_0x156bea['options'][_0x4fd4('0x1b')]||null:null,'attributes':_0x156bea['options']?_0x156bea[_0x4fd4('0x1a')][_0x4fd4('0x1c')]||null:null,'limit':_0x156bea[_0x4fd4('0x1a')]?_0x156bea[_0x4fd4('0x1a')][_0x4fd4('0x1d')]||null:null})['then'](function(_0x2a4834){logger['info'](_0x4fd4('0x17'),_0x156bea);logger[_0x4fd4('0x1e')](_0x4fd4('0x17'),_0x156bea,JSON[_0x4fd4('0xe')](_0x2a4834));_0x442542(_0x2a4834);})[_0x4fd4('0x12')](function(_0x438135){logger['error'](_0x4fd4('0x17'),_0x438135['message'],_0x156bea);_0x557f0a(_0x3e2817[_0x4fd4('0xf')](0x1f4,_0x438135[_0x4fd4('0x10')]));});});};