Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / intServicenowAccount / intServicenowAccount.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 _0x4466=['jayson/promise','client','http','request','then','info','ServicenowAccount,\x20%s,\x20%s','request\x20sent','debug','error','code','message','catch','ServicenowAccount','findAll','raw','options','where','limit','include','map','model','attributes','GetServicenowAccount','stringify','ShowServicenowAccount','find','lodash','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x32b30c,_0x4c5567){var _0x59bc79=function(_0x5ef43d){while(--_0x5ef43d){_0x32b30c['push'](_0x32b30c['shift']());}};_0x59bc79(++_0x4c5567);}(_0x4466,0xa3));var _0x6446=function(_0x523d5b,_0x1808f0){_0x523d5b=_0x523d5b-0x0;var _0x4d5b4c=_0x4466[_0x523d5b];return _0x4d5b4c;};'use strict';var _=require(_0x6446('0x0'));var util=require('util');var moment=require(_0x6446('0x1'));var BPromise=require('bluebird');var rs=require(_0x6446('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6446('0x3'))['db'];var utils=require(_0x6446('0x4'));var logger=require(_0x6446('0x5'))(_0x6446('0x6'));var config=require('../../config/environment');var jayson=require(_0x6446('0x7'));var client=jayson[_0x6446('0x8')][_0x6446('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x267d5a,_0x5c9195,_0x25b7ee){return new BPromise(function(_0x4da189,_0x1c1769){return client[_0x6446('0xa')](_0x267d5a,_0x25b7ee)[_0x6446('0xb')](function(_0x5dbf8c){logger[_0x6446('0xc')](_0x6446('0xd'),_0x5c9195,_0x6446('0xe'));logger[_0x6446('0xf')]('ServicenowAccount,\x20%s,\x20%s,\x20%s',_0x5c9195,_0x6446('0xe'),JSON['stringify'](_0x5dbf8c));if(_0x5dbf8c[_0x6446('0x10')]){if(_0x5dbf8c['error'][_0x6446('0x11')]===0x1f4){logger[_0x6446('0x10')](_0x6446('0xd'),_0x5c9195,_0x5dbf8c[_0x6446('0x10')][_0x6446('0x12')]);return _0x1c1769(_0x5dbf8c['error']['message']);}logger[_0x6446('0x10')](_0x6446('0xd'),_0x5c9195,_0x5dbf8c[_0x6446('0x10')][_0x6446('0x12')]);return _0x4da189(_0x5dbf8c[_0x6446('0x10')][_0x6446('0x12')]);}else{logger['info'](_0x6446('0xd'),_0x5c9195,_0x6446('0xe'));_0x4da189(_0x5dbf8c['result'][_0x6446('0x12')]);}})[_0x6446('0x13')](function(_0x42e5fc){logger[_0x6446('0x10')](_0x6446('0xd'),_0x5c9195,_0x42e5fc);_0x1c1769(_0x42e5fc);});});}exports['GetServicenowAccount']=function(_0xc49166){var _0x30d36d=this;return new Promise(function(_0x103498,_0x3b8ba2){return db[_0x6446('0x14')][_0x6446('0x15')]({'raw':_0xc49166['options']?_0xc49166['options'][_0x6446('0x16')]===undefined?!![]:![]:!![],'where':_0xc49166['options']?_0xc49166[_0x6446('0x17')][_0x6446('0x18')]||null:null,'attributes':_0xc49166[_0x6446('0x17')]?_0xc49166['options']['attributes']||null:null,'limit':_0xc49166[_0x6446('0x17')]?_0xc49166['options'][_0x6446('0x19')]||null:null,'include':_0xc49166['options']?_0xc49166[_0x6446('0x17')][_0x6446('0x1a')]?_[_0x6446('0x1b')](_0xc49166[_0x6446('0x17')][_0x6446('0x1a')],function(_0x432529){return{'model':db[_0x432529[_0x6446('0x1c')]],'as':_0x432529['as'],'attributes':_0x432529[_0x6446('0x1d')],'include':_0x432529[_0x6446('0x1a')]?_[_0x6446('0x1b')](_0x432529[_0x6446('0x1a')],function(_0x548527){return{'model':db[_0x548527['model']],'as':_0x548527['as'],'attributes':_0x548527[_0x6446('0x1d')],'include':_0x548527[_0x6446('0x1a')]?_['map'](_0x548527[_0x6446('0x1a')],function(_0x50e66a){return{'model':db[_0x50e66a['model']],'as':_0x50e66a['as'],'attributes':_0x50e66a[_0x6446('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x6446('0xb')](function(_0x3a6e09){logger['info'](_0x6446('0x1e'),_0xc49166);logger[_0x6446('0xf')](_0x6446('0x1e'),_0xc49166,JSON[_0x6446('0x1f')](_0x3a6e09));_0x103498(_0x3a6e09);})['catch'](function(_0x3d5279){logger[_0x6446('0x10')](_0x6446('0x1e'),_0x3d5279[_0x6446('0x12')],_0xc49166);_0x3b8ba2(_0x30d36d[_0x6446('0x10')](0x1f4,_0x3d5279[_0x6446('0x12')]));});});};exports[_0x6446('0x20')]=function(_0x3dc0f5){var _0x5e2c98=this;return new Promise(function(_0x12e642,_0x49f8c8){return db[_0x6446('0x14')][_0x6446('0x21')]({'raw':_0x3dc0f5[_0x6446('0x17')]?_0x3dc0f5[_0x6446('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x3dc0f5['options']?_0x3dc0f5[_0x6446('0x17')][_0x6446('0x18')]||null:null,'attributes':_0x3dc0f5[_0x6446('0x17')]?_0x3dc0f5[_0x6446('0x17')][_0x6446('0x1d')]||null:null,'include':_0x3dc0f5[_0x6446('0x17')]?_0x3dc0f5[_0x6446('0x17')][_0x6446('0x1a')]?_[_0x6446('0x1b')](_0x3dc0f5[_0x6446('0x17')]['include'],function(_0x1e4561){return{'model':db[_0x1e4561['model']],'as':_0x1e4561['as'],'attributes':_0x1e4561[_0x6446('0x1d')],'include':_0x1e4561['include']?_['map'](_0x1e4561[_0x6446('0x1a')],function(_0x5cb006){return{'model':db[_0x5cb006['model']],'as':_0x5cb006['as'],'attributes':_0x5cb006[_0x6446('0x1d')],'include':_0x5cb006[_0x6446('0x1a')]?_[_0x6446('0x1b')](_0x5cb006['include'],function(_0x452d6f){return{'model':db[_0x452d6f[_0x6446('0x1c')]],'as':_0x452d6f['as'],'attributes':_0x452d6f[_0x6446('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x564546){logger[_0x6446('0xc')](_0x6446('0x20'),_0x3dc0f5);logger['debug'](_0x6446('0x20'),_0x3dc0f5,JSON[_0x6446('0x1f')](_0x564546));_0x12e642(_0x564546);})[_0x6446('0x13')](function(_0x23298f){logger[_0x6446('0x10')](_0x6446('0x20'),_0x23298f[_0x6446('0x12')],_0x3dc0f5);_0x49f8c8(_0x5e2c98[_0x6446('0x10')](0x1f4,_0x23298f[_0x6446('0x12')]));});});};