Built motion from commit da617fac.|2.6.6
[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 _0xb114=['moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','GetZohoAccount','ZohoAccount','findAll','options','raw','attributes','limit','include','map','model','catch','ShowZohoAccount','find','where','stringify','lodash'];(function(_0x24e175,_0x45e8c7){var _0x55b0d1=function(_0x441591){while(--_0x441591){_0x24e175['push'](_0x24e175['shift']());}};_0x55b0d1(++_0x45e8c7);}(_0xb114,0x11f));var _0x4b11=function(_0x125ff8,_0x41925f){_0x125ff8=_0x125ff8-0x0;var _0x2d9ef=_0xb114[_0x125ff8];return _0x2d9ef;};'use strict';var _=require(_0x4b11('0x0'));var util=require('util');var moment=require(_0x4b11('0x1'));var BPromise=require(_0x4b11('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4b11('0x3'));var db=require(_0x4b11('0x4'))['db'];var utils=require(_0x4b11('0x5'));var logger=require(_0x4b11('0x6'))(_0x4b11('0x7'));var config=require(_0x4b11('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x4b11('0x9')][_0x4b11('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x41fac6,_0x91f371,_0x132ad2){return new BPromise(function(_0x283039,_0x25ff0a){return client['request'](_0x41fac6,_0x132ad2)[_0x4b11('0xb')](function(_0x4cde8d){logger[_0x4b11('0xc')](_0x4b11('0xd'),_0x91f371,_0x4b11('0xe'));logger[_0x4b11('0xf')](_0x4b11('0x10'),_0x91f371,_0x4b11('0xe'),JSON['stringify'](_0x4cde8d));if(_0x4cde8d[_0x4b11('0x11')]){if(_0x4cde8d[_0x4b11('0x11')][_0x4b11('0x12')]===0x1f4){logger[_0x4b11('0x11')]('ZohoAccount,\x20%s,\x20%s',_0x91f371,_0x4cde8d['error'][_0x4b11('0x13')]);return _0x25ff0a(_0x4cde8d[_0x4b11('0x11')][_0x4b11('0x13')]);}logger[_0x4b11('0x11')](_0x4b11('0xd'),_0x91f371,_0x4cde8d[_0x4b11('0x11')][_0x4b11('0x13')]);return _0x283039(_0x4cde8d[_0x4b11('0x11')]['message']);}else{logger['info'](_0x4b11('0xd'),_0x91f371,_0x4b11('0xe'));_0x283039(_0x4cde8d[_0x4b11('0x14')]['message']);}})['catch'](function(_0x4dd039){logger[_0x4b11('0x11')](_0x4b11('0xd'),_0x91f371,_0x4dd039);_0x25ff0a(_0x4dd039);});});}exports[_0x4b11('0x15')]=function(_0xf14a7f){var _0xa67776=this;return new Promise(function(_0x2db145,_0x40579b){return db[_0x4b11('0x16')][_0x4b11('0x17')]({'raw':_0xf14a7f[_0x4b11('0x18')]?_0xf14a7f['options'][_0x4b11('0x19')]===undefined?!![]:![]:!![],'where':_0xf14a7f[_0x4b11('0x18')]?_0xf14a7f[_0x4b11('0x18')]['where']||null:null,'attributes':_0xf14a7f[_0x4b11('0x18')]?_0xf14a7f['options'][_0x4b11('0x1a')]||null:null,'limit':_0xf14a7f[_0x4b11('0x18')]?_0xf14a7f[_0x4b11('0x18')][_0x4b11('0x1b')]||null:null,'include':_0xf14a7f[_0x4b11('0x18')]?_0xf14a7f[_0x4b11('0x18')][_0x4b11('0x1c')]?_[_0x4b11('0x1d')](_0xf14a7f[_0x4b11('0x18')][_0x4b11('0x1c')],function(_0x3e9a73){return{'model':db[_0x3e9a73['model']],'as':_0x3e9a73['as'],'attributes':_0x3e9a73[_0x4b11('0x1a')],'include':_0x3e9a73['include']?_[_0x4b11('0x1d')](_0x3e9a73['include'],function(_0x479e85){return{'model':db[_0x479e85[_0x4b11('0x1e')]],'as':_0x479e85['as'],'attributes':_0x479e85[_0x4b11('0x1a')],'include':_0x479e85[_0x4b11('0x1c')]?_[_0x4b11('0x1d')](_0x479e85[_0x4b11('0x1c')],function(_0x5b904a){return{'model':db[_0x5b904a[_0x4b11('0x1e')]],'as':_0x5b904a['as'],'attributes':_0x5b904a[_0x4b11('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x4b11('0xb')](function(_0x3e099f){logger[_0x4b11('0xc')](_0x4b11('0x15'),_0xf14a7f);logger[_0x4b11('0xf')](_0x4b11('0x15'),_0xf14a7f,JSON['stringify'](_0x3e099f));_0x2db145(_0x3e099f);})[_0x4b11('0x1f')](function(_0x15d27d){logger['error'](_0x4b11('0x15'),_0x15d27d[_0x4b11('0x13')],_0xf14a7f);_0x40579b(_0xa67776[_0x4b11('0x11')](0x1f4,_0x15d27d[_0x4b11('0x13')]));});});};exports[_0x4b11('0x20')]=function(_0x704ada){var _0x440cf5=this;return new Promise(function(_0x582d54,_0x409b01){return db[_0x4b11('0x16')][_0x4b11('0x21')]({'raw':_0x704ada['options']?_0x704ada[_0x4b11('0x18')][_0x4b11('0x19')]===undefined?!![]:![]:!![],'where':_0x704ada[_0x4b11('0x18')]?_0x704ada[_0x4b11('0x18')][_0x4b11('0x22')]||null:null,'attributes':_0x704ada[_0x4b11('0x18')]?_0x704ada['options']['attributes']||null:null,'include':_0x704ada[_0x4b11('0x18')]?_0x704ada[_0x4b11('0x18')][_0x4b11('0x1c')]?_[_0x4b11('0x1d')](_0x704ada[_0x4b11('0x18')][_0x4b11('0x1c')],function(_0x232e78){return{'model':db[_0x232e78['model']],'as':_0x232e78['as'],'attributes':_0x232e78[_0x4b11('0x1a')],'include':_0x232e78[_0x4b11('0x1c')]?_[_0x4b11('0x1d')](_0x232e78[_0x4b11('0x1c')],function(_0x18d31c){return{'model':db[_0x18d31c['model']],'as':_0x18d31c['as'],'attributes':_0x18d31c['attributes'],'include':_0x18d31c[_0x4b11('0x1c')]?_[_0x4b11('0x1d')](_0x18d31c[_0x4b11('0x1c')],function(_0x419d87){return{'model':db[_0x419d87['model']],'as':_0x419d87['as'],'attributes':_0x419d87['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x34846a){logger[_0x4b11('0xc')]('ShowZohoAccount',_0x704ada);logger[_0x4b11('0xf')]('ShowZohoAccount',_0x704ada,JSON[_0x4b11('0x23')](_0x34846a));_0x582d54(_0x34846a);})[_0x4b11('0x1f')](function(_0xade5cc){logger[_0x4b11('0x11')](_0x4b11('0x20'),_0xade5cc[_0x4b11('0x13')],_0x704ada);_0x409b01(_0x440cf5[_0x4b11('0x11')](0x1f4,_0xade5cc[_0x4b11('0x13')]));});});};