Built motion from commit 3e059bc2.|2.5.32
[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 _0x4697=['SugarcrmField,\x20%s,\x20%s','request\x20sent','SugarcrmField,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','util','randomstring','ioredis','rpc','../../config/environment','jayson/promise','client','request','then','info'];(function(_0x1cbfcc,_0x343b18){var _0x530657=function(_0x27362c){while(--_0x27362c){_0x1cbfcc['push'](_0x1cbfcc['shift']());}};_0x530657(++_0x343b18);}(_0x4697,0x113));var _0x7469=function(_0x5e378a,_0x47d455){_0x5e378a=_0x5e378a-0x0;var _0x596d31=_0x4697[_0x5e378a];return _0x596d31;};'use strict';var _=require('lodash');var util=require(_0x7469('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x7469('0x1'));var fs=require('fs');var Redis=require(_0x7469('0x2'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x7469('0x3'));var config=require(_0x7469('0x4'));var jayson=require(_0x7469('0x5'));var client=jayson[_0x7469('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0x508368,_0x60220,_0x3d3765){return new BPromise(function(_0xc6279c,_0x425483){return client[_0x7469('0x7')](_0x508368,_0x3d3765)[_0x7469('0x8')](function(_0x16a102){logger[_0x7469('0x9')](_0x7469('0xa'),_0x60220,_0x7469('0xb'));logger['debug'](_0x7469('0xc'),_0x60220,_0x7469('0xb'),JSON[_0x7469('0xd')](_0x16a102));if(_0x16a102['error']){if(_0x16a102[_0x7469('0xe')][_0x7469('0xf')]===0x1f4){logger[_0x7469('0xe')]('SugarcrmField,\x20%s,\x20%s',_0x60220,_0x16a102['error'][_0x7469('0x10')]);return _0x425483(_0x16a102[_0x7469('0xe')][_0x7469('0x10')]);}logger[_0x7469('0xe')](_0x7469('0xa'),_0x60220,_0x16a102['error'][_0x7469('0x10')]);return _0xc6279c(_0x16a102[_0x7469('0xe')][_0x7469('0x10')]);}else{logger[_0x7469('0x9')](_0x7469('0xa'),_0x60220,_0x7469('0xb'));_0xc6279c(_0x16a102[_0x7469('0x11')]['message']);}})[_0x7469('0x12')](function(_0x3dbb7d){logger['error'](_0x7469('0xa'),_0x60220,_0x3dbb7d);_0x425483(_0x3dbb7d);});});}