2f1876325459c329c0dcde0fe1d2295e76c42e5c
[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 _0x8e82=['../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','request','info','FaxApplication,\x20%s,\x20%s','request\x20sent','debug','FaxApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','UpdateFaxApplication','FaxApplication','update','body','options','raw','where','limit','then','lodash','util','moment','randomstring'];(function(_0x1ad1be,_0x440ad){var _0x279e73=function(_0x4292f3){while(--_0x4292f3){_0x1ad1be['push'](_0x1ad1be['shift']());}};_0x279e73(++_0x440ad);}(_0x8e82,0xb0));var _0x28e8=function(_0x55f15e,_0x2fa3ac){_0x55f15e=_0x55f15e-0x0;var _0x21d019=_0x8e82[_0x55f15e];return _0x21d019;};'use strict';var _=require(_0x28e8('0x0'));var util=require(_0x28e8('0x1'));var moment=require(_0x28e8('0x2'));var BPromise=require('bluebird');var rs=require(_0x28e8('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x28e8('0x4'))['db'];var utils=require(_0x28e8('0x5'));var logger=require(_0x28e8('0x6'))(_0x28e8('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x28e8('0x8')][_0x28e8('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x555c5d,_0x2696bd,_0x336041){return new BPromise(function(_0x23acf5,_0x43d28e){return client[_0x28e8('0xa')](_0x555c5d,_0x336041)['then'](function(_0x3145b4){logger[_0x28e8('0xb')](_0x28e8('0xc'),_0x2696bd,_0x28e8('0xd'));logger[_0x28e8('0xe')](_0x28e8('0xf'),_0x2696bd,_0x28e8('0xd'),JSON[_0x28e8('0x10')](_0x3145b4));if(_0x3145b4[_0x28e8('0x11')]){if(_0x3145b4[_0x28e8('0x11')]['code']===0x1f4){logger['error'](_0x28e8('0xc'),_0x2696bd,_0x3145b4[_0x28e8('0x11')]['message']);return _0x43d28e(_0x3145b4[_0x28e8('0x11')][_0x28e8('0x12')]);}logger[_0x28e8('0x11')](_0x28e8('0xc'),_0x2696bd,_0x3145b4[_0x28e8('0x11')][_0x28e8('0x12')]);return _0x23acf5(_0x3145b4['error'][_0x28e8('0x12')]);}else{logger[_0x28e8('0xb')](_0x28e8('0xc'),_0x2696bd,_0x28e8('0xd'));_0x23acf5(_0x3145b4[_0x28e8('0x13')][_0x28e8('0x12')]);}})[_0x28e8('0x14')](function(_0x230ad0){logger[_0x28e8('0x11')](_0x28e8('0xc'),_0x2696bd,_0x230ad0);_0x43d28e(_0x230ad0);});});}exports[_0x28e8('0x15')]=function(_0x1064f8){var _0x2eb23c=this;return new Promise(function(_0x31d4ad,_0x5d996f){return db[_0x28e8('0x16')][_0x28e8('0x17')](_0x1064f8[_0x28e8('0x18')],{'raw':_0x1064f8[_0x28e8('0x19')]?_0x1064f8['options'][_0x28e8('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1064f8['options']?_0x1064f8[_0x28e8('0x19')][_0x28e8('0x1b')]||null:null,'attributes':_0x1064f8['options']?_0x1064f8[_0x28e8('0x19')]['attributes']||null:null,'limit':_0x1064f8['options']?_0x1064f8[_0x28e8('0x19')][_0x28e8('0x1c')]||null:null})[_0x28e8('0x1d')](function(_0x999094){logger[_0x28e8('0xb')](_0x28e8('0x15'),_0x1064f8);logger[_0x28e8('0xe')]('UpdateFaxApplication',_0x1064f8,JSON['stringify'](_0x999094));_0x31d4ad(_0x999094);})['catch'](function(_0x4fcaa6){logger['error'](_0x28e8('0x15'),_0x4fcaa6['message'],_0x1064f8);_0x5d996f(_0x2eb23c['error'](0x1f4,_0x4fcaa6[_0x28e8('0x12')]));});});};