e45e870e4d295654cb02b291b74a55078989e038
[motion2.git] / server / api / openchannelApplication / openchannelApplication.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 _0xd36e=['client','info','request\x20sent','debug','OpenchannelApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','OpenchannelApplication,\x20%s,\x20%s','message','result','catch','OpenchannelApplication','update','body','options','raw','where','attributes','limit','UpdateOpenchannelApplication','lodash','util','moment','../../config/logger','../../config/environment','jayson/promise'];(function(_0x4f5dd9,_0x30b8c5){var _0x3c8624=function(_0x3d7f06){while(--_0x3d7f06){_0x4f5dd9['push'](_0x4f5dd9['shift']());}};_0x3c8624(++_0x30b8c5);}(_0xd36e,0x123));var _0xed36=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0xd36e[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0xed36('0x0'));var util=require(_0xed36('0x1'));var moment=require(_0xed36('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xed36('0x3'))('rpc');var config=require(_0xed36('0x4'));var jayson=require(_0xed36('0x5'));var client=jayson[_0xed36('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0x48e44d,_0x34fcf0,_0xad3e39){return new BPromise(function(_0x557e31,_0xf22b03){return client['request'](_0x48e44d,_0xad3e39)['then'](function(_0x50696d){logger[_0xed36('0x7')]('OpenchannelApplication,\x20%s,\x20%s',_0x34fcf0,_0xed36('0x8'));logger[_0xed36('0x9')](_0xed36('0xa'),_0x34fcf0,_0xed36('0x8'),JSON[_0xed36('0xb')](_0x50696d));if(_0x50696d['error']){if(_0x50696d[_0xed36('0xc')][_0xed36('0xd')]===0x1f4){logger['error'](_0xed36('0xe'),_0x34fcf0,_0x50696d[_0xed36('0xc')][_0xed36('0xf')]);return _0xf22b03(_0x50696d[_0xed36('0xc')]['message']);}logger[_0xed36('0xc')](_0xed36('0xe'),_0x34fcf0,_0x50696d[_0xed36('0xc')][_0xed36('0xf')]);return _0x557e31(_0x50696d[_0xed36('0xc')][_0xed36('0xf')]);}else{logger[_0xed36('0x7')](_0xed36('0xe'),_0x34fcf0,'request\x20sent');_0x557e31(_0x50696d[_0xed36('0x10')][_0xed36('0xf')]);}})[_0xed36('0x11')](function(_0x3b5678){logger[_0xed36('0xc')](_0xed36('0xe'),_0x34fcf0,_0x3b5678);_0xf22b03(_0x3b5678);});});}exports['UpdateOpenchannelApplication']=function(_0x45a696){var _0x139691=this;return new Promise(function(_0x1dfc95,_0x625b1c){return db[_0xed36('0x12')][_0xed36('0x13')](_0x45a696[_0xed36('0x14')],{'raw':_0x45a696[_0xed36('0x15')]?_0x45a696[_0xed36('0x15')][_0xed36('0x16')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x45a696[_0xed36('0x15')]?_0x45a696[_0xed36('0x15')][_0xed36('0x17')]||null:null,'attributes':_0x45a696[_0xed36('0x15')]?_0x45a696[_0xed36('0x15')][_0xed36('0x18')]||null:null,'limit':_0x45a696[_0xed36('0x15')]?_0x45a696['options'][_0xed36('0x19')]||null:null})['then'](function(_0x246351){logger['info'](_0xed36('0x1a'),_0x45a696);logger[_0xed36('0x9')](_0xed36('0x1a'),_0x45a696,JSON[_0xed36('0xb')](_0x246351));_0x1dfc95(_0x246351);})[_0xed36('0x11')](function(_0xb29e8a){logger[_0xed36('0xc')](_0xed36('0x1a'),_0xb29e8a['message'],_0x45a696);_0x625b1c(_0x139691[_0xed36('0xc')](0x1f4,_0xb29e8a[_0xed36('0xf')]));});});};