Built motion from commit (unavailable).|2.5.29
[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 _0x722b=['GetZohoAccount','findAll','options','raw','where','include','map','model','attributes','then','debug','ShowZohoAccount','ZohoAccount','find','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','http','request','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x722b,0x1dc));var _0xb722=function(_0xcde180,_0x2c7cb4){_0xcde180=_0xcde180-0x0;var _0x2adf0c=_0x722b[_0xcde180];return _0x2adf0c;};'use strict';var _=require('lodash');var util=require(_0xb722('0x0'));var moment=require(_0xb722('0x1'));var BPromise=require(_0xb722('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb722('0x3'));var db=require(_0xb722('0x4'))['db'];var utils=require(_0xb722('0x5'));var logger=require('../../config/logger')(_0xb722('0x6'));var config=require('../../config/environment');var jayson=require(_0xb722('0x7'));var client=jayson['client'][_0xb722('0x8')]({'port':0x232a});function respondWithRpcPromise(_0xaba74f,_0xcb4d2c,_0x3b2ad7){return new BPromise(function(_0x4580c9,_0x2e7682){return client[_0xb722('0x9')](_0xaba74f,_0x3b2ad7)['then'](function(_0x1bdf6d){logger[_0xb722('0xa')](_0xb722('0xb'),_0xcb4d2c,_0xb722('0xc'));logger['debug'](_0xb722('0xd'),_0xcb4d2c,_0xb722('0xc'),JSON[_0xb722('0xe')](_0x1bdf6d));if(_0x1bdf6d[_0xb722('0xf')]){if(_0x1bdf6d[_0xb722('0xf')][_0xb722('0x10')]===0x1f4){logger['error'](_0xb722('0xb'),_0xcb4d2c,_0x1bdf6d[_0xb722('0xf')][_0xb722('0x11')]);return _0x2e7682(_0x1bdf6d[_0xb722('0xf')][_0xb722('0x11')]);}logger[_0xb722('0xf')](_0xb722('0xb'),_0xcb4d2c,_0x1bdf6d['error'][_0xb722('0x11')]);return _0x4580c9(_0x1bdf6d[_0xb722('0xf')][_0xb722('0x11')]);}else{logger[_0xb722('0xa')](_0xb722('0xb'),_0xcb4d2c,'request\x20sent');_0x4580c9(_0x1bdf6d['result'][_0xb722('0x11')]);}})[_0xb722('0x12')](function(_0x30bc2b){logger[_0xb722('0xf')](_0xb722('0xb'),_0xcb4d2c,_0x30bc2b);_0x2e7682(_0x30bc2b);});});}exports[_0xb722('0x13')]=function(_0xe6722f){var _0x59e07a=this;return new Promise(function(_0x5dac13,_0xeea816){return db['ZohoAccount'][_0xb722('0x14')]({'raw':_0xe6722f[_0xb722('0x15')]?_0xe6722f[_0xb722('0x15')][_0xb722('0x16')]===undefined?!![]:![]:!![],'where':_0xe6722f[_0xb722('0x15')]?_0xe6722f[_0xb722('0x15')][_0xb722('0x17')]||null:null,'attributes':_0xe6722f[_0xb722('0x15')]?_0xe6722f[_0xb722('0x15')]['attributes']||null:null,'limit':_0xe6722f['options']?_0xe6722f[_0xb722('0x15')]['limit']||null:null,'include':_0xe6722f[_0xb722('0x15')]?_0xe6722f[_0xb722('0x15')][_0xb722('0x18')]?_[_0xb722('0x19')](_0xe6722f[_0xb722('0x15')][_0xb722('0x18')],function(_0xe7aa3){return{'model':db[_0xe7aa3['model']],'as':_0xe7aa3['as'],'attributes':_0xe7aa3['attributes'],'include':_0xe7aa3[_0xb722('0x18')]?_[_0xb722('0x19')](_0xe7aa3[_0xb722('0x18')],function(_0x54716d){return{'model':db[_0x54716d[_0xb722('0x1a')]],'as':_0x54716d['as'],'attributes':_0x54716d[_0xb722('0x1b')],'include':_0x54716d[_0xb722('0x18')]?_['map'](_0x54716d['include'],function(_0x2d0b93){return{'model':db[_0x2d0b93[_0xb722('0x1a')]],'as':_0x2d0b93['as'],'attributes':_0x2d0b93['attributes']};}):[]};}):[]};}):[]:[]})[_0xb722('0x1c')](function(_0x25f490){logger[_0xb722('0xa')](_0xb722('0x13'),_0xe6722f);logger[_0xb722('0x1d')](_0xb722('0x13'),_0xe6722f,JSON[_0xb722('0xe')](_0x25f490));_0x5dac13(_0x25f490);})[_0xb722('0x12')](function(_0x193cea){logger[_0xb722('0xf')](_0xb722('0x13'),_0x193cea['message'],_0xe6722f);_0xeea816(_0x59e07a[_0xb722('0xf')](0x1f4,_0x193cea[_0xb722('0x11')]));});});};exports[_0xb722('0x1e')]=function(_0x5aa6f7){var _0xe0bde3=this;return new Promise(function(_0x2d80ef,_0x252087){return db[_0xb722('0x1f')][_0xb722('0x20')]({'raw':_0x5aa6f7[_0xb722('0x15')]?_0x5aa6f7[_0xb722('0x15')][_0xb722('0x16')]===undefined?!![]:![]:!![],'where':_0x5aa6f7[_0xb722('0x15')]?_0x5aa6f7['options'][_0xb722('0x17')]||null:null,'attributes':_0x5aa6f7['options']?_0x5aa6f7[_0xb722('0x15')][_0xb722('0x1b')]||null:null,'include':_0x5aa6f7['options']?_0x5aa6f7[_0xb722('0x15')]['include']?_[_0xb722('0x19')](_0x5aa6f7['options'][_0xb722('0x18')],function(_0x24bfe3){return{'model':db[_0x24bfe3['model']],'as':_0x24bfe3['as'],'attributes':_0x24bfe3[_0xb722('0x1b')],'include':_0x24bfe3[_0xb722('0x18')]?_['map'](_0x24bfe3[_0xb722('0x18')],function(_0x19e1a7){return{'model':db[_0x19e1a7[_0xb722('0x1a')]],'as':_0x19e1a7['as'],'attributes':_0x19e1a7[_0xb722('0x1b')],'include':_0x19e1a7['include']?_[_0xb722('0x19')](_0x19e1a7['include'],function(_0x5eeb82){return{'model':db[_0x5eeb82[_0xb722('0x1a')]],'as':_0x5eeb82['as'],'attributes':_0x5eeb82[_0xb722('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x7b4a0a){logger['info'](_0xb722('0x1e'),_0x5aa6f7);logger[_0xb722('0x1d')](_0xb722('0x1e'),_0x5aa6f7,JSON[_0xb722('0xe')](_0x7b4a0a));_0x2d80ef(_0x7b4a0a);})[_0xb722('0x12')](function(_0x4f95cf){logger['error'](_0xb722('0x1e'),_0x4f95cf[_0xb722('0x11')],_0x5aa6f7);_0x252087(_0xe0bde3[_0xb722('0xf')](0x1f4,_0x4f95cf[_0xb722('0x11')]));});});};