e35d7cb16ca5175f6ca3b2582b7adfe648e03055
[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 _0x1cb4=['jayson/promise','http','request','then','OpenchannelApplication,\x20%s,\x20%s','request\x20sent','debug','OpenchannelApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','update','body','options','raw','info','UpdateOpenchannelApplication','lodash','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x4b055c,_0x4b870b){var _0x4b62bb=function(_0x4884c2){while(--_0x4884c2){_0x4b055c['push'](_0x4b055c['shift']());}};_0x4b62bb(++_0x4b870b);}(_0x1cb4,0x10f));var _0x41cb=function(_0x47d707,_0x50b692){_0x47d707=_0x47d707-0x0;var _0x45bb8a=_0x1cb4[_0x47d707];return _0x45bb8a;};'use strict';var _=require(_0x41cb('0x0'));var util=require(_0x41cb('0x1'));var moment=require(_0x41cb('0x2'));var BPromise=require(_0x41cb('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x41cb('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x41cb('0x5'));var logger=require(_0x41cb('0x6'))(_0x41cb('0x7'));var config=require(_0x41cb('0x8'));var jayson=require(_0x41cb('0x9'));var client=jayson['client'][_0x41cb('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x85d675,_0xe98d5e,_0x585ec7){return new BPromise(function(_0x142669,_0x108fd){return client[_0x41cb('0xb')](_0x85d675,_0x585ec7)[_0x41cb('0xc')](function(_0x37c859){logger['info'](_0x41cb('0xd'),_0xe98d5e,_0x41cb('0xe'));logger[_0x41cb('0xf')](_0x41cb('0x10'),_0xe98d5e,_0x41cb('0xe'),JSON[_0x41cb('0x11')](_0x37c859));if(_0x37c859[_0x41cb('0x12')]){if(_0x37c859['error'][_0x41cb('0x13')]===0x1f4){logger[_0x41cb('0x12')](_0x41cb('0xd'),_0xe98d5e,_0x37c859[_0x41cb('0x12')][_0x41cb('0x14')]);return _0x108fd(_0x37c859['error'][_0x41cb('0x14')]);}logger['error'](_0x41cb('0xd'),_0xe98d5e,_0x37c859['error'][_0x41cb('0x14')]);return _0x142669(_0x37c859['error'][_0x41cb('0x14')]);}else{logger['info'](_0x41cb('0xd'),_0xe98d5e,'request\x20sent');_0x142669(_0x37c859[_0x41cb('0x15')][_0x41cb('0x14')]);}})['catch'](function(_0x55d3fc){logger[_0x41cb('0x12')](_0x41cb('0xd'),_0xe98d5e,_0x55d3fc);_0x108fd(_0x55d3fc);});});}exports['UpdateOpenchannelApplication']=function(_0x34c35c){var _0x2fcf9d=this;return new Promise(function(_0x56bcd9,_0x5685f3){return db['OpenchannelApplication'][_0x41cb('0x16')](_0x34c35c[_0x41cb('0x17')],{'raw':_0x34c35c[_0x41cb('0x18')]?_0x34c35c[_0x41cb('0x18')][_0x41cb('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x34c35c[_0x41cb('0x18')]?_0x34c35c[_0x41cb('0x18')]['where']||null:null,'attributes':_0x34c35c[_0x41cb('0x18')]?_0x34c35c[_0x41cb('0x18')]['attributes']||null:null,'limit':_0x34c35c['options']?_0x34c35c['options']['limit']||null:null})[_0x41cb('0xc')](function(_0x55b44d){logger[_0x41cb('0x1a')](_0x41cb('0x1b'),_0x34c35c);logger[_0x41cb('0xf')]('UpdateOpenchannelApplication',_0x34c35c,JSON[_0x41cb('0x11')](_0x55b44d));_0x56bcd9(_0x55b44d);})['catch'](function(_0x2eed1b){logger['error']('UpdateOpenchannelApplication',_0x2eed1b[_0x41cb('0x14')],_0x34c35c);_0x5685f3(_0x2fcf9d[_0x41cb('0x12')](0x1f4,_0x2eed1b['message']));});});};