Built motion from commit (unavailable).|2.5.31
[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 _0x4b74=['limit','map','model','include','then','ShowFreshsalesAccount','find','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','info','request\x20sent','debug','stringify','error','code','message','FreshsalesAccount,\x20%s,\x20%s','catch','GetFreshsalesAccount','FreshsalesAccount','findAll','options','raw','where','attributes'];(function(_0x4ac52d,_0x5769d5){var _0x13c1bb=function(_0x21b38e){while(--_0x21b38e){_0x4ac52d['push'](_0x4ac52d['shift']());}};_0x13c1bb(++_0x5769d5);}(_0x4b74,0x103));var _0x44b7=function(_0x18a421,_0x36c675){_0x18a421=_0x18a421-0x0;var _0x276911=_0x4b74[_0x18a421];return _0x276911;};'use strict';var _=require(_0x44b7('0x0'));var util=require(_0x44b7('0x1'));var moment=require(_0x44b7('0x2'));var BPromise=require('bluebird');var rs=require(_0x44b7('0x3'));var fs=require('fs');var Redis=require(_0x44b7('0x4'));var db=require(_0x44b7('0x5'))['db'];var utils=require(_0x44b7('0x6'));var logger=require(_0x44b7('0x7'))(_0x44b7('0x8'));var config=require(_0x44b7('0x9'));var jayson=require(_0x44b7('0xa'));var client=jayson['client'][_0x44b7('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2174f2,_0x7b80e9,_0x4a582b){return new BPromise(function(_0x45dfbe,_0xabf05c){return client[_0x44b7('0xc')](_0x2174f2,_0x4a582b)['then'](function(_0x7d4b17){logger[_0x44b7('0xd')]('FreshsalesAccount,\x20%s,\x20%s',_0x7b80e9,_0x44b7('0xe'));logger[_0x44b7('0xf')]('FreshsalesAccount,\x20%s,\x20%s,\x20%s',_0x7b80e9,_0x44b7('0xe'),JSON[_0x44b7('0x10')](_0x7d4b17));if(_0x7d4b17[_0x44b7('0x11')]){if(_0x7d4b17['error'][_0x44b7('0x12')]===0x1f4){logger[_0x44b7('0x11')]('FreshsalesAccount,\x20%s,\x20%s',_0x7b80e9,_0x7d4b17[_0x44b7('0x11')]['message']);return _0xabf05c(_0x7d4b17[_0x44b7('0x11')][_0x44b7('0x13')]);}logger[_0x44b7('0x11')]('FreshsalesAccount,\x20%s,\x20%s',_0x7b80e9,_0x7d4b17['error'][_0x44b7('0x13')]);return _0x45dfbe(_0x7d4b17['error']['message']);}else{logger['info'](_0x44b7('0x14'),_0x7b80e9,_0x44b7('0xe'));_0x45dfbe(_0x7d4b17['result'][_0x44b7('0x13')]);}})[_0x44b7('0x15')](function(_0x3528c8){logger[_0x44b7('0x11')](_0x44b7('0x14'),_0x7b80e9,_0x3528c8);_0xabf05c(_0x3528c8);});});}exports[_0x44b7('0x16')]=function(_0x40c84e){var _0xb6e09d=this;return new Promise(function(_0x3f0c30,_0x252e87){return db[_0x44b7('0x17')][_0x44b7('0x18')]({'raw':_0x40c84e[_0x44b7('0x19')]?_0x40c84e['options'][_0x44b7('0x1a')]===undefined?!![]:![]:!![],'where':_0x40c84e[_0x44b7('0x19')]?_0x40c84e['options'][_0x44b7('0x1b')]||null:null,'attributes':_0x40c84e[_0x44b7('0x19')]?_0x40c84e[_0x44b7('0x19')][_0x44b7('0x1c')]||null:null,'limit':_0x40c84e[_0x44b7('0x19')]?_0x40c84e[_0x44b7('0x19')][_0x44b7('0x1d')]||null:null,'include':_0x40c84e['options']?_0x40c84e[_0x44b7('0x19')]['include']?_[_0x44b7('0x1e')](_0x40c84e[_0x44b7('0x19')]['include'],function(_0x37a205){return{'model':db[_0x37a205[_0x44b7('0x1f')]],'as':_0x37a205['as'],'attributes':_0x37a205[_0x44b7('0x1c')],'include':_0x37a205[_0x44b7('0x20')]?_[_0x44b7('0x1e')](_0x37a205[_0x44b7('0x20')],function(_0xe90edf){return{'model':db[_0xe90edf['model']],'as':_0xe90edf['as'],'attributes':_0xe90edf['attributes'],'include':_0xe90edf[_0x44b7('0x20')]?_['map'](_0xe90edf[_0x44b7('0x20')],function(_0x5e5f58){return{'model':db[_0x5e5f58['model']],'as':_0x5e5f58['as'],'attributes':_0x5e5f58[_0x44b7('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x44b7('0x21')](function(_0x15d176){logger[_0x44b7('0xd')](_0x44b7('0x16'),_0x40c84e);logger['debug'](_0x44b7('0x16'),_0x40c84e,JSON[_0x44b7('0x10')](_0x15d176));_0x3f0c30(_0x15d176);})[_0x44b7('0x15')](function(_0x3da272){logger[_0x44b7('0x11')]('GetFreshsalesAccount',_0x3da272['message'],_0x40c84e);_0x252e87(_0xb6e09d['error'](0x1f4,_0x3da272[_0x44b7('0x13')]));});});};exports[_0x44b7('0x22')]=function(_0x50c34c){var _0x4ed0cc=this;return new Promise(function(_0x178126,_0x2a7bbe){return db[_0x44b7('0x17')][_0x44b7('0x23')]({'raw':_0x50c34c[_0x44b7('0x19')]?_0x50c34c[_0x44b7('0x19')][_0x44b7('0x1a')]===undefined?!![]:![]:!![],'where':_0x50c34c['options']?_0x50c34c['options'][_0x44b7('0x1b')]||null:null,'attributes':_0x50c34c[_0x44b7('0x19')]?_0x50c34c[_0x44b7('0x19')][_0x44b7('0x1c')]||null:null,'include':_0x50c34c[_0x44b7('0x19')]?_0x50c34c[_0x44b7('0x19')]['include']?_[_0x44b7('0x1e')](_0x50c34c[_0x44b7('0x19')][_0x44b7('0x20')],function(_0xed7e4b){return{'model':db[_0xed7e4b[_0x44b7('0x1f')]],'as':_0xed7e4b['as'],'attributes':_0xed7e4b[_0x44b7('0x1c')],'include':_0xed7e4b[_0x44b7('0x20')]?_[_0x44b7('0x1e')](_0xed7e4b[_0x44b7('0x20')],function(_0x278383){return{'model':db[_0x278383[_0x44b7('0x1f')]],'as':_0x278383['as'],'attributes':_0x278383['attributes'],'include':_0x278383[_0x44b7('0x20')]?_[_0x44b7('0x1e')](_0x278383['include'],function(_0x2c5fbd){return{'model':db[_0x2c5fbd[_0x44b7('0x1f')]],'as':_0x2c5fbd['as'],'attributes':_0x2c5fbd[_0x44b7('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x44b7('0x21')](function(_0x4dc363){logger[_0x44b7('0xd')]('ShowFreshsalesAccount',_0x50c34c);logger[_0x44b7('0xf')](_0x44b7('0x22'),_0x50c34c,JSON[_0x44b7('0x10')](_0x4dc363));_0x178126(_0x4dc363);})[_0x44b7('0x15')](function(_0x5c51ad){logger[_0x44b7('0x11')](_0x44b7('0x22'),_0x5c51ad[_0x44b7('0x13')],_0x50c34c);_0x2a7bbe(_0x4ed0cc['error'](0x1f4,_0x5c51ad[_0x44b7('0x13')]));});});};