Built motion from commit 21186556.|2.6.19
[motion2.git] / server / api / intFreshsalesAccount / intFreshsalesAccount.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 _0x0295=['find','lodash','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','request\x20sent','debug','FreshsalesAccount,\x20%s,\x20%s,\x20%s','stringify','error','FreshsalesAccount,\x20%s,\x20%s','message','result','catch','FreshsalesAccount','findAll','options','raw','where','include','map','model','attributes','GetFreshsalesAccount','ShowFreshsalesAccount'];(function(_0x3c8985,_0x238ab7){var _0x472f36=function(_0xebdb38){while(--_0xebdb38){_0x3c8985['push'](_0x3c8985['shift']());}};_0x472f36(++_0x238ab7);}(_0x0295,0x1f0));var _0x5029=function(_0x272700,_0x525483){_0x272700=_0x272700-0x0;var _0x3927a4=_0x0295[_0x272700];return _0x3927a4;};'use strict';var _=require(_0x5029('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x5029('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5029('0x2'))['db'];var utils=require(_0x5029('0x3'));var logger=require(_0x5029('0x4'))(_0x5029('0x5'));var config=require(_0x5029('0x6'));var jayson=require(_0x5029('0x7'));var client=jayson[_0x5029('0x8')][_0x5029('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5b3cd,_0x502a62,_0x54978f){return new BPromise(function(_0x4ee867,_0xf4459b){return client['request'](_0x5b3cd,_0x54978f)[_0x5029('0xa')](function(_0x5bccfc){logger[_0x5029('0xb')]('FreshsalesAccount,\x20%s,\x20%s',_0x502a62,_0x5029('0xc'));logger[_0x5029('0xd')](_0x5029('0xe'),_0x502a62,'request\x20sent',JSON[_0x5029('0xf')](_0x5bccfc));if(_0x5bccfc[_0x5029('0x10')]){if(_0x5bccfc[_0x5029('0x10')]['code']===0x1f4){logger[_0x5029('0x10')](_0x5029('0x11'),_0x502a62,_0x5bccfc['error']['message']);return _0xf4459b(_0x5bccfc['error']['message']);}logger[_0x5029('0x10')](_0x5029('0x11'),_0x502a62,_0x5bccfc[_0x5029('0x10')][_0x5029('0x12')]);return _0x4ee867(_0x5bccfc[_0x5029('0x10')][_0x5029('0x12')]);}else{logger[_0x5029('0xb')](_0x5029('0x11'),_0x502a62,_0x5029('0xc'));_0x4ee867(_0x5bccfc[_0x5029('0x13')][_0x5029('0x12')]);}})[_0x5029('0x14')](function(_0x3786b5){logger[_0x5029('0x10')](_0x5029('0x11'),_0x502a62,_0x3786b5);_0xf4459b(_0x3786b5);});});}exports['GetFreshsalesAccount']=function(_0x1ed567){var _0x31a155=this;return new Promise(function(_0x35de81,_0x4902f3){return db[_0x5029('0x15')][_0x5029('0x16')]({'raw':_0x1ed567[_0x5029('0x17')]?_0x1ed567['options'][_0x5029('0x18')]===undefined?!![]:![]:!![],'where':_0x1ed567['options']?_0x1ed567[_0x5029('0x17')][_0x5029('0x19')]||null:null,'attributes':_0x1ed567[_0x5029('0x17')]?_0x1ed567[_0x5029('0x17')]['attributes']||null:null,'limit':_0x1ed567['options']?_0x1ed567[_0x5029('0x17')]['limit']||null:null,'include':_0x1ed567[_0x5029('0x17')]?_0x1ed567[_0x5029('0x17')][_0x5029('0x1a')]?_[_0x5029('0x1b')](_0x1ed567[_0x5029('0x17')][_0x5029('0x1a')],function(_0x125c26){return{'model':db[_0x125c26[_0x5029('0x1c')]],'as':_0x125c26['as'],'attributes':_0x125c26[_0x5029('0x1d')],'include':_0x125c26['include']?_['map'](_0x125c26['include'],function(_0x588d90){return{'model':db[_0x588d90[_0x5029('0x1c')]],'as':_0x588d90['as'],'attributes':_0x588d90['attributes'],'include':_0x588d90['include']?_[_0x5029('0x1b')](_0x588d90[_0x5029('0x1a')],function(_0x36d810){return{'model':db[_0x36d810['model']],'as':_0x36d810['as'],'attributes':_0x36d810[_0x5029('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x5029('0xa')](function(_0x5e45c4){logger[_0x5029('0xb')](_0x5029('0x1e'),_0x1ed567);logger[_0x5029('0xd')]('GetFreshsalesAccount',_0x1ed567,JSON[_0x5029('0xf')](_0x5e45c4));_0x35de81(_0x5e45c4);})[_0x5029('0x14')](function(_0xe5313e){logger['error'](_0x5029('0x1e'),_0xe5313e[_0x5029('0x12')],_0x1ed567);_0x4902f3(_0x31a155['error'](0x1f4,_0xe5313e[_0x5029('0x12')]));});});};exports[_0x5029('0x1f')]=function(_0x4434ff){var _0x1c3dd9=this;return new Promise(function(_0x196830,_0x2a1ed6){return db[_0x5029('0x15')][_0x5029('0x20')]({'raw':_0x4434ff[_0x5029('0x17')]?_0x4434ff[_0x5029('0x17')][_0x5029('0x18')]===undefined?!![]:![]:!![],'where':_0x4434ff[_0x5029('0x17')]?_0x4434ff['options'][_0x5029('0x19')]||null:null,'attributes':_0x4434ff['options']?_0x4434ff[_0x5029('0x17')]['attributes']||null:null,'include':_0x4434ff['options']?_0x4434ff[_0x5029('0x17')][_0x5029('0x1a')]?_[_0x5029('0x1b')](_0x4434ff['options'][_0x5029('0x1a')],function(_0x15d882){return{'model':db[_0x15d882[_0x5029('0x1c')]],'as':_0x15d882['as'],'attributes':_0x15d882[_0x5029('0x1d')],'include':_0x15d882[_0x5029('0x1a')]?_[_0x5029('0x1b')](_0x15d882[_0x5029('0x1a')],function(_0x22205e){return{'model':db[_0x22205e[_0x5029('0x1c')]],'as':_0x22205e['as'],'attributes':_0x22205e['attributes'],'include':_0x22205e[_0x5029('0x1a')]?_[_0x5029('0x1b')](_0x22205e[_0x5029('0x1a')],function(_0x1b3817){return{'model':db[_0x1b3817['model']],'as':_0x1b3817['as'],'attributes':_0x1b3817[_0x5029('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x5029('0xa')](function(_0x3e2d88){logger['info']('ShowFreshsalesAccount',_0x4434ff);logger[_0x5029('0xd')](_0x5029('0x1f'),_0x4434ff,JSON['stringify'](_0x3e2d88));_0x196830(_0x3e2d88);})['catch'](function(_0x9656f2){logger[_0x5029('0x10')](_0x5029('0x1f'),_0x9656f2[_0x5029('0x12')],_0x4434ff);_0x2a1ed6(_0x1c3dd9[_0x5029('0x10')](0x1f4,_0x9656f2[_0x5029('0x12')]));});});};