Built motion from commit c0cdc9d8.|2.6.28
[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 _0x8ff9=['model','then','ShowZohoAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetZohoAccount','ZohoAccount','findAll','options','raw','where','attributes','limit','include','map'];(function(_0x1fc997,_0x536877){var _0x4e5985=function(_0x84e87d){while(--_0x84e87d){_0x1fc997['push'](_0x1fc997['shift']());}};_0x4e5985(++_0x536877);}(_0x8ff9,0x1a6));var _0x98ff=function(_0xdf18de,_0x39ca70){_0xdf18de=_0xdf18de-0x0;var _0xae7373=_0x8ff9[_0xdf18de];return _0xae7373;};'use strict';var _=require(_0x98ff('0x0'));var util=require(_0x98ff('0x1'));var moment=require(_0x98ff('0x2'));var BPromise=require(_0x98ff('0x3'));var rs=require(_0x98ff('0x4'));var fs=require('fs');var Redis=require(_0x98ff('0x5'));var db=require(_0x98ff('0x6'))['db'];var utils=require(_0x98ff('0x7'));var logger=require(_0x98ff('0x8'))(_0x98ff('0x9'));var config=require(_0x98ff('0xa'));var jayson=require('jayson/promise');var client=jayson[_0x98ff('0xb')][_0x98ff('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x13537e,_0x21d840,_0x12d3fe){return new BPromise(function(_0xbe13f3,_0x51fbd8){return client[_0x98ff('0xd')](_0x13537e,_0x12d3fe)['then'](function(_0x4bbf37){logger[_0x98ff('0xe')](_0x98ff('0xf'),_0x21d840,_0x98ff('0x10'));logger[_0x98ff('0x11')](_0x98ff('0x12'),_0x21d840,'request\x20sent',JSON[_0x98ff('0x13')](_0x4bbf37));if(_0x4bbf37['error']){if(_0x4bbf37[_0x98ff('0x14')]['code']===0x1f4){logger['error'](_0x98ff('0xf'),_0x21d840,_0x4bbf37[_0x98ff('0x14')][_0x98ff('0x15')]);return _0x51fbd8(_0x4bbf37['error'][_0x98ff('0x15')]);}logger['error'](_0x98ff('0xf'),_0x21d840,_0x4bbf37[_0x98ff('0x14')][_0x98ff('0x15')]);return _0xbe13f3(_0x4bbf37[_0x98ff('0x14')][_0x98ff('0x15')]);}else{logger[_0x98ff('0xe')]('ZohoAccount,\x20%s,\x20%s',_0x21d840,_0x98ff('0x10'));_0xbe13f3(_0x4bbf37[_0x98ff('0x16')][_0x98ff('0x15')]);}})[_0x98ff('0x17')](function(_0x3751b9){logger[_0x98ff('0x14')](_0x98ff('0xf'),_0x21d840,_0x3751b9);_0x51fbd8(_0x3751b9);});});}exports[_0x98ff('0x18')]=function(_0x268121){var _0x3c04d4=this;return new Promise(function(_0x91e31c,_0x1611b5){return db[_0x98ff('0x19')][_0x98ff('0x1a')]({'raw':_0x268121['options']?_0x268121[_0x98ff('0x1b')][_0x98ff('0x1c')]===undefined?!![]:![]:!![],'where':_0x268121[_0x98ff('0x1b')]?_0x268121[_0x98ff('0x1b')][_0x98ff('0x1d')]||null:null,'attributes':_0x268121[_0x98ff('0x1b')]?_0x268121[_0x98ff('0x1b')][_0x98ff('0x1e')]||null:null,'limit':_0x268121[_0x98ff('0x1b')]?_0x268121[_0x98ff('0x1b')][_0x98ff('0x1f')]||null:null,'include':_0x268121[_0x98ff('0x1b')]?_0x268121[_0x98ff('0x1b')]['include']?_['map'](_0x268121['options'][_0x98ff('0x20')],function(_0x3ee01b){return{'model':db[_0x3ee01b['model']],'as':_0x3ee01b['as'],'attributes':_0x3ee01b[_0x98ff('0x1e')],'include':_0x3ee01b['include']?_[_0x98ff('0x21')](_0x3ee01b[_0x98ff('0x20')],function(_0x308efd){return{'model':db[_0x308efd[_0x98ff('0x22')]],'as':_0x308efd['as'],'attributes':_0x308efd[_0x98ff('0x1e')],'include':_0x308efd['include']?_['map'](_0x308efd[_0x98ff('0x20')],function(_0x1a4ebd){return{'model':db[_0x1a4ebd[_0x98ff('0x22')]],'as':_0x1a4ebd['as'],'attributes':_0x1a4ebd[_0x98ff('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x98ff('0x23')](function(_0x231e00){logger[_0x98ff('0xe')](_0x98ff('0x18'),_0x268121);logger[_0x98ff('0x11')](_0x98ff('0x18'),_0x268121,JSON['stringify'](_0x231e00));_0x91e31c(_0x231e00);})[_0x98ff('0x17')](function(_0x256823){logger[_0x98ff('0x14')](_0x98ff('0x18'),_0x256823[_0x98ff('0x15')],_0x268121);_0x1611b5(_0x3c04d4[_0x98ff('0x14')](0x1f4,_0x256823[_0x98ff('0x15')]));});});};exports[_0x98ff('0x24')]=function(_0x42213a){var _0x205d85=this;return new Promise(function(_0x3fa70c,_0x1472cb){return db[_0x98ff('0x19')][_0x98ff('0x25')]({'raw':_0x42213a[_0x98ff('0x1b')]?_0x42213a[_0x98ff('0x1b')][_0x98ff('0x1c')]===undefined?!![]:![]:!![],'where':_0x42213a[_0x98ff('0x1b')]?_0x42213a[_0x98ff('0x1b')][_0x98ff('0x1d')]||null:null,'attributes':_0x42213a[_0x98ff('0x1b')]?_0x42213a['options'][_0x98ff('0x1e')]||null:null,'include':_0x42213a[_0x98ff('0x1b')]?_0x42213a[_0x98ff('0x1b')][_0x98ff('0x20')]?_[_0x98ff('0x21')](_0x42213a['options'][_0x98ff('0x20')],function(_0x56b676){return{'model':db[_0x56b676[_0x98ff('0x22')]],'as':_0x56b676['as'],'attributes':_0x56b676[_0x98ff('0x1e')],'include':_0x56b676[_0x98ff('0x20')]?_[_0x98ff('0x21')](_0x56b676[_0x98ff('0x20')],function(_0x8dfe4d){return{'model':db[_0x8dfe4d[_0x98ff('0x22')]],'as':_0x8dfe4d['as'],'attributes':_0x8dfe4d[_0x98ff('0x1e')],'include':_0x8dfe4d[_0x98ff('0x20')]?_[_0x98ff('0x21')](_0x8dfe4d['include'],function(_0x20c907){return{'model':db[_0x20c907[_0x98ff('0x22')]],'as':_0x20c907['as'],'attributes':_0x20c907[_0x98ff('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x98ff('0x23')](function(_0x34219e){logger[_0x98ff('0xe')](_0x98ff('0x24'),_0x42213a);logger[_0x98ff('0x11')]('ShowZohoAccount',_0x42213a,JSON[_0x98ff('0x13')](_0x34219e));_0x3fa70c(_0x34219e);})['catch'](function(_0x13f7b1){logger[_0x98ff('0x14')](_0x98ff('0x24'),_0x13f7b1[_0x98ff('0x15')],_0x42213a);_0x1472cb(_0x205d85[_0x98ff('0x14')](0x1f4,_0x13f7b1['message']));});});};