5bca5263a03e30c7b6debf486525410a59a981f5
[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 _0x32f4=['lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','then','info','FreshsalesAccount,\x20%s,\x20%s','request\x20sent','FreshsalesAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetFreshsalesAccount','FreshsalesAccount','options','raw','where','attributes','limit','include','model','map','find','ShowFreshsalesAccount'];(function(_0x5230ed,_0x2eb03e){var _0x43bb42=function(_0x407331){while(--_0x407331){_0x5230ed['push'](_0x5230ed['shift']());}};_0x43bb42(++_0x2eb03e);}(_0x32f4,0x154));var _0x432f=function(_0x134de0,_0x415563){_0x134de0=_0x134de0-0x0;var _0x334421=_0x32f4[_0x134de0];return _0x334421;};'use strict';var _=require(_0x432f('0x0'));var util=require(_0x432f('0x1'));var moment=require(_0x432f('0x2'));var BPromise=require(_0x432f('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x432f('0x4'));var db=require(_0x432f('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x432f('0x6'))(_0x432f('0x7'));var config=require(_0x432f('0x8'));var jayson=require(_0x432f('0x9'));var client=jayson[_0x432f('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5b5f08,_0x2f66fd,_0x32b062){return new BPromise(function(_0x4a5b56,_0x2a2ef6){return client['request'](_0x5b5f08,_0x32b062)[_0x432f('0xb')](function(_0x340fe9){logger[_0x432f('0xc')](_0x432f('0xd'),_0x2f66fd,_0x432f('0xe'));logger['debug'](_0x432f('0xf'),_0x2f66fd,'request\x20sent',JSON[_0x432f('0x10')](_0x340fe9));if(_0x340fe9['error']){if(_0x340fe9[_0x432f('0x11')][_0x432f('0x12')]===0x1f4){logger['error'](_0x432f('0xd'),_0x2f66fd,_0x340fe9[_0x432f('0x11')]['message']);return _0x2a2ef6(_0x340fe9[_0x432f('0x11')][_0x432f('0x13')]);}logger['error']('FreshsalesAccount,\x20%s,\x20%s',_0x2f66fd,_0x340fe9[_0x432f('0x11')][_0x432f('0x13')]);return _0x4a5b56(_0x340fe9[_0x432f('0x11')][_0x432f('0x13')]);}else{logger[_0x432f('0xc')]('FreshsalesAccount,\x20%s,\x20%s',_0x2f66fd,_0x432f('0xe'));_0x4a5b56(_0x340fe9[_0x432f('0x14')][_0x432f('0x13')]);}})[_0x432f('0x15')](function(_0x5bae29){logger[_0x432f('0x11')](_0x432f('0xd'),_0x2f66fd,_0x5bae29);_0x2a2ef6(_0x5bae29);});});}exports[_0x432f('0x16')]=function(_0x243cf){var _0x3cd5da=this;return new Promise(function(_0x129582,_0x5ae24e){return db[_0x432f('0x17')]['findAll']({'raw':_0x243cf[_0x432f('0x18')]?_0x243cf[_0x432f('0x18')][_0x432f('0x19')]===undefined?!![]:![]:!![],'where':_0x243cf[_0x432f('0x18')]?_0x243cf[_0x432f('0x18')][_0x432f('0x1a')]||null:null,'attributes':_0x243cf[_0x432f('0x18')]?_0x243cf[_0x432f('0x18')][_0x432f('0x1b')]||null:null,'limit':_0x243cf[_0x432f('0x18')]?_0x243cf[_0x432f('0x18')][_0x432f('0x1c')]||null:null,'include':_0x243cf['options']?_0x243cf['options'][_0x432f('0x1d')]?_['map'](_0x243cf[_0x432f('0x18')]['include'],function(_0x37f136){return{'model':db[_0x37f136[_0x432f('0x1e')]],'as':_0x37f136['as'],'attributes':_0x37f136[_0x432f('0x1b')],'include':_0x37f136[_0x432f('0x1d')]?_[_0x432f('0x1f')](_0x37f136[_0x432f('0x1d')],function(_0x59f352){return{'model':db[_0x59f352[_0x432f('0x1e')]],'as':_0x59f352['as'],'attributes':_0x59f352[_0x432f('0x1b')],'include':_0x59f352['include']?_[_0x432f('0x1f')](_0x59f352[_0x432f('0x1d')],function(_0x2bcbb4){return{'model':db[_0x2bcbb4[_0x432f('0x1e')]],'as':_0x2bcbb4['as'],'attributes':_0x2bcbb4[_0x432f('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x432f('0xb')](function(_0x138a6a){logger['info'](_0x432f('0x16'),_0x243cf);logger['debug'](_0x432f('0x16'),_0x243cf,JSON['stringify'](_0x138a6a));_0x129582(_0x138a6a);})[_0x432f('0x15')](function(_0x5a2c14){logger[_0x432f('0x11')]('GetFreshsalesAccount',_0x5a2c14[_0x432f('0x13')],_0x243cf);_0x5ae24e(_0x3cd5da[_0x432f('0x11')](0x1f4,_0x5a2c14[_0x432f('0x13')]));});});};exports['ShowFreshsalesAccount']=function(_0x6a116e){var _0x24406a=this;return new Promise(function(_0x48139b,_0x5ee0fa){return db[_0x432f('0x17')][_0x432f('0x20')]({'raw':_0x6a116e[_0x432f('0x18')]?_0x6a116e[_0x432f('0x18')][_0x432f('0x19')]===undefined?!![]:![]:!![],'where':_0x6a116e[_0x432f('0x18')]?_0x6a116e['options']['where']||null:null,'attributes':_0x6a116e[_0x432f('0x18')]?_0x6a116e[_0x432f('0x18')][_0x432f('0x1b')]||null:null,'include':_0x6a116e['options']?_0x6a116e[_0x432f('0x18')][_0x432f('0x1d')]?_[_0x432f('0x1f')](_0x6a116e[_0x432f('0x18')][_0x432f('0x1d')],function(_0x3ad632){return{'model':db[_0x3ad632[_0x432f('0x1e')]],'as':_0x3ad632['as'],'attributes':_0x3ad632[_0x432f('0x1b')],'include':_0x3ad632['include']?_['map'](_0x3ad632[_0x432f('0x1d')],function(_0xa5e0d){return{'model':db[_0xa5e0d['model']],'as':_0xa5e0d['as'],'attributes':_0xa5e0d['attributes'],'include':_0xa5e0d['include']?_[_0x432f('0x1f')](_0xa5e0d[_0x432f('0x1d')],function(_0x5648a7){return{'model':db[_0x5648a7[_0x432f('0x1e')]],'as':_0x5648a7['as'],'attributes':_0x5648a7[_0x432f('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x432f('0xb')](function(_0x5903f6){logger[_0x432f('0xc')](_0x432f('0x21'),_0x6a116e);logger['debug'](_0x432f('0x21'),_0x6a116e,JSON[_0x432f('0x10')](_0x5903f6));_0x48139b(_0x5903f6);})['catch'](function(_0x28da2e){logger[_0x432f('0x11')](_0x432f('0x21'),_0x28da2e[_0x432f('0x13')],_0x6a116e);_0x5ee0fa(_0x24406a[_0x432f('0x11')](0x1f4,_0x28da2e[_0x432f('0x13')]));});});};