Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.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 _0x8239=['../../config/environment','jayson/promise','client','http','request','then','info','SalesforceAccount,\x20%s,\x20%s','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','catch','GetSalesforceAccount','SalesforceAccount','findAll','options','map','include','model','attributes','ShowSalesforceAccount','find','where','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x2a26ad,_0x44d8eb){var _0xf9f25d=function(_0x2df971){while(--_0x2df971){_0x2a26ad['push'](_0x2a26ad['shift']());}};_0xf9f25d(++_0x44d8eb);}(_0x8239,0x1e2));var _0x9823=function(_0x43fd7f,_0x5b301d){_0x43fd7f=_0x43fd7f-0x0;var _0x4dd2c5=_0x8239[_0x43fd7f];return _0x4dd2c5;};'use strict';var _=require('lodash');var util=require(_0x9823('0x0'));var moment=require(_0x9823('0x1'));var BPromise=require(_0x9823('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x9823('0x3'));var db=require(_0x9823('0x4'))['db'];var utils=require(_0x9823('0x5'));var logger=require(_0x9823('0x6'))(_0x9823('0x7'));var config=require(_0x9823('0x8'));var jayson=require(_0x9823('0x9'));var client=jayson[_0x9823('0xa')][_0x9823('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3cd0e6,_0x570e3f,_0x589db9){return new BPromise(function(_0x3dadbd,_0x25445f){return client[_0x9823('0xc')](_0x3cd0e6,_0x589db9)[_0x9823('0xd')](function(_0x8fc375){logger[_0x9823('0xe')](_0x9823('0xf'),_0x570e3f,'request\x20sent');logger[_0x9823('0x10')](_0x9823('0x11'),_0x570e3f,'request\x20sent',JSON[_0x9823('0x12')](_0x8fc375));if(_0x8fc375[_0x9823('0x13')]){if(_0x8fc375[_0x9823('0x13')][_0x9823('0x14')]===0x1f4){logger[_0x9823('0x13')](_0x9823('0xf'),_0x570e3f,_0x8fc375['error'][_0x9823('0x15')]);return _0x25445f(_0x8fc375[_0x9823('0x13')][_0x9823('0x15')]);}logger[_0x9823('0x13')](_0x9823('0xf'),_0x570e3f,_0x8fc375[_0x9823('0x13')]['message']);return _0x3dadbd(_0x8fc375[_0x9823('0x13')][_0x9823('0x15')]);}else{logger[_0x9823('0xe')](_0x9823('0xf'),_0x570e3f,_0x9823('0x16'));_0x3dadbd(_0x8fc375['result'][_0x9823('0x15')]);}})[_0x9823('0x17')](function(_0x38c835){logger['error'](_0x9823('0xf'),_0x570e3f,_0x38c835);_0x25445f(_0x38c835);});});}exports[_0x9823('0x18')]=function(_0x347426){var _0x36defc=this;return new Promise(function(_0x23c73e,_0x328d03){return db[_0x9823('0x19')][_0x9823('0x1a')]({'raw':_0x347426[_0x9823('0x1b')]?_0x347426[_0x9823('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x347426[_0x9823('0x1b')]?_0x347426[_0x9823('0x1b')]['where']||null:null,'attributes':_0x347426[_0x9823('0x1b')]?_0x347426[_0x9823('0x1b')]['attributes']||null:null,'limit':_0x347426[_0x9823('0x1b')]?_0x347426[_0x9823('0x1b')]['limit']||null:null,'include':_0x347426['options']?_0x347426[_0x9823('0x1b')]['include']?_[_0x9823('0x1c')](_0x347426[_0x9823('0x1b')][_0x9823('0x1d')],function(_0x493880){return{'model':db[_0x493880[_0x9823('0x1e')]],'as':_0x493880['as'],'attributes':_0x493880['attributes'],'include':_0x493880[_0x9823('0x1d')]?_[_0x9823('0x1c')](_0x493880[_0x9823('0x1d')],function(_0x1fa0b2){return{'model':db[_0x1fa0b2[_0x9823('0x1e')]],'as':_0x1fa0b2['as'],'attributes':_0x1fa0b2[_0x9823('0x1f')],'include':_0x1fa0b2['include']?_[_0x9823('0x1c')](_0x1fa0b2[_0x9823('0x1d')],function(_0x529694){return{'model':db[_0x529694[_0x9823('0x1e')]],'as':_0x529694['as'],'attributes':_0x529694['attributes']};}):[]};}):[]};}):[]:[]})[_0x9823('0xd')](function(_0xa2e84c){logger[_0x9823('0xe')](_0x9823('0x18'),_0x347426);logger['debug'](_0x9823('0x18'),_0x347426,JSON['stringify'](_0xa2e84c));_0x23c73e(_0xa2e84c);})['catch'](function(_0x34469b){logger[_0x9823('0x13')](_0x9823('0x18'),_0x34469b[_0x9823('0x15')],_0x347426);_0x328d03(_0x36defc['error'](0x1f4,_0x34469b[_0x9823('0x15')]));});});};exports[_0x9823('0x20')]=function(_0x4499f7){var _0x4c0634=this;return new Promise(function(_0x444144,_0x18db33){return db[_0x9823('0x19')][_0x9823('0x21')]({'raw':_0x4499f7['options']?_0x4499f7[_0x9823('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x4499f7['options']?_0x4499f7[_0x9823('0x1b')][_0x9823('0x22')]||null:null,'attributes':_0x4499f7[_0x9823('0x1b')]?_0x4499f7[_0x9823('0x1b')][_0x9823('0x1f')]||null:null,'include':_0x4499f7[_0x9823('0x1b')]?_0x4499f7[_0x9823('0x1b')]['include']?_[_0x9823('0x1c')](_0x4499f7['options'][_0x9823('0x1d')],function(_0x4ecd43){return{'model':db[_0x4ecd43['model']],'as':_0x4ecd43['as'],'attributes':_0x4ecd43['attributes'],'include':_0x4ecd43['include']?_['map'](_0x4ecd43['include'],function(_0x3cdcf5){return{'model':db[_0x3cdcf5['model']],'as':_0x3cdcf5['as'],'attributes':_0x3cdcf5[_0x9823('0x1f')],'include':_0x3cdcf5[_0x9823('0x1d')]?_[_0x9823('0x1c')](_0x3cdcf5['include'],function(_0x413cde){return{'model':db[_0x413cde[_0x9823('0x1e')]],'as':_0x413cde['as'],'attributes':_0x413cde[_0x9823('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x9823('0xd')](function(_0x1d788f){logger[_0x9823('0xe')](_0x9823('0x20'),_0x4499f7);logger[_0x9823('0x10')](_0x9823('0x20'),_0x4499f7,JSON[_0x9823('0x12')](_0x1d788f));_0x444144(_0x1d788f);})['catch'](function(_0x1b5c1b){logger[_0x9823('0x13')](_0x9823('0x20'),_0x1b5c1b['message'],_0x4499f7);_0x18db33(_0x4c0634[_0x9823('0x13')](0x1f4,_0x1b5c1b[_0x9823('0x15')]));});});};