9b671bc87bf204cf43ad1a3ea03d2b0171563e9a
[motion2.git] / server / api / intFreshdeskField / intFreshdeskField.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 _0xaa77=['request\x20sent','debug','stringify','error','message','result','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','then','info','FreshdeskField,\x20%s,\x20%s'];(function(_0x5bb1e9,_0x15f025){var _0x262c24=function(_0x553d41){while(--_0x553d41){_0x5bb1e9['push'](_0x5bb1e9['shift']());}};_0x262c24(++_0x15f025);}(_0xaa77,0x1a8));var _0x7aa7=function(_0x18c7a0,_0x464635){_0x18c7a0=_0x18c7a0-0x0;var _0x5b3f8d=_0xaa77[_0x18c7a0];return _0x5b3f8d;};'use strict';var _=require('lodash');var util=require(_0x7aa7('0x0'));var moment=require(_0x7aa7('0x1'));var BPromise=require(_0x7aa7('0x2'));var rs=require(_0x7aa7('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7aa7('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x7aa7('0x5'))(_0x7aa7('0x6'));var config=require(_0x7aa7('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x7aa7('0x8')][_0x7aa7('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x47b659,_0x4c5214,_0x401e37){return new BPromise(function(_0x360d96,_0x370048){return client['request'](_0x47b659,_0x401e37)[_0x7aa7('0xa')](function(_0x1af7c1){logger[_0x7aa7('0xb')](_0x7aa7('0xc'),_0x4c5214,_0x7aa7('0xd'));logger[_0x7aa7('0xe')]('FreshdeskField,\x20%s,\x20%s,\x20%s',_0x4c5214,_0x7aa7('0xd'),JSON[_0x7aa7('0xf')](_0x1af7c1));if(_0x1af7c1[_0x7aa7('0x10')]){if(_0x1af7c1[_0x7aa7('0x10')]['code']===0x1f4){logger['error']('FreshdeskField,\x20%s,\x20%s',_0x4c5214,_0x1af7c1['error']['message']);return _0x370048(_0x1af7c1[_0x7aa7('0x10')][_0x7aa7('0x11')]);}logger[_0x7aa7('0x10')](_0x7aa7('0xc'),_0x4c5214,_0x1af7c1[_0x7aa7('0x10')][_0x7aa7('0x11')]);return _0x360d96(_0x1af7c1['error'][_0x7aa7('0x11')]);}else{logger['info'](_0x7aa7('0xc'),_0x4c5214,'request\x20sent');_0x360d96(_0x1af7c1[_0x7aa7('0x12')]['message']);}})['catch'](function(_0x21bc04){logger['error'](_0x7aa7('0xc'),_0x4c5214,_0x21bc04);_0x370048(_0x21bc04);});});}