ad6f4d6dc26331fdf33846d06128435d2c27d434
[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 _0xb5fb=['../../config/environment','jayson/promise','client','http','request','info','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','ZohoAccount,\x20%s,\x20%s','message','GetZohoAccount','findAll','options','where','limit','map','include','model','attributes','then','ShowZohoAccount','ZohoAccount','raw','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0xd1f099,_0x48a728){var _0x5db86d=function(_0x81c62f){while(--_0x81c62f){_0xd1f099['push'](_0xd1f099['shift']());}};_0x5db86d(++_0x48a728);}(_0xb5fb,0x172));var _0xbb5f=function(_0x7d5b1b,_0x20e692){_0x7d5b1b=_0x7d5b1b-0x0;var _0x51988c=_0xb5fb[_0x7d5b1b];return _0x51988c;};'use strict';var _=require(_0xbb5f('0x0'));var util=require(_0xbb5f('0x1'));var moment=require(_0xbb5f('0x2'));var BPromise=require(_0xbb5f('0x3'));var rs=require(_0xbb5f('0x4'));var fs=require('fs');var Redis=require(_0xbb5f('0x5'));var db=require(_0xbb5f('0x6'))['db'];var utils=require(_0xbb5f('0x7'));var logger=require(_0xbb5f('0x8'))(_0xbb5f('0x9'));var config=require(_0xbb5f('0xa'));var jayson=require(_0xbb5f('0xb'));var client=jayson[_0xbb5f('0xc')][_0xbb5f('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x487a1a,_0x597050,_0x317cd9){return new BPromise(function(_0x5e7943,_0x5b91){return client[_0xbb5f('0xe')](_0x487a1a,_0x317cd9)['then'](function(_0x4f13a9){logger[_0xbb5f('0xf')]('ZohoAccount,\x20%s,\x20%s',_0x597050,_0xbb5f('0x10'));logger[_0xbb5f('0x11')](_0xbb5f('0x12'),_0x597050,_0xbb5f('0x10'),JSON[_0xbb5f('0x13')](_0x4f13a9));if(_0x4f13a9[_0xbb5f('0x14')]){if(_0x4f13a9[_0xbb5f('0x14')][_0xbb5f('0x15')]===0x1f4){logger['error'](_0xbb5f('0x16'),_0x597050,_0x4f13a9['error'][_0xbb5f('0x17')]);return _0x5b91(_0x4f13a9[_0xbb5f('0x14')][_0xbb5f('0x17')]);}logger['error'](_0xbb5f('0x16'),_0x597050,_0x4f13a9[_0xbb5f('0x14')]['message']);return _0x5e7943(_0x4f13a9[_0xbb5f('0x14')][_0xbb5f('0x17')]);}else{logger[_0xbb5f('0xf')](_0xbb5f('0x16'),_0x597050,'request\x20sent');_0x5e7943(_0x4f13a9['result'][_0xbb5f('0x17')]);}})['catch'](function(_0xdf4ec8){logger[_0xbb5f('0x14')]('ZohoAccount,\x20%s,\x20%s',_0x597050,_0xdf4ec8);_0x5b91(_0xdf4ec8);});});}exports[_0xbb5f('0x18')]=function(_0x4cc050){var _0x313a0e=this;return new Promise(function(_0xca33c1,_0x5944f9){return db['ZohoAccount'][_0xbb5f('0x19')]({'raw':_0x4cc050[_0xbb5f('0x1a')]?_0x4cc050[_0xbb5f('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x4cc050[_0xbb5f('0x1a')]?_0x4cc050['options'][_0xbb5f('0x1b')]||null:null,'attributes':_0x4cc050[_0xbb5f('0x1a')]?_0x4cc050[_0xbb5f('0x1a')]['attributes']||null:null,'limit':_0x4cc050[_0xbb5f('0x1a')]?_0x4cc050['options'][_0xbb5f('0x1c')]||null:null,'include':_0x4cc050['options']?_0x4cc050[_0xbb5f('0x1a')]['include']?_[_0xbb5f('0x1d')](_0x4cc050['options'][_0xbb5f('0x1e')],function(_0xb35efe){return{'model':db[_0xb35efe[_0xbb5f('0x1f')]],'as':_0xb35efe['as'],'attributes':_0xb35efe['attributes'],'include':_0xb35efe[_0xbb5f('0x1e')]?_['map'](_0xb35efe['include'],function(_0x41be1c){return{'model':db[_0x41be1c[_0xbb5f('0x1f')]],'as':_0x41be1c['as'],'attributes':_0x41be1c[_0xbb5f('0x20')],'include':_0x41be1c[_0xbb5f('0x1e')]?_[_0xbb5f('0x1d')](_0x41be1c[_0xbb5f('0x1e')],function(_0x150e10){return{'model':db[_0x150e10[_0xbb5f('0x1f')]],'as':_0x150e10['as'],'attributes':_0x150e10[_0xbb5f('0x20')]};}):[]};}):[]};}):[]:[]})[_0xbb5f('0x21')](function(_0xa87ebb){logger[_0xbb5f('0xf')](_0xbb5f('0x18'),_0x4cc050);logger[_0xbb5f('0x11')](_0xbb5f('0x18'),_0x4cc050,JSON[_0xbb5f('0x13')](_0xa87ebb));_0xca33c1(_0xa87ebb);})['catch'](function(_0x5a2f1a){logger[_0xbb5f('0x14')](_0xbb5f('0x18'),_0x5a2f1a['message'],_0x4cc050);_0x5944f9(_0x313a0e[_0xbb5f('0x14')](0x1f4,_0x5a2f1a['message']));});});};exports[_0xbb5f('0x22')]=function(_0x30641a){var _0xa2adf2=this;return new Promise(function(_0x24e8c2,_0x22d528){return db[_0xbb5f('0x23')]['find']({'raw':_0x30641a[_0xbb5f('0x1a')]?_0x30641a[_0xbb5f('0x1a')][_0xbb5f('0x24')]===undefined?!![]:![]:!![],'where':_0x30641a[_0xbb5f('0x1a')]?_0x30641a[_0xbb5f('0x1a')][_0xbb5f('0x1b')]||null:null,'attributes':_0x30641a[_0xbb5f('0x1a')]?_0x30641a[_0xbb5f('0x1a')][_0xbb5f('0x20')]||null:null,'include':_0x30641a[_0xbb5f('0x1a')]?_0x30641a[_0xbb5f('0x1a')][_0xbb5f('0x1e')]?_['map'](_0x30641a[_0xbb5f('0x1a')][_0xbb5f('0x1e')],function(_0x543b0e){return{'model':db[_0x543b0e[_0xbb5f('0x1f')]],'as':_0x543b0e['as'],'attributes':_0x543b0e['attributes'],'include':_0x543b0e[_0xbb5f('0x1e')]?_['map'](_0x543b0e['include'],function(_0x25c061){return{'model':db[_0x25c061[_0xbb5f('0x1f')]],'as':_0x25c061['as'],'attributes':_0x25c061[_0xbb5f('0x20')],'include':_0x25c061[_0xbb5f('0x1e')]?_[_0xbb5f('0x1d')](_0x25c061[_0xbb5f('0x1e')],function(_0x7769fe){return{'model':db[_0x7769fe[_0xbb5f('0x1f')]],'as':_0x7769fe['as'],'attributes':_0x7769fe[_0xbb5f('0x20')]};}):[]};}):[]};}):[]:[]})[_0xbb5f('0x21')](function(_0x2eb51a){logger[_0xbb5f('0xf')](_0xbb5f('0x22'),_0x30641a);logger['debug'](_0xbb5f('0x22'),_0x30641a,JSON[_0xbb5f('0x13')](_0x2eb51a));_0x24e8c2(_0x2eb51a);})[_0xbb5f('0x25')](function(_0x39a895){logger['error'](_0xbb5f('0x22'),_0x39a895['message'],_0x30641a);_0x22d528(_0xa2adf2[_0xbb5f('0x14')](0x1f4,_0x39a895[_0xbb5f('0x17')]));});});};