6da1445a1d0be933eaf29d2630b16bed028d5b60
[motion2.git] / server / api / intSugarcrmField / intSugarcrmField.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 _0xe9b2=['../../mysqldb','../../config/logger','../../config/environment','jayson/promise','http','request','then','request\x20sent','debug','stringify','error','SugarcrmField,\x20%s,\x20%s','info','result','message','catch','util','moment','ioredis'];(function(_0x1e3b26,_0x14ea53){var _0x2eeeaf=function(_0x2bb84c){while(--_0x2bb84c){_0x1e3b26['push'](_0x1e3b26['shift']());}};_0x2eeeaf(++_0x14ea53);}(_0xe9b2,0x153));var _0x2e9b=function(_0x9553a2,_0x5424d9){_0x9553a2=_0x9553a2-0x0;var _0x3e398c=_0xe9b2[_0x9553a2];return _0x3e398c;};'use strict';var _=require('lodash');var util=require(_0x2e9b('0x0'));var moment=require(_0x2e9b('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2e9b('0x2'));var db=require(_0x2e9b('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x2e9b('0x4'))('rpc');var config=require(_0x2e9b('0x5'));var jayson=require(_0x2e9b('0x6'));var client=jayson['client'][_0x2e9b('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x1506b0,_0x2ae3cf,_0x3a91c3){return new BPromise(function(_0xd27ae8,_0x450f6d){return client[_0x2e9b('0x8')](_0x1506b0,_0x3a91c3)[_0x2e9b('0x9')](function(_0x3d78a7){logger['info']('SugarcrmField,\x20%s,\x20%s',_0x2ae3cf,_0x2e9b('0xa'));logger[_0x2e9b('0xb')]('SugarcrmField,\x20%s,\x20%s,\x20%s',_0x2ae3cf,_0x2e9b('0xa'),JSON[_0x2e9b('0xc')](_0x3d78a7));if(_0x3d78a7[_0x2e9b('0xd')]){if(_0x3d78a7[_0x2e9b('0xd')]['code']===0x1f4){logger['error'](_0x2e9b('0xe'),_0x2ae3cf,_0x3d78a7['error']['message']);return _0x450f6d(_0x3d78a7[_0x2e9b('0xd')]['message']);}logger[_0x2e9b('0xd')]('SugarcrmField,\x20%s,\x20%s',_0x2ae3cf,_0x3d78a7['error']['message']);return _0xd27ae8(_0x3d78a7['error']['message']);}else{logger[_0x2e9b('0xf')](_0x2e9b('0xe'),_0x2ae3cf,_0x2e9b('0xa'));_0xd27ae8(_0x3d78a7[_0x2e9b('0x10')][_0x2e9b('0x11')]);}})[_0x2e9b('0x12')](function(_0x42685d){logger[_0x2e9b('0xd')]('SugarcrmField,\x20%s,\x20%s',_0x2ae3cf,_0x42685d);_0x450f6d(_0x42685d);});});}