Built motion from commit e6806ed6.|2.6.0
[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 _0x9d56=['../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetZohoAccount','findAll','options','raw','where','limit','include','map','attributes','model','catch','ShowZohoAccount','find','lodash','util','moment','bluebird','ioredis','../../mysqldb'];(function(_0x5cce05,_0x5be00d){var _0x3ed991=function(_0x23e151){while(--_0x23e151){_0x5cce05['push'](_0x5cce05['shift']());}};_0x3ed991(++_0x5be00d);}(_0x9d56,0x122));var _0x69d5=function(_0x2a071b,_0x28a482){_0x2a071b=_0x2a071b-0x0;var _0x4398a8=_0x9d56[_0x2a071b];return _0x4398a8;};'use strict';var _=require(_0x69d5('0x0'));var util=require(_0x69d5('0x1'));var moment=require(_0x69d5('0x2'));var BPromise=require(_0x69d5('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x69d5('0x4'));var db=require(_0x69d5('0x5'))['db'];var utils=require(_0x69d5('0x6'));var logger=require(_0x69d5('0x7'))(_0x69d5('0x8'));var config=require('../../config/environment');var jayson=require(_0x69d5('0x9'));var client=jayson[_0x69d5('0xa')][_0x69d5('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1ca8b8,_0x9051a,_0x3dfaac){return new BPromise(function(_0x825bb5,_0xa9dc3c){return client[_0x69d5('0xc')](_0x1ca8b8,_0x3dfaac)[_0x69d5('0xd')](function(_0x38e5fc){logger[_0x69d5('0xe')](_0x69d5('0xf'),_0x9051a,_0x69d5('0x10'));logger[_0x69d5('0x11')](_0x69d5('0x12'),_0x9051a,_0x69d5('0x10'),JSON[_0x69d5('0x13')](_0x38e5fc));if(_0x38e5fc[_0x69d5('0x14')]){if(_0x38e5fc['error'][_0x69d5('0x15')]===0x1f4){logger[_0x69d5('0x14')](_0x69d5('0xf'),_0x9051a,_0x38e5fc[_0x69d5('0x14')][_0x69d5('0x16')]);return _0xa9dc3c(_0x38e5fc['error'][_0x69d5('0x16')]);}logger[_0x69d5('0x14')](_0x69d5('0xf'),_0x9051a,_0x38e5fc[_0x69d5('0x14')]['message']);return _0x825bb5(_0x38e5fc['error']['message']);}else{logger[_0x69d5('0xe')](_0x69d5('0xf'),_0x9051a,_0x69d5('0x10'));_0x825bb5(_0x38e5fc[_0x69d5('0x17')][_0x69d5('0x16')]);}})['catch'](function(_0x212aeb){logger[_0x69d5('0x14')](_0x69d5('0xf'),_0x9051a,_0x212aeb);_0xa9dc3c(_0x212aeb);});});}exports[_0x69d5('0x18')]=function(_0x16e628){var _0x2f6616=this;return new Promise(function(_0x6763ac,_0x141cb7){return db['ZohoAccount'][_0x69d5('0x19')]({'raw':_0x16e628[_0x69d5('0x1a')]?_0x16e628[_0x69d5('0x1a')][_0x69d5('0x1b')]===undefined?!![]:![]:!![],'where':_0x16e628[_0x69d5('0x1a')]?_0x16e628[_0x69d5('0x1a')][_0x69d5('0x1c')]||null:null,'attributes':_0x16e628[_0x69d5('0x1a')]?_0x16e628[_0x69d5('0x1a')]['attributes']||null:null,'limit':_0x16e628['options']?_0x16e628[_0x69d5('0x1a')][_0x69d5('0x1d')]||null:null,'include':_0x16e628[_0x69d5('0x1a')]?_0x16e628[_0x69d5('0x1a')][_0x69d5('0x1e')]?_[_0x69d5('0x1f')](_0x16e628[_0x69d5('0x1a')][_0x69d5('0x1e')],function(_0x23ee57){return{'model':db[_0x23ee57['model']],'as':_0x23ee57['as'],'attributes':_0x23ee57[_0x69d5('0x20')],'include':_0x23ee57[_0x69d5('0x1e')]?_[_0x69d5('0x1f')](_0x23ee57['include'],function(_0x2e1d8d){return{'model':db[_0x2e1d8d['model']],'as':_0x2e1d8d['as'],'attributes':_0x2e1d8d['attributes'],'include':_0x2e1d8d[_0x69d5('0x1e')]?_['map'](_0x2e1d8d[_0x69d5('0x1e')],function(_0x7636f2){return{'model':db[_0x7636f2[_0x69d5('0x21')]],'as':_0x7636f2['as'],'attributes':_0x7636f2['attributes']};}):[]};}):[]};}):[]:[]})[_0x69d5('0xd')](function(_0x3b3c1a){logger[_0x69d5('0xe')]('GetZohoAccount',_0x16e628);logger['debug'](_0x69d5('0x18'),_0x16e628,JSON[_0x69d5('0x13')](_0x3b3c1a));_0x6763ac(_0x3b3c1a);})[_0x69d5('0x22')](function(_0x4d8fb){logger[_0x69d5('0x14')]('GetZohoAccount',_0x4d8fb[_0x69d5('0x16')],_0x16e628);_0x141cb7(_0x2f6616[_0x69d5('0x14')](0x1f4,_0x4d8fb[_0x69d5('0x16')]));});});};exports[_0x69d5('0x23')]=function(_0x222192){var _0xd12dbc=this;return new Promise(function(_0x3371d7,_0x435217){return db['ZohoAccount'][_0x69d5('0x24')]({'raw':_0x222192[_0x69d5('0x1a')]?_0x222192['options'][_0x69d5('0x1b')]===undefined?!![]:![]:!![],'where':_0x222192['options']?_0x222192[_0x69d5('0x1a')][_0x69d5('0x1c')]||null:null,'attributes':_0x222192[_0x69d5('0x1a')]?_0x222192['options'][_0x69d5('0x20')]||null:null,'include':_0x222192[_0x69d5('0x1a')]?_0x222192['options'][_0x69d5('0x1e')]?_[_0x69d5('0x1f')](_0x222192[_0x69d5('0x1a')]['include'],function(_0x30e073){return{'model':db[_0x30e073[_0x69d5('0x21')]],'as':_0x30e073['as'],'attributes':_0x30e073[_0x69d5('0x20')],'include':_0x30e073[_0x69d5('0x1e')]?_[_0x69d5('0x1f')](_0x30e073[_0x69d5('0x1e')],function(_0x1e6692){return{'model':db[_0x1e6692[_0x69d5('0x21')]],'as':_0x1e6692['as'],'attributes':_0x1e6692[_0x69d5('0x20')],'include':_0x1e6692[_0x69d5('0x1e')]?_[_0x69d5('0x1f')](_0x1e6692[_0x69d5('0x1e')],function(_0x2c5caa){return{'model':db[_0x2c5caa[_0x69d5('0x21')]],'as':_0x2c5caa['as'],'attributes':_0x2c5caa[_0x69d5('0x20')]};}):[]};}):[]};}):[]:[]})[_0x69d5('0xd')](function(_0x4675fb){logger['info'](_0x69d5('0x23'),_0x222192);logger[_0x69d5('0x11')](_0x69d5('0x23'),_0x222192,JSON['stringify'](_0x4675fb));_0x3371d7(_0x4675fb);})[_0x69d5('0x22')](function(_0x2cb460){logger[_0x69d5('0x14')]('ShowZohoAccount',_0x2cb460[_0x69d5('0x16')],_0x222192);_0x435217(_0xd12dbc['error'](0x1f4,_0x2cb460[_0x69d5('0x16')]));});});};