15d9354465a65ffc6063ec88ee200654b9702b6d
[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 _0x0c3d=['client','http','request','then','info','OpenchannelApplication,\x20%s,\x20%s','request\x20sent','debug','OpenchannelApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','result','OpenchannelApplication','update','options','raw','attributes','limit','UpdateOpenchannelApplication','lodash','util','moment','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x375ac7,_0x1c0e76){var _0x2c4df9=function(_0x302245){while(--_0x302245){_0x375ac7['push'](_0x375ac7['shift']());}};_0x2c4df9(++_0x1c0e76);}(_0x0c3d,0xdf));var _0xd0c3=function(_0x388b47,_0x5cdac5){_0x388b47=_0x388b47-0x0;var _0x4859df=_0x0c3d[_0x388b47];return _0x4859df;};'use strict';var _=require(_0xd0c3('0x0'));var util=require(_0xd0c3('0x1'));var moment=require(_0xd0c3('0x2'));var BPromise=require('bluebird');var rs=require(_0xd0c3('0x3'));var fs=require('fs');var Redis=require(_0xd0c3('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xd0c3('0x5'))(_0xd0c3('0x6'));var config=require(_0xd0c3('0x7'));var jayson=require(_0xd0c3('0x8'));var client=jayson[_0xd0c3('0x9')][_0xd0c3('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1d802e,_0x46f606,_0x5dd387){return new BPromise(function(_0x3df324,_0x2a5d6e){return client[_0xd0c3('0xb')](_0x1d802e,_0x5dd387)[_0xd0c3('0xc')](function(_0x1feec3){logger[_0xd0c3('0xd')](_0xd0c3('0xe'),_0x46f606,_0xd0c3('0xf'));logger[_0xd0c3('0x10')](_0xd0c3('0x11'),_0x46f606,_0xd0c3('0xf'),JSON[_0xd0c3('0x12')](_0x1feec3));if(_0x1feec3[_0xd0c3('0x13')]){if(_0x1feec3[_0xd0c3('0x13')]['code']===0x1f4){logger[_0xd0c3('0x13')](_0xd0c3('0xe'),_0x46f606,_0x1feec3[_0xd0c3('0x13')][_0xd0c3('0x14')]);return _0x2a5d6e(_0x1feec3['error']['message']);}logger[_0xd0c3('0x13')]('OpenchannelApplication,\x20%s,\x20%s',_0x46f606,_0x1feec3[_0xd0c3('0x13')][_0xd0c3('0x14')]);return _0x3df324(_0x1feec3[_0xd0c3('0x13')][_0xd0c3('0x14')]);}else{logger[_0xd0c3('0xd')](_0xd0c3('0xe'),_0x46f606,_0xd0c3('0xf'));_0x3df324(_0x1feec3[_0xd0c3('0x15')]['message']);}})['catch'](function(_0x1ad2de){logger[_0xd0c3('0x13')]('OpenchannelApplication,\x20%s,\x20%s',_0x46f606,_0x1ad2de);_0x2a5d6e(_0x1ad2de);});});}exports['UpdateOpenchannelApplication']=function(_0x421bb3){var _0x226625=this;return new Promise(function(_0x23ba31,_0x2c257c){return db[_0xd0c3('0x16')][_0xd0c3('0x17')](_0x421bb3['body'],{'raw':_0x421bb3[_0xd0c3('0x18')]?_0x421bb3['options'][_0xd0c3('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x421bb3[_0xd0c3('0x18')]?_0x421bb3[_0xd0c3('0x18')]['where']||null:null,'attributes':_0x421bb3[_0xd0c3('0x18')]?_0x421bb3['options'][_0xd0c3('0x1a')]||null:null,'limit':_0x421bb3['options']?_0x421bb3[_0xd0c3('0x18')][_0xd0c3('0x1b')]||null:null})['then'](function(_0x40ddc9){logger['info'](_0xd0c3('0x1c'),_0x421bb3);logger[_0xd0c3('0x10')](_0xd0c3('0x1c'),_0x421bb3,JSON[_0xd0c3('0x12')](_0x40ddc9));_0x23ba31(_0x40ddc9);})['catch'](function(_0x188028){logger[_0xd0c3('0x13')]('UpdateOpenchannelApplication',_0x188028[_0xd0c3('0x14')],_0x421bb3);_0x2c257c(_0x226625['error'](0x1f4,_0x188028[_0xd0c3('0x14')]));});});};