Built motion from commit ac06311e.|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 _0x6000=['debug','stringify','error','code','message','result','catch','GetZohoAccount','ZohoAccount','findAll','options','where','attributes','limit','include','map','model','ShowZohoAccount','find','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','client','http','request','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent'];(function(_0x4732e4,_0x5b0ab6){var _0x2ac1c3=function(_0x250288){while(--_0x250288){_0x4732e4['push'](_0x4732e4['shift']());}};_0x2ac1c3(++_0x5b0ab6);}(_0x6000,0x17c));var _0x0600=function(_0x3e4c31,_0x2f74db){_0x3e4c31=_0x3e4c31-0x0;var _0x455cf3=_0x6000[_0x3e4c31];return _0x455cf3;};'use strict';var _=require(_0x0600('0x0'));var util=require(_0x0600('0x1'));var moment=require(_0x0600('0x2'));var BPromise=require(_0x0600('0x3'));var rs=require(_0x0600('0x4'));var fs=require('fs');var Redis=require(_0x0600('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x0600('0x6'));var logger=require(_0x0600('0x7'))('rpc');var config=require(_0x0600('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x0600('0x9')][_0x0600('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x89927a,_0x559495,_0x45e348){return new BPromise(function(_0x5730b2,_0x15b6d2){return client[_0x0600('0xb')](_0x89927a,_0x45e348)[_0x0600('0xc')](function(_0xacb924){logger[_0x0600('0xd')](_0x0600('0xe'),_0x559495,_0x0600('0xf'));logger[_0x0600('0x10')]('ZohoAccount,\x20%s,\x20%s,\x20%s',_0x559495,_0x0600('0xf'),JSON[_0x0600('0x11')](_0xacb924));if(_0xacb924['error']){if(_0xacb924[_0x0600('0x12')][_0x0600('0x13')]===0x1f4){logger[_0x0600('0x12')]('ZohoAccount,\x20%s,\x20%s',_0x559495,_0xacb924[_0x0600('0x12')]['message']);return _0x15b6d2(_0xacb924[_0x0600('0x12')][_0x0600('0x14')]);}logger[_0x0600('0x12')](_0x0600('0xe'),_0x559495,_0xacb924[_0x0600('0x12')]['message']);return _0x5730b2(_0xacb924[_0x0600('0x12')][_0x0600('0x14')]);}else{logger['info'](_0x0600('0xe'),_0x559495,_0x0600('0xf'));_0x5730b2(_0xacb924[_0x0600('0x15')][_0x0600('0x14')]);}})[_0x0600('0x16')](function(_0x31ced0){logger[_0x0600('0x12')]('ZohoAccount,\x20%s,\x20%s',_0x559495,_0x31ced0);_0x15b6d2(_0x31ced0);});});}exports[_0x0600('0x17')]=function(_0x205998){var _0x25ade1=this;return new Promise(function(_0x571a0a,_0x251021){return db[_0x0600('0x18')][_0x0600('0x19')]({'raw':_0x205998[_0x0600('0x1a')]?_0x205998[_0x0600('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x205998[_0x0600('0x1a')]?_0x205998[_0x0600('0x1a')][_0x0600('0x1b')]||null:null,'attributes':_0x205998[_0x0600('0x1a')]?_0x205998['options'][_0x0600('0x1c')]||null:null,'limit':_0x205998[_0x0600('0x1a')]?_0x205998['options'][_0x0600('0x1d')]||null:null,'include':_0x205998['options']?_0x205998[_0x0600('0x1a')][_0x0600('0x1e')]?_[_0x0600('0x1f')](_0x205998['options'][_0x0600('0x1e')],function(_0x246f8c){return{'model':db[_0x246f8c['model']],'as':_0x246f8c['as'],'attributes':_0x246f8c[_0x0600('0x1c')],'include':_0x246f8c[_0x0600('0x1e')]?_['map'](_0x246f8c[_0x0600('0x1e')],function(_0x4c09fb){return{'model':db[_0x4c09fb[_0x0600('0x20')]],'as':_0x4c09fb['as'],'attributes':_0x4c09fb[_0x0600('0x1c')],'include':_0x4c09fb[_0x0600('0x1e')]?_[_0x0600('0x1f')](_0x4c09fb[_0x0600('0x1e')],function(_0x536b65){return{'model':db[_0x536b65[_0x0600('0x20')]],'as':_0x536b65['as'],'attributes':_0x536b65[_0x0600('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x0600('0xc')](function(_0x5b9264){logger['info'](_0x0600('0x17'),_0x205998);logger['debug']('GetZohoAccount',_0x205998,JSON[_0x0600('0x11')](_0x5b9264));_0x571a0a(_0x5b9264);})[_0x0600('0x16')](function(_0x3b543b){logger['error'](_0x0600('0x17'),_0x3b543b[_0x0600('0x14')],_0x205998);_0x251021(_0x25ade1[_0x0600('0x12')](0x1f4,_0x3b543b[_0x0600('0x14')]));});});};exports[_0x0600('0x21')]=function(_0x657d6e){var _0x1f8ccb=this;return new Promise(function(_0x454bd4,_0x57241e){return db[_0x0600('0x18')][_0x0600('0x22')]({'raw':_0x657d6e[_0x0600('0x1a')]?_0x657d6e['options'][_0x0600('0x23')]===undefined?!![]:![]:!![],'where':_0x657d6e[_0x0600('0x1a')]?_0x657d6e['options'][_0x0600('0x1b')]||null:null,'attributes':_0x657d6e[_0x0600('0x1a')]?_0x657d6e[_0x0600('0x1a')][_0x0600('0x1c')]||null:null,'include':_0x657d6e[_0x0600('0x1a')]?_0x657d6e[_0x0600('0x1a')][_0x0600('0x1e')]?_['map'](_0x657d6e['options']['include'],function(_0x6f5533){return{'model':db[_0x6f5533[_0x0600('0x20')]],'as':_0x6f5533['as'],'attributes':_0x6f5533[_0x0600('0x1c')],'include':_0x6f5533[_0x0600('0x1e')]?_[_0x0600('0x1f')](_0x6f5533[_0x0600('0x1e')],function(_0x526d59){return{'model':db[_0x526d59[_0x0600('0x20')]],'as':_0x526d59['as'],'attributes':_0x526d59['attributes'],'include':_0x526d59[_0x0600('0x1e')]?_['map'](_0x526d59['include'],function(_0x43e05d){return{'model':db[_0x43e05d[_0x0600('0x20')]],'as':_0x43e05d['as'],'attributes':_0x43e05d[_0x0600('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x0600('0xc')](function(_0x589e99){logger[_0x0600('0xd')](_0x0600('0x21'),_0x657d6e);logger[_0x0600('0x10')](_0x0600('0x21'),_0x657d6e,JSON[_0x0600('0x11')](_0x589e99));_0x454bd4(_0x589e99);})[_0x0600('0x16')](function(_0x3b3e5e){logger['error'](_0x0600('0x21'),_0x3b3e5e['message'],_0x657d6e);_0x57241e(_0x1f8ccb[_0x0600('0x12')](0x1f4,_0x3b3e5e[_0x0600('0x14')]));});});};