c3bf93c4450e643f016ab9d32b54cbb575b19c24
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.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 _0x739e=['error','message','result','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','attributes','limit','map','include','model','stringify','ShowSugarcrmAccount','find','where','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s'];(function(_0x22ddb5,_0x1df707){var _0x5a7937=function(_0x435796){while(--_0x435796){_0x22ddb5['push'](_0x22ddb5['shift']());}};_0x5a7937(++_0x1df707);}(_0x739e,0x193));var _0xe739=function(_0x26a013,_0x5b329e){_0x26a013=_0x26a013-0x0;var _0x51f08f=_0x739e[_0x26a013];return _0x51f08f;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0xe739('0x0'));var rs=require(_0xe739('0x1'));var fs=require('fs');var Redis=require(_0xe739('0x2'));var db=require(_0xe739('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0xe739('0x4'))(_0xe739('0x5'));var config=require(_0xe739('0x6'));var jayson=require(_0xe739('0x7'));var client=jayson[_0xe739('0x8')][_0xe739('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2c4f81,_0x2ec9f6,_0x47d601){return new BPromise(function(_0x2f21ef,_0x137214){return client[_0xe739('0xa')](_0x2c4f81,_0x47d601)[_0xe739('0xb')](function(_0x324ba8){logger[_0xe739('0xc')](_0xe739('0xd'),_0x2ec9f6,_0xe739('0xe'));logger[_0xe739('0xf')](_0xe739('0x10'),_0x2ec9f6,_0xe739('0xe'),JSON['stringify'](_0x324ba8));if(_0x324ba8[_0xe739('0x11')]){if(_0x324ba8[_0xe739('0x11')]['code']===0x1f4){logger[_0xe739('0x11')]('SugarcrmAccount,\x20%s,\x20%s',_0x2ec9f6,_0x324ba8[_0xe739('0x11')][_0xe739('0x12')]);return _0x137214(_0x324ba8[_0xe739('0x11')][_0xe739('0x12')]);}logger[_0xe739('0x11')](_0xe739('0xd'),_0x2ec9f6,_0x324ba8[_0xe739('0x11')][_0xe739('0x12')]);return _0x2f21ef(_0x324ba8[_0xe739('0x11')]['message']);}else{logger['info'](_0xe739('0xd'),_0x2ec9f6,_0xe739('0xe'));_0x2f21ef(_0x324ba8[_0xe739('0x13')][_0xe739('0x12')]);}})[_0xe739('0x14')](function(_0x2deaff){logger['error'](_0xe739('0xd'),_0x2ec9f6,_0x2deaff);_0x137214(_0x2deaff);});});}exports[_0xe739('0x15')]=function(_0x121aa1){var _0x2a6813=this;return new Promise(function(_0x5b0a2b,_0x2daf88){return db[_0xe739('0x16')][_0xe739('0x17')]({'raw':_0x121aa1[_0xe739('0x18')]?_0x121aa1[_0xe739('0x18')][_0xe739('0x19')]===undefined?!![]:![]:!![],'where':_0x121aa1[_0xe739('0x18')]?_0x121aa1[_0xe739('0x18')]['where']||null:null,'attributes':_0x121aa1[_0xe739('0x18')]?_0x121aa1['options'][_0xe739('0x1a')]||null:null,'limit':_0x121aa1[_0xe739('0x18')]?_0x121aa1[_0xe739('0x18')][_0xe739('0x1b')]||null:null,'include':_0x121aa1[_0xe739('0x18')]?_0x121aa1[_0xe739('0x18')]['include']?_[_0xe739('0x1c')](_0x121aa1['options']['include'],function(_0x5462cf){return{'model':db[_0x5462cf['model']],'as':_0x5462cf['as'],'attributes':_0x5462cf[_0xe739('0x1a')],'include':_0x5462cf[_0xe739('0x1d')]?_[_0xe739('0x1c')](_0x5462cf['include'],function(_0x309a1c){return{'model':db[_0x309a1c[_0xe739('0x1e')]],'as':_0x309a1c['as'],'attributes':_0x309a1c['attributes'],'include':_0x309a1c[_0xe739('0x1d')]?_[_0xe739('0x1c')](_0x309a1c[_0xe739('0x1d')],function(_0x1dce5d){return{'model':db[_0x1dce5d['model']],'as':_0x1dce5d['as'],'attributes':_0x1dce5d[_0xe739('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xe739('0xb')](function(_0x1a90d1){logger[_0xe739('0xc')](_0xe739('0x15'),_0x121aa1);logger[_0xe739('0xf')](_0xe739('0x15'),_0x121aa1,JSON[_0xe739('0x1f')](_0x1a90d1));_0x5b0a2b(_0x1a90d1);})[_0xe739('0x14')](function(_0x138bc3){logger['error']('GetSugarcrmAccount',_0x138bc3[_0xe739('0x12')],_0x121aa1);_0x2daf88(_0x2a6813['error'](0x1f4,_0x138bc3[_0xe739('0x12')]));});});};exports[_0xe739('0x20')]=function(_0x212d79){var _0x3d0887=this;return new Promise(function(_0x3f4b74,_0x260f4d){return db['SugarcrmAccount'][_0xe739('0x21')]({'raw':_0x212d79[_0xe739('0x18')]?_0x212d79[_0xe739('0x18')][_0xe739('0x19')]===undefined?!![]:![]:!![],'where':_0x212d79[_0xe739('0x18')]?_0x212d79[_0xe739('0x18')][_0xe739('0x22')]||null:null,'attributes':_0x212d79['options']?_0x212d79[_0xe739('0x18')][_0xe739('0x1a')]||null:null,'include':_0x212d79[_0xe739('0x18')]?_0x212d79[_0xe739('0x18')]['include']?_[_0xe739('0x1c')](_0x212d79[_0xe739('0x18')][_0xe739('0x1d')],function(_0xb08978){return{'model':db[_0xb08978['model']],'as':_0xb08978['as'],'attributes':_0xb08978[_0xe739('0x1a')],'include':_0xb08978[_0xe739('0x1d')]?_[_0xe739('0x1c')](_0xb08978[_0xe739('0x1d')],function(_0x2c7ecc){return{'model':db[_0x2c7ecc['model']],'as':_0x2c7ecc['as'],'attributes':_0x2c7ecc[_0xe739('0x1a')],'include':_0x2c7ecc[_0xe739('0x1d')]?_[_0xe739('0x1c')](_0x2c7ecc[_0xe739('0x1d')],function(_0x17f8d4){return{'model':db[_0x17f8d4[_0xe739('0x1e')]],'as':_0x17f8d4['as'],'attributes':_0x17f8d4[_0xe739('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xe739('0xb')](function(_0x4aa625){logger[_0xe739('0xc')](_0xe739('0x20'),_0x212d79);logger[_0xe739('0xf')](_0xe739('0x20'),_0x212d79,JSON['stringify'](_0x4aa625));_0x3f4b74(_0x4aa625);})[_0xe739('0x14')](function(_0x1059dc){logger[_0xe739('0x11')](_0xe739('0x20'),_0x1059dc[_0xe739('0x12')],_0x212d79);_0x260f4d(_0x3d0887[_0xe739('0x11')](0x1f4,_0x1059dc[_0xe739('0x12')]));});});};