6bf0e838b0443728a279626d46035a7856163e49
[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 _0xa266=['stringify','error','code','message','info','result','catch','UpdateFaxApplication','update','body','options','raw','where','limit','then','debug','lodash','util','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','request','FaxApplication,\x20%s,\x20%s','request\x20sent','FaxApplication,\x20%s,\x20%s,\x20%s'];(function(_0x24d5b5,_0x383522){var _0x39a57d=function(_0x1c5aa0){while(--_0x1c5aa0){_0x24d5b5['push'](_0x24d5b5['shift']());}};_0x39a57d(++_0x383522);}(_0xa266,0xdb));var _0x6a26=function(_0xf26d40,_0x2f4f46){_0xf26d40=_0xf26d40-0x0;var _0x50b68c=_0xa266[_0xf26d40];return _0x50b68c;};'use strict';var _=require(_0x6a26('0x0'));var util=require(_0x6a26('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6a26('0x2'));var db=require(_0x6a26('0x3'))['db'];var utils=require(_0x6a26('0x4'));var logger=require('../../config/logger')(_0x6a26('0x5'));var config=require(_0x6a26('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x6a26('0x7')][_0x6a26('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x4c7a67,_0x55000f,_0x2fab35){return new BPromise(function(_0x4b8b0c,_0x58fc71){return client[_0x6a26('0x9')](_0x4c7a67,_0x2fab35)['then'](function(_0x1ec5fb){logger['info'](_0x6a26('0xa'),_0x55000f,_0x6a26('0xb'));logger['debug'](_0x6a26('0xc'),_0x55000f,_0x6a26('0xb'),JSON[_0x6a26('0xd')](_0x1ec5fb));if(_0x1ec5fb[_0x6a26('0xe')]){if(_0x1ec5fb[_0x6a26('0xe')][_0x6a26('0xf')]===0x1f4){logger[_0x6a26('0xe')]('FaxApplication,\x20%s,\x20%s',_0x55000f,_0x1ec5fb[_0x6a26('0xe')][_0x6a26('0x10')]);return _0x58fc71(_0x1ec5fb[_0x6a26('0xe')][_0x6a26('0x10')]);}logger[_0x6a26('0xe')](_0x6a26('0xa'),_0x55000f,_0x1ec5fb['error'][_0x6a26('0x10')]);return _0x4b8b0c(_0x1ec5fb[_0x6a26('0xe')][_0x6a26('0x10')]);}else{logger[_0x6a26('0x11')](_0x6a26('0xa'),_0x55000f,'request\x20sent');_0x4b8b0c(_0x1ec5fb[_0x6a26('0x12')]['message']);}})[_0x6a26('0x13')](function(_0x2223c9){logger[_0x6a26('0xe')](_0x6a26('0xa'),_0x55000f,_0x2223c9);_0x58fc71(_0x2223c9);});});}exports[_0x6a26('0x14')]=function(_0x50c68e){var _0x51a550=this;return new Promise(function(_0x2b5004,_0x2a1697){return db['FaxApplication'][_0x6a26('0x15')](_0x50c68e[_0x6a26('0x16')],{'raw':_0x50c68e[_0x6a26('0x17')]?_0x50c68e[_0x6a26('0x17')][_0x6a26('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x50c68e['options']?_0x50c68e['options'][_0x6a26('0x19')]||null:null,'attributes':_0x50c68e['options']?_0x50c68e[_0x6a26('0x17')]['attributes']||null:null,'limit':_0x50c68e['options']?_0x50c68e[_0x6a26('0x17')][_0x6a26('0x1a')]||null:null})[_0x6a26('0x1b')](function(_0x187ddb){logger[_0x6a26('0x11')]('UpdateFaxApplication',_0x50c68e);logger[_0x6a26('0x1c')](_0x6a26('0x14'),_0x50c68e,JSON[_0x6a26('0xd')](_0x187ddb));_0x2b5004(_0x187ddb);})['catch'](function(_0x13b48f){logger[_0x6a26('0xe')](_0x6a26('0x14'),_0x13b48f[_0x6a26('0x10')],_0x50c68e);_0x2a1697(_0x51a550[_0x6a26('0xe')](0x1f4,_0x13b48f[_0x6a26('0x10')]));});});};