b28c7bf01de576469e7b5221a2636f2fb1db4a40
[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 _0x4bfa=['bluebird','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','request','then','OpenchannelApplication,\x20%s,\x20%s','request\x20sent','debug','OpenchannelApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','update','body','options','raw','where','attributes','info','UpdateOpenchannelApplication','lodash'];(function(_0x4c1ec2,_0x4f42b7){var _0x3f6f1c=function(_0xc82652){while(--_0xc82652){_0x4c1ec2['push'](_0x4c1ec2['shift']());}};_0x3f6f1c(++_0x4f42b7);}(_0x4bfa,0x14f));var _0xa4bf=function(_0x452791,_0x1c20df){_0x452791=_0x452791-0x0;var _0x459acf=_0x4bfa[_0x452791];return _0x459acf;};'use strict';var _=require(_0xa4bf('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xa4bf('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa4bf('0x2'));var db=require(_0xa4bf('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xa4bf('0x4'));var config=require(_0xa4bf('0x5'));var jayson=require(_0xa4bf('0x6'));var client=jayson[_0xa4bf('0x7')][_0xa4bf('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x44f475,_0x483c62,_0x7e85af){return new BPromise(function(_0x27b336,_0xae1617){return client[_0xa4bf('0x9')](_0x44f475,_0x7e85af)[_0xa4bf('0xa')](function(_0x23bb5d){logger['info'](_0xa4bf('0xb'),_0x483c62,_0xa4bf('0xc'));logger[_0xa4bf('0xd')](_0xa4bf('0xe'),_0x483c62,_0xa4bf('0xc'),JSON[_0xa4bf('0xf')](_0x23bb5d));if(_0x23bb5d[_0xa4bf('0x10')]){if(_0x23bb5d[_0xa4bf('0x10')][_0xa4bf('0x11')]===0x1f4){logger[_0xa4bf('0x10')](_0xa4bf('0xb'),_0x483c62,_0x23bb5d[_0xa4bf('0x10')][_0xa4bf('0x12')]);return _0xae1617(_0x23bb5d[_0xa4bf('0x10')][_0xa4bf('0x12')]);}logger[_0xa4bf('0x10')](_0xa4bf('0xb'),_0x483c62,_0x23bb5d[_0xa4bf('0x10')][_0xa4bf('0x12')]);return _0x27b336(_0x23bb5d['error']['message']);}else{logger['info']('OpenchannelApplication,\x20%s,\x20%s',_0x483c62,'request\x20sent');_0x27b336(_0x23bb5d['result'][_0xa4bf('0x12')]);}})[_0xa4bf('0x13')](function(_0x47e744){logger['error'](_0xa4bf('0xb'),_0x483c62,_0x47e744);_0xae1617(_0x47e744);});});}exports['UpdateOpenchannelApplication']=function(_0x2d4e51){var _0x505b1d=this;return new Promise(function(_0x4258b7,_0x48d81e){return db['OpenchannelApplication'][_0xa4bf('0x14')](_0x2d4e51[_0xa4bf('0x15')],{'raw':_0x2d4e51[_0xa4bf('0x16')]?_0x2d4e51[_0xa4bf('0x16')][_0xa4bf('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2d4e51[_0xa4bf('0x16')]?_0x2d4e51[_0xa4bf('0x16')][_0xa4bf('0x18')]||null:null,'attributes':_0x2d4e51[_0xa4bf('0x16')]?_0x2d4e51[_0xa4bf('0x16')][_0xa4bf('0x19')]||null:null,'limit':_0x2d4e51[_0xa4bf('0x16')]?_0x2d4e51['options']['limit']||null:null})[_0xa4bf('0xa')](function(_0x13aeaa){logger[_0xa4bf('0x1a')]('UpdateOpenchannelApplication',_0x2d4e51);logger[_0xa4bf('0xd')]('UpdateOpenchannelApplication',_0x2d4e51,JSON[_0xa4bf('0xf')](_0x13aeaa));_0x4258b7(_0x13aeaa);})[_0xa4bf('0x13')](function(_0x1a06ca){logger[_0xa4bf('0x10')](_0xa4bf('0x1b'),_0x1a06ca[_0xa4bf('0x12')],_0x2d4e51);_0x48d81e(_0x505b1d[_0xa4bf('0x10')](0x1f4,_0x1a06ca['message']));});});};