9d2416c75ce44f7aa88572ce5b5d093cca394f6b
[motion2.git] / server / api / crmNation / crmNation.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 _0x3374=['stringify','error','code','message','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','http','info','CrmNation,\x20%s,\x20%s','request\x20sent','CrmNation,\x20%s,\x20%s,\x20%s'];(function(_0x3ab51d,_0x2fa01d){var _0x29a04e=function(_0x7807b0){while(--_0x7807b0){_0x3ab51d['push'](_0x3ab51d['shift']());}};_0x29a04e(++_0x2fa01d);}(_0x3374,0x112));var _0x4337=function(_0x1eacd7,_0x283067){_0x1eacd7=_0x1eacd7-0x0;var _0x5a4208=_0x3374[_0x1eacd7];return _0x5a4208;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x4337('0x0'));var BPromise=require(_0x4337('0x1'));var rs=require(_0x4337('0x2'));var fs=require('fs');var Redis=require(_0x4337('0x3'));var db=require(_0x4337('0x4'))['db'];var utils=require(_0x4337('0x5'));var logger=require('../../config/logger')(_0x4337('0x6'));var config=require('../../config/environment');var jayson=require(_0x4337('0x7'));var client=jayson[_0x4337('0x8')][_0x4337('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xf6d331,_0x2f1c70,_0x4774f5){return new BPromise(function(_0x1e1475,_0x1ce9c8){return client['request'](_0xf6d331,_0x4774f5)['then'](function(_0x35d4ba){logger[_0x4337('0xa')](_0x4337('0xb'),_0x2f1c70,_0x4337('0xc'));logger['debug'](_0x4337('0xd'),_0x2f1c70,_0x4337('0xc'),JSON[_0x4337('0xe')](_0x35d4ba));if(_0x35d4ba[_0x4337('0xf')]){if(_0x35d4ba['error'][_0x4337('0x10')]===0x1f4){logger[_0x4337('0xf')](_0x4337('0xb'),_0x2f1c70,_0x35d4ba[_0x4337('0xf')]['message']);return _0x1ce9c8(_0x35d4ba[_0x4337('0xf')][_0x4337('0x11')]);}logger[_0x4337('0xf')](_0x4337('0xb'),_0x2f1c70,_0x35d4ba[_0x4337('0xf')]['message']);return _0x1e1475(_0x35d4ba[_0x4337('0xf')][_0x4337('0x11')]);}else{logger['info'](_0x4337('0xb'),_0x2f1c70,'request\x20sent');_0x1e1475(_0x35d4ba['result']['message']);}})['catch'](function(_0x7cdb63){logger['error'](_0x4337('0xb'),_0x2f1c70,_0x7cdb63);_0x1ce9c8(_0x7cdb63);});});}