e63f6496d0a8b5a899d209614e371cc1827da7d4
[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 _0x6372=['randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','ZohoAccount,\x20%s,\x20%s','message','result','catch','ZohoAccount','findAll','options','raw','attributes','include','map','model','GetZohoAccount','ShowZohoAccount','find','where','lodash','moment'];(function(_0x5da21c,_0x340f8b){var _0x3b72fa=function(_0x3aae43){while(--_0x3aae43){_0x5da21c['push'](_0x5da21c['shift']());}};_0x3b72fa(++_0x340f8b);}(_0x6372,0x1b8));var _0x2637=function(_0x2cc3c1,_0xa43650){_0x2cc3c1=_0x2cc3c1-0x0;var _0x4c4f66=_0x6372[_0x2cc3c1];return _0x4c4f66;};'use strict';var _=require(_0x2637('0x0'));var util=require('util');var moment=require(_0x2637('0x1'));var BPromise=require('bluebird');var rs=require(_0x2637('0x2'));var fs=require('fs');var Redis=require(_0x2637('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x2637('0x4'));var logger=require(_0x2637('0x5'))(_0x2637('0x6'));var config=require(_0x2637('0x7'));var jayson=require(_0x2637('0x8'));var client=jayson['client'][_0x2637('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x54bdd1,_0x4f8521,_0x49383d){return new BPromise(function(_0x30abde,_0x5a4748){return client['request'](_0x54bdd1,_0x49383d)[_0x2637('0xa')](function(_0x2dbcb5){logger[_0x2637('0xb')]('ZohoAccount,\x20%s,\x20%s',_0x4f8521,'request\x20sent');logger[_0x2637('0xc')](_0x2637('0xd'),_0x4f8521,_0x2637('0xe'),JSON[_0x2637('0xf')](_0x2dbcb5));if(_0x2dbcb5[_0x2637('0x10')]){if(_0x2dbcb5[_0x2637('0x10')][_0x2637('0x11')]===0x1f4){logger[_0x2637('0x10')](_0x2637('0x12'),_0x4f8521,_0x2dbcb5['error'][_0x2637('0x13')]);return _0x5a4748(_0x2dbcb5[_0x2637('0x10')][_0x2637('0x13')]);}logger['error'](_0x2637('0x12'),_0x4f8521,_0x2dbcb5[_0x2637('0x10')][_0x2637('0x13')]);return _0x30abde(_0x2dbcb5[_0x2637('0x10')]['message']);}else{logger[_0x2637('0xb')](_0x2637('0x12'),_0x4f8521,_0x2637('0xe'));_0x30abde(_0x2dbcb5[_0x2637('0x14')][_0x2637('0x13')]);}})[_0x2637('0x15')](function(_0x567d3c){logger['error'](_0x2637('0x12'),_0x4f8521,_0x567d3c);_0x5a4748(_0x567d3c);});});}exports['GetZohoAccount']=function(_0x4f44d7){var _0x3dcb2e=this;return new Promise(function(_0x1e9598,_0x4d3266){return db[_0x2637('0x16')][_0x2637('0x17')]({'raw':_0x4f44d7[_0x2637('0x18')]?_0x4f44d7['options'][_0x2637('0x19')]===undefined?!![]:![]:!![],'where':_0x4f44d7[_0x2637('0x18')]?_0x4f44d7[_0x2637('0x18')]['where']||null:null,'attributes':_0x4f44d7[_0x2637('0x18')]?_0x4f44d7[_0x2637('0x18')][_0x2637('0x1a')]||null:null,'limit':_0x4f44d7['options']?_0x4f44d7[_0x2637('0x18')]['limit']||null:null,'include':_0x4f44d7[_0x2637('0x18')]?_0x4f44d7[_0x2637('0x18')][_0x2637('0x1b')]?_['map'](_0x4f44d7['options'][_0x2637('0x1b')],function(_0x5e6d31){return{'model':db[_0x5e6d31['model']],'as':_0x5e6d31['as'],'attributes':_0x5e6d31['attributes'],'include':_0x5e6d31[_0x2637('0x1b')]?_[_0x2637('0x1c')](_0x5e6d31[_0x2637('0x1b')],function(_0x3d3bd9){return{'model':db[_0x3d3bd9[_0x2637('0x1d')]],'as':_0x3d3bd9['as'],'attributes':_0x3d3bd9[_0x2637('0x1a')],'include':_0x3d3bd9[_0x2637('0x1b')]?_[_0x2637('0x1c')](_0x3d3bd9['include'],function(_0x13a4a8){return{'model':db[_0x13a4a8[_0x2637('0x1d')]],'as':_0x13a4a8['as'],'attributes':_0x13a4a8['attributes']};}):[]};}):[]};}):[]:[]})[_0x2637('0xa')](function(_0x2d3f28){logger[_0x2637('0xb')](_0x2637('0x1e'),_0x4f44d7);logger['debug'](_0x2637('0x1e'),_0x4f44d7,JSON[_0x2637('0xf')](_0x2d3f28));_0x1e9598(_0x2d3f28);})[_0x2637('0x15')](function(_0x27f326){logger[_0x2637('0x10')]('GetZohoAccount',_0x27f326['message'],_0x4f44d7);_0x4d3266(_0x3dcb2e[_0x2637('0x10')](0x1f4,_0x27f326['message']));});});};exports[_0x2637('0x1f')]=function(_0xaa5292){var _0x2d1628=this;return new Promise(function(_0x39fd9e,_0x40e343){return db[_0x2637('0x16')][_0x2637('0x20')]({'raw':_0xaa5292[_0x2637('0x18')]?_0xaa5292[_0x2637('0x18')][_0x2637('0x19')]===undefined?!![]:![]:!![],'where':_0xaa5292[_0x2637('0x18')]?_0xaa5292[_0x2637('0x18')][_0x2637('0x21')]||null:null,'attributes':_0xaa5292[_0x2637('0x18')]?_0xaa5292[_0x2637('0x18')][_0x2637('0x1a')]||null:null,'include':_0xaa5292[_0x2637('0x18')]?_0xaa5292['options'][_0x2637('0x1b')]?_[_0x2637('0x1c')](_0xaa5292['options']['include'],function(_0x3b4a0f){return{'model':db[_0x3b4a0f[_0x2637('0x1d')]],'as':_0x3b4a0f['as'],'attributes':_0x3b4a0f[_0x2637('0x1a')],'include':_0x3b4a0f[_0x2637('0x1b')]?_[_0x2637('0x1c')](_0x3b4a0f[_0x2637('0x1b')],function(_0x3107e5){return{'model':db[_0x3107e5[_0x2637('0x1d')]],'as':_0x3107e5['as'],'attributes':_0x3107e5[_0x2637('0x1a')],'include':_0x3107e5[_0x2637('0x1b')]?_[_0x2637('0x1c')](_0x3107e5[_0x2637('0x1b')],function(_0x4bdb3c){return{'model':db[_0x4bdb3c[_0x2637('0x1d')]],'as':_0x4bdb3c['as'],'attributes':_0x4bdb3c['attributes']};}):[]};}):[]};}):[]:[]})[_0x2637('0xa')](function(_0x44b93b){logger[_0x2637('0xb')](_0x2637('0x1f'),_0xaa5292);logger[_0x2637('0xc')](_0x2637('0x1f'),_0xaa5292,JSON[_0x2637('0xf')](_0x44b93b));_0x39fd9e(_0x44b93b);})[_0x2637('0x15')](function(_0x31df33){logger[_0x2637('0x10')](_0x2637('0x1f'),_0x31df33[_0x2637('0x13')],_0xaa5292);_0x40e343(_0x2d1628[_0x2637('0x10')](0x1f4,_0x31df33[_0x2637('0x13')]));});});};