4c9eb4eb9ff71ce99b4ffc16a0d7099d7f406114
[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 _0x145a=['../../mysqldb','../../config/utils','../../config/logger','rpc','client','request','then','CmHopperFinal,\x20%s,\x20%s','request\x20sent','debug','CmHopperFinal,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','CreateCmHopperFinal','body','options','info','lodash','moment','bluebird','randomstring'];(function(_0x2c944e,_0x26f659){var _0x2cc529=function(_0x3fbc4b){while(--_0x3fbc4b){_0x2c944e['push'](_0x2c944e['shift']());}};_0x2cc529(++_0x26f659);}(_0x145a,0x86));var _0xa145=function(_0x152bcd,_0x5b7a9a){_0x152bcd=_0x152bcd-0x0;var _0x24985e=_0x145a[_0x152bcd];return _0x24985e;};'use strict';var _=require(_0xa145('0x0'));var util=require('util');var moment=require(_0xa145('0x1'));var BPromise=require(_0xa145('0x2'));var rs=require(_0xa145('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa145('0x4'))['db'];var utils=require(_0xa145('0x5'));var logger=require(_0xa145('0x6'))(_0xa145('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xa145('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0xa1c74e,_0x198a83,_0x67f60f){return new BPromise(function(_0x336233,_0x9d0b2b){return client[_0xa145('0x9')](_0xa1c74e,_0x67f60f)[_0xa145('0xa')](function(_0xc06763){logger['info'](_0xa145('0xb'),_0x198a83,_0xa145('0xc'));logger[_0xa145('0xd')](_0xa145('0xe'),_0x198a83,'request\x20sent',JSON[_0xa145('0xf')](_0xc06763));if(_0xc06763[_0xa145('0x10')]){if(_0xc06763[_0xa145('0x10')]['code']===0x1f4){logger[_0xa145('0x10')]('CmHopperFinal,\x20%s,\x20%s',_0x198a83,_0xc06763[_0xa145('0x10')][_0xa145('0x11')]);return _0x9d0b2b(_0xc06763[_0xa145('0x10')]['message']);}logger[_0xa145('0x10')](_0xa145('0xb'),_0x198a83,_0xc06763[_0xa145('0x10')]['message']);return _0x336233(_0xc06763[_0xa145('0x10')]['message']);}else{logger['info'](_0xa145('0xb'),_0x198a83,_0xa145('0xc'));_0x336233(_0xc06763['result'][_0xa145('0x11')]);}})[_0xa145('0x12')](function(_0x3f7970){logger['error'](_0xa145('0xb'),_0x198a83,_0x3f7970);_0x9d0b2b(_0x3f7970);});});}exports[_0xa145('0x13')]=function(_0x2024d4){var _0x10235e=this;return new Promise(function(_0x2b03ef,_0x264cee){return db['CmHopperFinal']['create'](_0x2024d4[_0xa145('0x14')],{'raw':_0x2024d4['options']?_0x2024d4[_0xa145('0x15')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x539c46){logger[_0xa145('0x16')](_0xa145('0x13'),_0x2024d4);logger[_0xa145('0xd')]('CreateCmHopperFinal',_0x2024d4,JSON['stringify'](_0x539c46));_0x2b03ef(_0x539c46);})[_0xa145('0x12')](function(_0x5bdbf9){logger['error'](_0xa145('0x13'),_0x5bdbf9['message'],_0x2024d4);_0x264cee(_0x10235e[_0xa145('0x10')](0x1f4,_0x5bdbf9[_0xa145('0x11')]));});});};