Built motion from commit (unavailable).|2.5.30
[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 _0x1680=['ZohoAccount,\x20%s,\x20%s','GetZohoAccount','ZohoAccount','options','raw','where','attributes','include','map','model','ShowZohoAccount','find','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch'];(function(_0x4b8b33,_0xd08af8){var _0x427f85=function(_0x2cebe2){while(--_0x2cebe2){_0x4b8b33['push'](_0x4b8b33['shift']());}};_0x427f85(++_0xd08af8);}(_0x1680,0x160));var _0x0168=function(_0x30f030,_0xd03b7a){_0x30f030=_0x30f030-0x0;var _0xf7614f=_0x1680[_0x30f030];return _0xf7614f;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x0168('0x0'));var BPromise=require(_0x0168('0x1'));var rs=require(_0x0168('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0168('0x3'))['db'];var utils=require(_0x0168('0x4'));var logger=require(_0x0168('0x5'))(_0x0168('0x6'));var config=require(_0x0168('0x7'));var jayson=require(_0x0168('0x8'));var client=jayson[_0x0168('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x33d142,_0x2d9059,_0x1b7ba4){return new BPromise(function(_0x4f07ab,_0x250897){return client[_0x0168('0xa')](_0x33d142,_0x1b7ba4)[_0x0168('0xb')](function(_0x33bbd4){logger[_0x0168('0xc')]('ZohoAccount,\x20%s,\x20%s',_0x2d9059,_0x0168('0xd'));logger[_0x0168('0xe')](_0x0168('0xf'),_0x2d9059,'request\x20sent',JSON[_0x0168('0x10')](_0x33bbd4));if(_0x33bbd4[_0x0168('0x11')]){if(_0x33bbd4[_0x0168('0x11')][_0x0168('0x12')]===0x1f4){logger['error']('ZohoAccount,\x20%s,\x20%s',_0x2d9059,_0x33bbd4['error'][_0x0168('0x13')]);return _0x250897(_0x33bbd4[_0x0168('0x11')]['message']);}logger['error']('ZohoAccount,\x20%s,\x20%s',_0x2d9059,_0x33bbd4[_0x0168('0x11')][_0x0168('0x13')]);return _0x4f07ab(_0x33bbd4[_0x0168('0x11')][_0x0168('0x13')]);}else{logger[_0x0168('0xc')]('ZohoAccount,\x20%s,\x20%s',_0x2d9059,_0x0168('0xd'));_0x4f07ab(_0x33bbd4[_0x0168('0x14')]['message']);}})[_0x0168('0x15')](function(_0x4bd130){logger[_0x0168('0x11')](_0x0168('0x16'),_0x2d9059,_0x4bd130);_0x250897(_0x4bd130);});});}exports[_0x0168('0x17')]=function(_0x255b54){var _0x5920c5=this;return new Promise(function(_0x18784a,_0x4c0911){return db[_0x0168('0x18')]['findAll']({'raw':_0x255b54[_0x0168('0x19')]?_0x255b54[_0x0168('0x19')][_0x0168('0x1a')]===undefined?!![]:![]:!![],'where':_0x255b54[_0x0168('0x19')]?_0x255b54['options'][_0x0168('0x1b')]||null:null,'attributes':_0x255b54[_0x0168('0x19')]?_0x255b54[_0x0168('0x19')][_0x0168('0x1c')]||null:null,'limit':_0x255b54[_0x0168('0x19')]?_0x255b54['options']['limit']||null:null,'include':_0x255b54[_0x0168('0x19')]?_0x255b54[_0x0168('0x19')][_0x0168('0x1d')]?_[_0x0168('0x1e')](_0x255b54['options']['include'],function(_0x213589){return{'model':db[_0x213589[_0x0168('0x1f')]],'as':_0x213589['as'],'attributes':_0x213589[_0x0168('0x1c')],'include':_0x213589[_0x0168('0x1d')]?_[_0x0168('0x1e')](_0x213589[_0x0168('0x1d')],function(_0x35f30b){return{'model':db[_0x35f30b[_0x0168('0x1f')]],'as':_0x35f30b['as'],'attributes':_0x35f30b['attributes'],'include':_0x35f30b['include']?_[_0x0168('0x1e')](_0x35f30b[_0x0168('0x1d')],function(_0x528455){return{'model':db[_0x528455[_0x0168('0x1f')]],'as':_0x528455['as'],'attributes':_0x528455['attributes']};}):[]};}):[]};}):[]:[]})[_0x0168('0xb')](function(_0x54e92d){logger[_0x0168('0xc')](_0x0168('0x17'),_0x255b54);logger[_0x0168('0xe')]('GetZohoAccount',_0x255b54,JSON[_0x0168('0x10')](_0x54e92d));_0x18784a(_0x54e92d);})[_0x0168('0x15')](function(_0x91cb54){logger[_0x0168('0x11')]('GetZohoAccount',_0x91cb54[_0x0168('0x13')],_0x255b54);_0x4c0911(_0x5920c5['error'](0x1f4,_0x91cb54[_0x0168('0x13')]));});});};exports[_0x0168('0x20')]=function(_0x13e571){var _0xcd74f8=this;return new Promise(function(_0x1968bb,_0x1d0a5c){return db[_0x0168('0x18')][_0x0168('0x21')]({'raw':_0x13e571['options']?_0x13e571[_0x0168('0x19')][_0x0168('0x1a')]===undefined?!![]:![]:!![],'where':_0x13e571[_0x0168('0x19')]?_0x13e571[_0x0168('0x19')][_0x0168('0x1b')]||null:null,'attributes':_0x13e571[_0x0168('0x19')]?_0x13e571[_0x0168('0x19')][_0x0168('0x1c')]||null:null,'include':_0x13e571[_0x0168('0x19')]?_0x13e571[_0x0168('0x19')][_0x0168('0x1d')]?_[_0x0168('0x1e')](_0x13e571[_0x0168('0x19')][_0x0168('0x1d')],function(_0x8d4d52){return{'model':db[_0x8d4d52['model']],'as':_0x8d4d52['as'],'attributes':_0x8d4d52[_0x0168('0x1c')],'include':_0x8d4d52[_0x0168('0x1d')]?_[_0x0168('0x1e')](_0x8d4d52[_0x0168('0x1d')],function(_0xb65288){return{'model':db[_0xb65288[_0x0168('0x1f')]],'as':_0xb65288['as'],'attributes':_0xb65288[_0x0168('0x1c')],'include':_0xb65288[_0x0168('0x1d')]?_[_0x0168('0x1e')](_0xb65288['include'],function(_0x4d1fac){return{'model':db[_0x4d1fac['model']],'as':_0x4d1fac['as'],'attributes':_0x4d1fac[_0x0168('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x285a55){logger[_0x0168('0xc')](_0x0168('0x20'),_0x13e571);logger[_0x0168('0xe')]('ShowZohoAccount',_0x13e571,JSON[_0x0168('0x10')](_0x285a55));_0x1968bb(_0x285a55);})[_0x0168('0x15')](function(_0x98b654){logger['error'](_0x0168('0x20'),_0x98b654['message'],_0x13e571);_0x1d0a5c(_0xcd74f8[_0x0168('0x11')](0x1f4,_0x98b654[_0x0168('0x13')]));});});};