fa28cf00dbf3b70660692a5da6123325827b7307
[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 _0x991b=['jayson/promise','client','http','request','then','OpenchannelApplication,\x20%s,\x20%s','request\x20sent','error','code','message','info','result','UpdateOpenchannelApplication','OpenchannelApplication','body','options','raw','attributes','limit','debug','stringify','catch','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x23e393,_0xb339cb){var _0x623dd2=function(_0x58a8a6){while(--_0x58a8a6){_0x23e393['push'](_0x23e393['shift']());}};_0x623dd2(++_0xb339cb);}(_0x991b,0x1c8));var _0xb991=function(_0x3120ee,_0x3d5335){_0x3120ee=_0x3120ee-0x0;var _0x572249=_0x991b[_0x3120ee];return _0x572249;};'use strict';var _=require(_0xb991('0x0'));var util=require('util');var moment=require(_0xb991('0x1'));var BPromise=require(_0xb991('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb991('0x3'));var db=require(_0xb991('0x4'))['db'];var utils=require(_0xb991('0x5'));var logger=require(_0xb991('0x6'))(_0xb991('0x7'));var config=require(_0xb991('0x8'));var jayson=require(_0xb991('0x9'));var client=jayson[_0xb991('0xa')][_0xb991('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x412b38,_0x3d1e84,_0x41c6b){return new BPromise(function(_0x27dbc8,_0x18bcca){return client[_0xb991('0xc')](_0x412b38,_0x41c6b)[_0xb991('0xd')](function(_0x29cd3d){logger['info'](_0xb991('0xe'),_0x3d1e84,'request\x20sent');logger['debug']('OpenchannelApplication,\x20%s,\x20%s,\x20%s',_0x3d1e84,_0xb991('0xf'),JSON['stringify'](_0x29cd3d));if(_0x29cd3d[_0xb991('0x10')]){if(_0x29cd3d[_0xb991('0x10')][_0xb991('0x11')]===0x1f4){logger['error'](_0xb991('0xe'),_0x3d1e84,_0x29cd3d[_0xb991('0x10')][_0xb991('0x12')]);return _0x18bcca(_0x29cd3d[_0xb991('0x10')]['message']);}logger[_0xb991('0x10')](_0xb991('0xe'),_0x3d1e84,_0x29cd3d[_0xb991('0x10')][_0xb991('0x12')]);return _0x27dbc8(_0x29cd3d[_0xb991('0x10')][_0xb991('0x12')]);}else{logger[_0xb991('0x13')](_0xb991('0xe'),_0x3d1e84,'request\x20sent');_0x27dbc8(_0x29cd3d[_0xb991('0x14')][_0xb991('0x12')]);}})['catch'](function(_0x54bb53){logger[_0xb991('0x10')](_0xb991('0xe'),_0x3d1e84,_0x54bb53);_0x18bcca(_0x54bb53);});});}exports[_0xb991('0x15')]=function(_0x248abc){var _0xc2f54=this;return new Promise(function(_0x513381,_0x3902d3){return db[_0xb991('0x16')]['update'](_0x248abc[_0xb991('0x17')],{'raw':_0x248abc[_0xb991('0x18')]?_0x248abc[_0xb991('0x18')][_0xb991('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x248abc['options']?_0x248abc[_0xb991('0x18')]['where']||null:null,'attributes':_0x248abc[_0xb991('0x18')]?_0x248abc['options'][_0xb991('0x1a')]||null:null,'limit':_0x248abc[_0xb991('0x18')]?_0x248abc[_0xb991('0x18')][_0xb991('0x1b')]||null:null})[_0xb991('0xd')](function(_0x579f13){logger[_0xb991('0x13')](_0xb991('0x15'),_0x248abc);logger[_0xb991('0x1c')](_0xb991('0x15'),_0x248abc,JSON[_0xb991('0x1d')](_0x579f13));_0x513381(_0x579f13);})[_0xb991('0x1e')](function(_0x4e7210){logger[_0xb991('0x10')](_0xb991('0x15'),_0x4e7210['message'],_0x248abc);_0x3902d3(_0xc2f54[_0xb991('0x10')](0x1f4,_0x4e7210[_0xb991('0x12')]));});});};