8ecfe6d9e5940d8035cba72858008a79ba03622c
[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 _0xaaf5=['bluebird','randomstring','../../config/logger','rpc','../../config/environment','client','request','then','SugarcrmField,\x20%s,\x20%s','SugarcrmField,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','catch','lodash','util','moment'];(function(_0x225b4b,_0x55a260){var _0xaec8c3=function(_0x23be29){while(--_0x23be29){_0x225b4b['push'](_0x225b4b['shift']());}};_0xaec8c3(++_0x55a260);}(_0xaaf5,0x1d1));var _0x5aaf=function(_0x2d822b,_0x2ce322){_0x2d822b=_0x2d822b-0x0;var _0x36ac27=_0xaaf5[_0x2d822b];return _0x36ac27;};'use strict';var _=require(_0x5aaf('0x0'));var util=require(_0x5aaf('0x1'));var moment=require(_0x5aaf('0x2'));var BPromise=require(_0x5aaf('0x3'));var rs=require(_0x5aaf('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x5aaf('0x5'))(_0x5aaf('0x6'));var config=require(_0x5aaf('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x5aaf('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x86b47,_0x135c2a,_0x53483f){return new BPromise(function(_0x50c844,_0x29a3c3){return client[_0x5aaf('0x9')](_0x86b47,_0x53483f)[_0x5aaf('0xa')](function(_0x14a6ff){logger['info'](_0x5aaf('0xb'),_0x135c2a,'request\x20sent');logger['debug'](_0x5aaf('0xc'),_0x135c2a,_0x5aaf('0xd'),JSON[_0x5aaf('0xe')](_0x14a6ff));if(_0x14a6ff[_0x5aaf('0xf')]){if(_0x14a6ff[_0x5aaf('0xf')]['code']===0x1f4){logger[_0x5aaf('0xf')]('SugarcrmField,\x20%s,\x20%s',_0x135c2a,_0x14a6ff[_0x5aaf('0xf')][_0x5aaf('0x10')]);return _0x29a3c3(_0x14a6ff['error'][_0x5aaf('0x10')]);}logger['error']('SugarcrmField,\x20%s,\x20%s',_0x135c2a,_0x14a6ff[_0x5aaf('0xf')][_0x5aaf('0x10')]);return _0x50c844(_0x14a6ff[_0x5aaf('0xf')][_0x5aaf('0x10')]);}else{logger['info'](_0x5aaf('0xb'),_0x135c2a,_0x5aaf('0xd'));_0x50c844(_0x14a6ff['result'][_0x5aaf('0x10')]);}})[_0x5aaf('0x11')](function(_0xaad3a1){logger[_0x5aaf('0xf')](_0x5aaf('0xb'),_0x135c2a,_0xaad3a1);_0x29a3c3(_0xaad3a1);});});}