8264408cd179c4a9f5b2bf83f48d076ddd36446d
[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 _0x4296=['raw','attributes','limit','include','model','map','ShowSugarcrmAccount','find','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','SugarcrmAccount,\x20%s,\x20%s','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','request\x20sent','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options'];(function(_0x216edc,_0x57df05){var _0x745d3e=function(_0x2b1bf8){while(--_0x2b1bf8){_0x216edc['push'](_0x216edc['shift']());}};_0x745d3e(++_0x57df05);}(_0x4296,0x74));var _0x6429=function(_0x494d1f,_0x3f72ff){_0x494d1f=_0x494d1f-0x0;var _0x457b6e=_0x4296[_0x494d1f];return _0x457b6e;};'use strict';var _=require('lodash');var util=require(_0x6429('0x0'));var moment=require(_0x6429('0x1'));var BPromise=require(_0x6429('0x2'));var rs=require(_0x6429('0x3'));var fs=require('fs');var Redis=require(_0x6429('0x4'));var db=require(_0x6429('0x5'))['db'];var utils=require(_0x6429('0x6'));var logger=require('../../config/logger')(_0x6429('0x7'));var config=require(_0x6429('0x8'));var jayson=require(_0x6429('0x9'));var client=jayson[_0x6429('0xa')][_0x6429('0xb')]({'port':0x232a});function respondWithRpcPromise(_0xf9a336,_0x42f26d,_0x4be0be){return new BPromise(function(_0x571cd5,_0x10f96e){return client[_0x6429('0xc')](_0xf9a336,_0x4be0be)[_0x6429('0xd')](function(_0x59c93e){logger['info'](_0x6429('0xe'),_0x42f26d,'request\x20sent');logger[_0x6429('0xf')](_0x6429('0x10'),_0x42f26d,'request\x20sent',JSON[_0x6429('0x11')](_0x59c93e));if(_0x59c93e[_0x6429('0x12')]){if(_0x59c93e[_0x6429('0x12')][_0x6429('0x13')]===0x1f4){logger[_0x6429('0x12')]('SugarcrmAccount,\x20%s,\x20%s',_0x42f26d,_0x59c93e['error'][_0x6429('0x14')]);return _0x10f96e(_0x59c93e['error']['message']);}logger['error'](_0x6429('0xe'),_0x42f26d,_0x59c93e[_0x6429('0x12')][_0x6429('0x14')]);return _0x571cd5(_0x59c93e[_0x6429('0x12')][_0x6429('0x14')]);}else{logger[_0x6429('0x15')](_0x6429('0xe'),_0x42f26d,_0x6429('0x16'));_0x571cd5(_0x59c93e['result']['message']);}})[_0x6429('0x17')](function(_0x36180f){logger[_0x6429('0x12')]('SugarcrmAccount,\x20%s,\x20%s',_0x42f26d,_0x36180f);_0x10f96e(_0x36180f);});});}exports[_0x6429('0x18')]=function(_0x1c5357){var _0x578a2b=this;return new Promise(function(_0x1c70a3,_0x14d688){return db[_0x6429('0x19')][_0x6429('0x1a')]({'raw':_0x1c5357[_0x6429('0x1b')]?_0x1c5357['options'][_0x6429('0x1c')]===undefined?!![]:![]:!![],'where':_0x1c5357[_0x6429('0x1b')]?_0x1c5357['options']['where']||null:null,'attributes':_0x1c5357[_0x6429('0x1b')]?_0x1c5357['options'][_0x6429('0x1d')]||null:null,'limit':_0x1c5357['options']?_0x1c5357[_0x6429('0x1b')][_0x6429('0x1e')]||null:null,'include':_0x1c5357[_0x6429('0x1b')]?_0x1c5357[_0x6429('0x1b')][_0x6429('0x1f')]?_['map'](_0x1c5357[_0x6429('0x1b')][_0x6429('0x1f')],function(_0x4d6d7b){return{'model':db[_0x4d6d7b[_0x6429('0x20')]],'as':_0x4d6d7b['as'],'attributes':_0x4d6d7b[_0x6429('0x1d')],'include':_0x4d6d7b[_0x6429('0x1f')]?_[_0x6429('0x21')](_0x4d6d7b[_0x6429('0x1f')],function(_0x1a989c){return{'model':db[_0x1a989c[_0x6429('0x20')]],'as':_0x1a989c['as'],'attributes':_0x1a989c[_0x6429('0x1d')],'include':_0x1a989c[_0x6429('0x1f')]?_[_0x6429('0x21')](_0x1a989c[_0x6429('0x1f')],function(_0x4d76a9){return{'model':db[_0x4d76a9[_0x6429('0x20')]],'as':_0x4d76a9['as'],'attributes':_0x4d76a9[_0x6429('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x6429('0xd')](function(_0x56e0fc){logger['info'](_0x6429('0x18'),_0x1c5357);logger[_0x6429('0xf')](_0x6429('0x18'),_0x1c5357,JSON['stringify'](_0x56e0fc));_0x1c70a3(_0x56e0fc);})[_0x6429('0x17')](function(_0x188c94){logger['error'](_0x6429('0x18'),_0x188c94[_0x6429('0x14')],_0x1c5357);_0x14d688(_0x578a2b[_0x6429('0x12')](0x1f4,_0x188c94[_0x6429('0x14')]));});});};exports[_0x6429('0x22')]=function(_0x58d634){var _0x21d69e=this;return new Promise(function(_0x35cb15,_0x3c239f){return db['SugarcrmAccount'][_0x6429('0x23')]({'raw':_0x58d634['options']?_0x58d634['options']['raw']===undefined?!![]:![]:!![],'where':_0x58d634[_0x6429('0x1b')]?_0x58d634['options']['where']||null:null,'attributes':_0x58d634[_0x6429('0x1b')]?_0x58d634['options'][_0x6429('0x1d')]||null:null,'include':_0x58d634[_0x6429('0x1b')]?_0x58d634['options'][_0x6429('0x1f')]?_[_0x6429('0x21')](_0x58d634['options'][_0x6429('0x1f')],function(_0x188fa6){return{'model':db[_0x188fa6[_0x6429('0x20')]],'as':_0x188fa6['as'],'attributes':_0x188fa6['attributes'],'include':_0x188fa6[_0x6429('0x1f')]?_[_0x6429('0x21')](_0x188fa6[_0x6429('0x1f')],function(_0x41d9b0){return{'model':db[_0x41d9b0[_0x6429('0x20')]],'as':_0x41d9b0['as'],'attributes':_0x41d9b0['attributes'],'include':_0x41d9b0[_0x6429('0x1f')]?_['map'](_0x41d9b0[_0x6429('0x1f')],function(_0xbb6417){return{'model':db[_0xbb6417[_0x6429('0x20')]],'as':_0xbb6417['as'],'attributes':_0xbb6417[_0x6429('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x6429('0xd')](function(_0x1cb8c7){logger[_0x6429('0x15')](_0x6429('0x22'),_0x58d634);logger[_0x6429('0xf')](_0x6429('0x22'),_0x58d634,JSON[_0x6429('0x11')](_0x1cb8c7));_0x35cb15(_0x1cb8c7);})[_0x6429('0x17')](function(_0x2ce148){logger[_0x6429('0x12')]('ShowSugarcrmAccount',_0x2ce148[_0x6429('0x14')],_0x58d634);_0x3c239f(_0x21d69e[_0x6429('0x12')](0x1f4,_0x2ce148[_0x6429('0x14')]));});});};