1fccece26a5c203335e3d2f2234a32ce11740636
[motion2.git] / server / api / faxApplication / faxApplication.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 _0x41ea=['code','FaxApplication,\x20%s,\x20%s','message','result','catch','UpdateFaxApplication','update','body','options','raw','limit','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','http','request','then','debug','FaxApplication,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error'];(function(_0x21446b,_0x3e539e){var _0xfe74d4=function(_0x1833c7){while(--_0x1833c7){_0x21446b['push'](_0x21446b['shift']());}};_0xfe74d4(++_0x3e539e);}(_0x41ea,0x97));var _0xa41e=function(_0x39cc46,_0x28b341){_0x39cc46=_0x39cc46-0x0;var _0x2b7db5=_0x41ea[_0x39cc46];return _0x2b7db5;};'use strict';var _=require(_0xa41e('0x0'));var util=require(_0xa41e('0x1'));var moment=require('moment');var BPromise=require(_0xa41e('0x2'));var rs=require(_0xa41e('0x3'));var fs=require('fs');var Redis=require(_0xa41e('0x4'));var db=require(_0xa41e('0x5'))['db'];var utils=require(_0xa41e('0x6'));var logger=require(_0xa41e('0x7'))(_0xa41e('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xa41e('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2c62c6,_0x3b01f3,_0x11c0a3){return new BPromise(function(_0x4d3faa,_0x5ce92a){return client[_0xa41e('0xa')](_0x2c62c6,_0x11c0a3)[_0xa41e('0xb')](function(_0x2dbce9){logger['info']('FaxApplication,\x20%s,\x20%s',_0x3b01f3,'request\x20sent');logger[_0xa41e('0xc')](_0xa41e('0xd'),_0x3b01f3,_0xa41e('0xe'),JSON[_0xa41e('0xf')](_0x2dbce9));if(_0x2dbce9[_0xa41e('0x10')]){if(_0x2dbce9[_0xa41e('0x10')][_0xa41e('0x11')]===0x1f4){logger['error'](_0xa41e('0x12'),_0x3b01f3,_0x2dbce9[_0xa41e('0x10')][_0xa41e('0x13')]);return _0x5ce92a(_0x2dbce9[_0xa41e('0x10')][_0xa41e('0x13')]);}logger[_0xa41e('0x10')]('FaxApplication,\x20%s,\x20%s',_0x3b01f3,_0x2dbce9[_0xa41e('0x10')][_0xa41e('0x13')]);return _0x4d3faa(_0x2dbce9[_0xa41e('0x10')][_0xa41e('0x13')]);}else{logger['info']('FaxApplication,\x20%s,\x20%s',_0x3b01f3,'request\x20sent');_0x4d3faa(_0x2dbce9[_0xa41e('0x14')][_0xa41e('0x13')]);}})[_0xa41e('0x15')](function(_0x11b269){logger[_0xa41e('0x10')](_0xa41e('0x12'),_0x3b01f3,_0x11b269);_0x5ce92a(_0x11b269);});});}exports[_0xa41e('0x16')]=function(_0x344b94){var _0x5e40d6=this;return new Promise(function(_0x21b7cf,_0x2253b0){return db['FaxApplication'][_0xa41e('0x17')](_0x344b94[_0xa41e('0x18')],{'raw':_0x344b94['options']?_0x344b94[_0xa41e('0x19')][_0xa41e('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x344b94[_0xa41e('0x19')]?_0x344b94['options']['where']||null:null,'attributes':_0x344b94[_0xa41e('0x19')]?_0x344b94[_0xa41e('0x19')]['attributes']||null:null,'limit':_0x344b94[_0xa41e('0x19')]?_0x344b94[_0xa41e('0x19')][_0xa41e('0x1b')]||null:null})['then'](function(_0x24eb51){logger['info'](_0xa41e('0x16'),_0x344b94);logger[_0xa41e('0xc')](_0xa41e('0x16'),_0x344b94,JSON[_0xa41e('0xf')](_0x24eb51));_0x21b7cf(_0x24eb51);})['catch'](function(_0x3060ac){logger[_0xa41e('0x10')]('UpdateFaxApplication',_0x3060ac[_0xa41e('0x13')],_0x344b94);_0x2253b0(_0x5e40d6[_0xa41e('0x10')](0x1f4,_0x3060ac['message']));});});};