Built motion from commit (unavailable).|2.4.3
[motion2.git] / server / api / intZohoAccount / intZohoAccount.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 _0x641b=['ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','code','error','message','GetZohoAccount','ZohoAccount','options','where','attributes','include','model','map','catch','ShowZohoAccount','find','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','jayson/promise','client','http','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x82a393,_0x2fb70e){var _0x2e1674=function(_0x25cbc2){while(--_0x25cbc2){_0x82a393['push'](_0x82a393['shift']());}};_0x2e1674(++_0x2fb70e);}(_0x641b,0xca));var _0xb641=function(_0x169024,_0x2d658c){_0x169024=_0x169024-0x0;var _0x3fc756=_0x641b[_0x169024];return _0x3fc756;};'use strict';var _=require(_0xb641('0x0'));var util=require('util');var moment=require(_0xb641('0x1'));var BPromise=require(_0xb641('0x2'));var rs=require(_0xb641('0x3'));var fs=require('fs');var Redis=require(_0xb641('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xb641('0x5'));var logger=require(_0xb641('0x6'))('rpc');var config=require('../../config/environment');var jayson=require(_0xb641('0x7'));var client=jayson[_0xb641('0x8')][_0xb641('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1ca4ea,_0x104581,_0x1878e6){return new BPromise(function(_0x1b21f5,_0x185790){return client['request'](_0x1ca4ea,_0x1878e6)[_0xb641('0xa')](function(_0x2dbdba){logger[_0xb641('0xb')](_0xb641('0xc'),_0x104581,_0xb641('0xd'));logger[_0xb641('0xe')](_0xb641('0xf'),_0x104581,_0xb641('0xd'),JSON[_0xb641('0x10')](_0x2dbdba));if(_0x2dbdba['error']){if(_0x2dbdba['error'][_0xb641('0x11')]===0x1f4){logger[_0xb641('0x12')]('ZohoAccount,\x20%s,\x20%s',_0x104581,_0x2dbdba[_0xb641('0x12')]['message']);return _0x185790(_0x2dbdba[_0xb641('0x12')][_0xb641('0x13')]);}logger['error']('ZohoAccount,\x20%s,\x20%s',_0x104581,_0x2dbdba['error'][_0xb641('0x13')]);return _0x1b21f5(_0x2dbdba[_0xb641('0x12')][_0xb641('0x13')]);}else{logger[_0xb641('0xb')](_0xb641('0xc'),_0x104581,'request\x20sent');_0x1b21f5(_0x2dbdba['result'][_0xb641('0x13')]);}})['catch'](function(_0x270a40){logger[_0xb641('0x12')](_0xb641('0xc'),_0x104581,_0x270a40);_0x185790(_0x270a40);});});}exports[_0xb641('0x14')]=function(_0x4a8c1c){var _0x538a8e=this;return new Promise(function(_0x329a55,_0x17e862){return db[_0xb641('0x15')]['findAll']({'raw':_0x4a8c1c[_0xb641('0x16')]?_0x4a8c1c['options']['raw']===undefined?!![]:![]:!![],'where':_0x4a8c1c['options']?_0x4a8c1c[_0xb641('0x16')][_0xb641('0x17')]||null:null,'attributes':_0x4a8c1c[_0xb641('0x16')]?_0x4a8c1c['options'][_0xb641('0x18')]||null:null,'limit':_0x4a8c1c[_0xb641('0x16')]?_0x4a8c1c[_0xb641('0x16')]['limit']||null:null,'include':_0x4a8c1c[_0xb641('0x16')]?_0x4a8c1c[_0xb641('0x16')][_0xb641('0x19')]?_['map'](_0x4a8c1c[_0xb641('0x16')]['include'],function(_0x51b49b){return{'model':db[_0x51b49b[_0xb641('0x1a')]],'as':_0x51b49b['as'],'attributes':_0x51b49b[_0xb641('0x18')],'include':_0x51b49b[_0xb641('0x19')]?_[_0xb641('0x1b')](_0x51b49b[_0xb641('0x19')],function(_0x55c26f){return{'model':db[_0x55c26f['model']],'as':_0x55c26f['as'],'attributes':_0x55c26f[_0xb641('0x18')],'include':_0x55c26f[_0xb641('0x19')]?_[_0xb641('0x1b')](_0x55c26f[_0xb641('0x19')],function(_0x378169){return{'model':db[_0x378169[_0xb641('0x1a')]],'as':_0x378169['as'],'attributes':_0x378169[_0xb641('0x18')]};}):[]};}):[]};}):[]:[]})[_0xb641('0xa')](function(_0x1999a2){logger[_0xb641('0xb')](_0xb641('0x14'),_0x4a8c1c);logger[_0xb641('0xe')](_0xb641('0x14'),_0x4a8c1c,JSON['stringify'](_0x1999a2));_0x329a55(_0x1999a2);})[_0xb641('0x1c')](function(_0x3abf50){logger[_0xb641('0x12')](_0xb641('0x14'),_0x3abf50[_0xb641('0x13')],_0x4a8c1c);_0x17e862(_0x538a8e[_0xb641('0x12')](0x1f4,_0x3abf50['message']));});});};exports[_0xb641('0x1d')]=function(_0x3991d5){var _0x1e1b21=this;return new Promise(function(_0x157ad1,_0x2fa23a){return db[_0xb641('0x15')][_0xb641('0x1e')]({'raw':_0x3991d5[_0xb641('0x16')]?_0x3991d5[_0xb641('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0x3991d5[_0xb641('0x16')]?_0x3991d5['options'][_0xb641('0x17')]||null:null,'attributes':_0x3991d5[_0xb641('0x16')]?_0x3991d5[_0xb641('0x16')][_0xb641('0x18')]||null:null,'include':_0x3991d5['options']?_0x3991d5[_0xb641('0x16')]['include']?_[_0xb641('0x1b')](_0x3991d5[_0xb641('0x16')][_0xb641('0x19')],function(_0x3512f7){return{'model':db[_0x3512f7[_0xb641('0x1a')]],'as':_0x3512f7['as'],'attributes':_0x3512f7['attributes'],'include':_0x3512f7[_0xb641('0x19')]?_[_0xb641('0x1b')](_0x3512f7[_0xb641('0x19')],function(_0x243818){return{'model':db[_0x243818['model']],'as':_0x243818['as'],'attributes':_0x243818[_0xb641('0x18')],'include':_0x243818[_0xb641('0x19')]?_[_0xb641('0x1b')](_0x243818[_0xb641('0x19')],function(_0xc5b562){return{'model':db[_0xc5b562[_0xb641('0x1a')]],'as':_0xc5b562['as'],'attributes':_0xc5b562[_0xb641('0x18')]};}):[]};}):[]};}):[]:[]})[_0xb641('0xa')](function(_0xba8c2f){logger[_0xb641('0xb')](_0xb641('0x1d'),_0x3991d5);logger['debug'](_0xb641('0x1d'),_0x3991d5,JSON[_0xb641('0x10')](_0xba8c2f));_0x157ad1(_0xba8c2f);})[_0xb641('0x1c')](function(_0x55739d){logger[_0xb641('0x12')](_0xb641('0x1d'),_0x55739d[_0xb641('0x13')],_0x3991d5);_0x2fa23a(_0x1e1b21[_0xb641('0x12')](0x1f4,_0x55739d[_0xb641('0x13')]));});});};