092a2bad57f66228af89d45fa59924652ba530c7
[motion2.git] / server / api / intZendeskField / intZendeskField.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 _0xff1f=['info','ZendeskField,\x20%s,\x20%s','request\x20sent','debug','ZendeskField,\x20%s,\x20%s,\x20%s','error','message','result','util','moment','bluebird','ioredis','../../config/logger','../../config/environment','jayson/promise','client','http','then'];(function(_0x571d87,_0x481629){var _0x38636f=function(_0x7f2c40){while(--_0x7f2c40){_0x571d87['push'](_0x571d87['shift']());}};_0x38636f(++_0x481629);}(_0xff1f,0x170));var _0xfff1=function(_0x25e7cb,_0x3579b7){_0x25e7cb=_0x25e7cb-0x0;var _0x375d92=_0xff1f[_0x25e7cb];return _0x375d92;};'use strict';var _=require('lodash');var util=require(_0xfff1('0x0'));var moment=require(_0xfff1('0x1'));var BPromise=require(_0xfff1('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xfff1('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xfff1('0x4'))('rpc');var config=require(_0xfff1('0x5'));var jayson=require(_0xfff1('0x6'));var client=jayson[_0xfff1('0x7')][_0xfff1('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1fb259,_0x5f0942,_0x16241e){return new BPromise(function(_0x27ae80,_0xc7b226){return client['request'](_0x1fb259,_0x16241e)[_0xfff1('0x9')](function(_0x1e6f44){logger[_0xfff1('0xa')](_0xfff1('0xb'),_0x5f0942,_0xfff1('0xc'));logger[_0xfff1('0xd')](_0xfff1('0xe'),_0x5f0942,'request\x20sent',JSON['stringify'](_0x1e6f44));if(_0x1e6f44[_0xfff1('0xf')]){if(_0x1e6f44['error']['code']===0x1f4){logger[_0xfff1('0xf')](_0xfff1('0xb'),_0x5f0942,_0x1e6f44[_0xfff1('0xf')][_0xfff1('0x10')]);return _0xc7b226(_0x1e6f44[_0xfff1('0xf')][_0xfff1('0x10')]);}logger[_0xfff1('0xf')](_0xfff1('0xb'),_0x5f0942,_0x1e6f44[_0xfff1('0xf')][_0xfff1('0x10')]);return _0x27ae80(_0x1e6f44['error'][_0xfff1('0x10')]);}else{logger['info'](_0xfff1('0xb'),_0x5f0942,_0xfff1('0xc'));_0x27ae80(_0x1e6f44[_0xfff1('0x11')][_0xfff1('0x10')]);}})['catch'](function(_0x495bfd){logger['error'](_0xfff1('0xb'),_0x5f0942,_0x495bfd);_0xc7b226(_0x495bfd);});});}