6850796d50d08089216daf0b647b30f3136175d8
[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 _0xaebd=['GetZohoAccount','findAll','options','raw','attributes','include','map','model','debug','ShowZohoAccount','ZohoAccount','find','where','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info','request\x20sent','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','ZohoAccount,\x20%s,\x20%s','catch'];(function(_0x8358c6,_0x4b59e0){var _0x4c1af1=function(_0x1a945c){while(--_0x1a945c){_0x8358c6['push'](_0x8358c6['shift']());}};_0x4c1af1(++_0x4b59e0);}(_0xaebd,0x1e9));var _0xdaeb=function(_0x47eee2,_0x3d1e28){_0x47eee2=_0x47eee2-0x0;var _0x3941d7=_0xaebd[_0x47eee2];return _0x3941d7;};'use strict';var _=require(_0xdaeb('0x0'));var util=require('util');var moment=require(_0xdaeb('0x1'));var BPromise=require(_0xdaeb('0x2'));var rs=require(_0xdaeb('0x3'));var fs=require('fs');var Redis=require(_0xdaeb('0x4'));var db=require(_0xdaeb('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xdaeb('0x6'))(_0xdaeb('0x7'));var config=require(_0xdaeb('0x8'));var jayson=require(_0xdaeb('0x9'));var client=jayson[_0xdaeb('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3ea090,_0x3f7ba1,_0x52c717){return new BPromise(function(_0x550bd9,_0x1b9d37){return client[_0xdaeb('0xb')](_0x3ea090,_0x52c717)[_0xdaeb('0xc')](function(_0x5e0ae9){logger[_0xdaeb('0xd')]('ZohoAccount,\x20%s,\x20%s',_0x3f7ba1,_0xdaeb('0xe'));logger['debug'](_0xdaeb('0xf'),_0x3f7ba1,'request\x20sent',JSON[_0xdaeb('0x10')](_0x5e0ae9));if(_0x5e0ae9[_0xdaeb('0x11')]){if(_0x5e0ae9['error']['code']===0x1f4){logger[_0xdaeb('0x11')]('ZohoAccount,\x20%s,\x20%s',_0x3f7ba1,_0x5e0ae9[_0xdaeb('0x11')][_0xdaeb('0x12')]);return _0x1b9d37(_0x5e0ae9[_0xdaeb('0x11')][_0xdaeb('0x12')]);}logger[_0xdaeb('0x11')](_0xdaeb('0x13'),_0x3f7ba1,_0x5e0ae9[_0xdaeb('0x11')]['message']);return _0x550bd9(_0x5e0ae9['error'][_0xdaeb('0x12')]);}else{logger[_0xdaeb('0xd')](_0xdaeb('0x13'),_0x3f7ba1,_0xdaeb('0xe'));_0x550bd9(_0x5e0ae9['result']['message']);}})[_0xdaeb('0x14')](function(_0x4dd803){logger['error'](_0xdaeb('0x13'),_0x3f7ba1,_0x4dd803);_0x1b9d37(_0x4dd803);});});}exports[_0xdaeb('0x15')]=function(_0x1b5243){var _0x1fe84e=this;return new Promise(function(_0x2d8f11,_0x36f9ac){return db['ZohoAccount'][_0xdaeb('0x16')]({'raw':_0x1b5243['options']?_0x1b5243[_0xdaeb('0x17')][_0xdaeb('0x18')]===undefined?!![]:![]:!![],'where':_0x1b5243[_0xdaeb('0x17')]?_0x1b5243['options']['where']||null:null,'attributes':_0x1b5243[_0xdaeb('0x17')]?_0x1b5243[_0xdaeb('0x17')][_0xdaeb('0x19')]||null:null,'limit':_0x1b5243[_0xdaeb('0x17')]?_0x1b5243[_0xdaeb('0x17')]['limit']||null:null,'include':_0x1b5243['options']?_0x1b5243[_0xdaeb('0x17')][_0xdaeb('0x1a')]?_[_0xdaeb('0x1b')](_0x1b5243[_0xdaeb('0x17')][_0xdaeb('0x1a')],function(_0x55c825){return{'model':db[_0x55c825[_0xdaeb('0x1c')]],'as':_0x55c825['as'],'attributes':_0x55c825['attributes'],'include':_0x55c825[_0xdaeb('0x1a')]?_[_0xdaeb('0x1b')](_0x55c825[_0xdaeb('0x1a')],function(_0x3b0770){return{'model':db[_0x3b0770[_0xdaeb('0x1c')]],'as':_0x3b0770['as'],'attributes':_0x3b0770['attributes'],'include':_0x3b0770[_0xdaeb('0x1a')]?_[_0xdaeb('0x1b')](_0x3b0770[_0xdaeb('0x1a')],function(_0x4eb719){return{'model':db[_0x4eb719['model']],'as':_0x4eb719['as'],'attributes':_0x4eb719[_0xdaeb('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5045f8){logger[_0xdaeb('0xd')](_0xdaeb('0x15'),_0x1b5243);logger[_0xdaeb('0x1d')]('GetZohoAccount',_0x1b5243,JSON['stringify'](_0x5045f8));_0x2d8f11(_0x5045f8);})[_0xdaeb('0x14')](function(_0x440022){logger[_0xdaeb('0x11')]('GetZohoAccount',_0x440022[_0xdaeb('0x12')],_0x1b5243);_0x36f9ac(_0x1fe84e['error'](0x1f4,_0x440022['message']));});});};exports[_0xdaeb('0x1e')]=function(_0x21f6cf){var _0x2fb019=this;return new Promise(function(_0x28c15c,_0x3276c2){return db[_0xdaeb('0x1f')][_0xdaeb('0x20')]({'raw':_0x21f6cf['options']?_0x21f6cf[_0xdaeb('0x17')][_0xdaeb('0x18')]===undefined?!![]:![]:!![],'where':_0x21f6cf[_0xdaeb('0x17')]?_0x21f6cf[_0xdaeb('0x17')][_0xdaeb('0x21')]||null:null,'attributes':_0x21f6cf['options']?_0x21f6cf[_0xdaeb('0x17')][_0xdaeb('0x19')]||null:null,'include':_0x21f6cf['options']?_0x21f6cf[_0xdaeb('0x17')][_0xdaeb('0x1a')]?_[_0xdaeb('0x1b')](_0x21f6cf[_0xdaeb('0x17')][_0xdaeb('0x1a')],function(_0x1628b8){return{'model':db[_0x1628b8[_0xdaeb('0x1c')]],'as':_0x1628b8['as'],'attributes':_0x1628b8[_0xdaeb('0x19')],'include':_0x1628b8[_0xdaeb('0x1a')]?_[_0xdaeb('0x1b')](_0x1628b8['include'],function(_0x53b6c4){return{'model':db[_0x53b6c4[_0xdaeb('0x1c')]],'as':_0x53b6c4['as'],'attributes':_0x53b6c4['attributes'],'include':_0x53b6c4[_0xdaeb('0x1a')]?_[_0xdaeb('0x1b')](_0x53b6c4[_0xdaeb('0x1a')],function(_0x331624){return{'model':db[_0x331624[_0xdaeb('0x1c')]],'as':_0x331624['as'],'attributes':_0x331624[_0xdaeb('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1f4dcb){logger[_0xdaeb('0xd')](_0xdaeb('0x1e'),_0x21f6cf);logger['debug'](_0xdaeb('0x1e'),_0x21f6cf,JSON[_0xdaeb('0x10')](_0x1f4dcb));_0x28c15c(_0x1f4dcb);})[_0xdaeb('0x14')](function(_0x104c90){logger[_0xdaeb('0x11')](_0xdaeb('0x1e'),_0x104c90[_0xdaeb('0x12')],_0x21f6cf);_0x3276c2(_0x2fb019['error'](0x1f4,_0x104c90[_0xdaeb('0x12')]));});});};