de581d3bdff8f59a6931d36622326cd92c0cb25f
[motion2.git] / server / api / intFreshsalesField / intFreshsalesField.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 _0xdb67=['info','FreshsalesField,\x20%s,\x20%s','request\x20sent','debug','error','message','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','request','then'];(function(_0x3ab51d,_0x2fa01d){var _0x29a04e=function(_0x7807b0){while(--_0x7807b0){_0x3ab51d['push'](_0x3ab51d['shift']());}};_0x29a04e(++_0x2fa01d);}(_0xdb67,0x15b));var _0x7db6=function(_0x5337d3,_0x1401c7){_0x5337d3=_0x5337d3-0x0;var _0x461aa4=_0xdb67[_0x5337d3];return _0x461aa4;};'use strict';var _=require('lodash');var util=require(_0x7db6('0x0'));var moment=require(_0x7db6('0x1'));var BPromise=require(_0x7db6('0x2'));var rs=require(_0x7db6('0x3'));var fs=require('fs');var Redis=require(_0x7db6('0x4'));var db=require(_0x7db6('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x7db6('0x6'));var config=require(_0x7db6('0x7'));var jayson=require(_0x7db6('0x8'));var client=jayson[_0x7db6('0x9')][_0x7db6('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x387866,_0x470fa8,_0x444638){return new BPromise(function(_0x13311a,_0x4512db){return client[_0x7db6('0xb')](_0x387866,_0x444638)[_0x7db6('0xc')](function(_0x31bdaf){logger[_0x7db6('0xd')](_0x7db6('0xe'),_0x470fa8,_0x7db6('0xf'));logger[_0x7db6('0x10')]('FreshsalesField,\x20%s,\x20%s,\x20%s',_0x470fa8,_0x7db6('0xf'),JSON['stringify'](_0x31bdaf));if(_0x31bdaf['error']){if(_0x31bdaf[_0x7db6('0x11')]['code']===0x1f4){logger[_0x7db6('0x11')](_0x7db6('0xe'),_0x470fa8,_0x31bdaf[_0x7db6('0x11')]['message']);return _0x4512db(_0x31bdaf[_0x7db6('0x11')][_0x7db6('0x12')]);}logger['error']('FreshsalesField,\x20%s,\x20%s',_0x470fa8,_0x31bdaf[_0x7db6('0x11')][_0x7db6('0x12')]);return _0x13311a(_0x31bdaf[_0x7db6('0x11')][_0x7db6('0x12')]);}else{logger[_0x7db6('0xd')](_0x7db6('0xe'),_0x470fa8,_0x7db6('0xf'));_0x13311a(_0x31bdaf['result']['message']);}})[_0x7db6('0x13')](function(_0x4924f2){logger[_0x7db6('0x11')](_0x7db6('0xe'),_0x470fa8,_0x4924f2);_0x4512db(_0x4924f2);});});}