7448b4b7cb7b752f3a6348918996db446c3fb105
[motion2.git] / server / api / cmHopperFinal / cmHopperFinal.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 _0xf071=['options','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','then','info','CmHopperFinal,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','CreateCmHopperFinal','CmHopperFinal','body'];(function(_0x251d4e,_0x355ef5){var _0x5b54b6=function(_0x399e09){while(--_0x399e09){_0x251d4e['push'](_0x251d4e['shift']());}};_0x5b54b6(++_0x355ef5);}(_0xf071,0x191));var _0x1f07=function(_0x1b9576,_0x55609f){_0x1b9576=_0x1b9576-0x0;var _0x5d0218=_0xf071[_0x1b9576];return _0x5d0218;};'use strict';var _=require(_0x1f07('0x0'));var util=require(_0x1f07('0x1'));var moment=require(_0x1f07('0x2'));var BPromise=require(_0x1f07('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1f07('0x4'));var db=require(_0x1f07('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x1f07('0x6'))(_0x1f07('0x7'));var config=require(_0x1f07('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x1f07('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x8c6c4e,_0x90b6ca,_0x4fa694){return new BPromise(function(_0x396243,_0x14f6ec){return client['request'](_0x8c6c4e,_0x4fa694)[_0x1f07('0xa')](function(_0x545d70){logger[_0x1f07('0xb')](_0x1f07('0xc'),_0x90b6ca,'request\x20sent');logger[_0x1f07('0xd')]('CmHopperFinal,\x20%s,\x20%s,\x20%s',_0x90b6ca,_0x1f07('0xe'),JSON[_0x1f07('0xf')](_0x545d70));if(_0x545d70['error']){if(_0x545d70[_0x1f07('0x10')][_0x1f07('0x11')]===0x1f4){logger[_0x1f07('0x10')](_0x1f07('0xc'),_0x90b6ca,_0x545d70['error'][_0x1f07('0x12')]);return _0x14f6ec(_0x545d70[_0x1f07('0x10')][_0x1f07('0x12')]);}logger[_0x1f07('0x10')](_0x1f07('0xc'),_0x90b6ca,_0x545d70[_0x1f07('0x10')]['message']);return _0x396243(_0x545d70[_0x1f07('0x10')]['message']);}else{logger[_0x1f07('0xb')]('CmHopperFinal,\x20%s,\x20%s',_0x90b6ca,_0x1f07('0xe'));_0x396243(_0x545d70[_0x1f07('0x13')][_0x1f07('0x12')]);}})[_0x1f07('0x14')](function(_0x14bd3e){logger[_0x1f07('0x10')]('CmHopperFinal,\x20%s,\x20%s',_0x90b6ca,_0x14bd3e);_0x14f6ec(_0x14bd3e);});});}exports[_0x1f07('0x15')]=function(_0x4eec22){var _0x3312d9=this;return new Promise(function(_0x357373,_0x84364e){return db[_0x1f07('0x16')]['create'](_0x4eec22[_0x1f07('0x17')],{'raw':_0x4eec22[_0x1f07('0x18')]?_0x4eec22[_0x1f07('0x18')]['raw']===undefined?!![]:![]:!![]})[_0x1f07('0xa')](function(_0x39a328){logger[_0x1f07('0xb')](_0x1f07('0x15'),_0x4eec22);logger[_0x1f07('0xd')](_0x1f07('0x15'),_0x4eec22,JSON[_0x1f07('0xf')](_0x39a328));_0x357373(_0x39a328);})[_0x1f07('0x14')](function(_0x74a51a){logger['error'](_0x1f07('0x15'),_0x74a51a[_0x1f07('0x12')],_0x4eec22);_0x84364e(_0x3312d9[_0x1f07('0x10')](0x1f4,_0x74a51a[_0x1f07('0x12')]));});});};