c419d552658198d039d59b402fbb8f3aec861549
[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 _0x3e99=['body','options','raw','attributes','limit','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','request','then','info','FaxApplication,\x20%s,\x20%s','request\x20sent','debug','FaxApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','UpdateFaxApplication','update'];(function(_0x10a781,_0x26dcd7){var _0x41d8ae=function(_0x14ad0c){while(--_0x14ad0c){_0x10a781['push'](_0x10a781['shift']());}};_0x41d8ae(++_0x26dcd7);}(_0x3e99,0xed));var _0x93e9=function(_0x4d2bee,_0x2960a6){_0x4d2bee=_0x4d2bee-0x0;var _0x22c9d6=_0x3e99[_0x4d2bee];return _0x22c9d6;};'use strict';var _=require('lodash');var util=require(_0x93e9('0x0'));var moment=require(_0x93e9('0x1'));var BPromise=require(_0x93e9('0x2'));var rs=require(_0x93e9('0x3'));var fs=require('fs');var Redis=require(_0x93e9('0x4'));var db=require(_0x93e9('0x5'))['db'];var utils=require(_0x93e9('0x6'));var logger=require(_0x93e9('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x93e9('0x8'));var client=jayson[_0x93e9('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x6ac8db,_0x34afdd,_0x3dd432){return new BPromise(function(_0x240dba,_0x4c5eba){return client[_0x93e9('0xa')](_0x6ac8db,_0x3dd432)[_0x93e9('0xb')](function(_0x55d4bc){logger[_0x93e9('0xc')](_0x93e9('0xd'),_0x34afdd,_0x93e9('0xe'));logger[_0x93e9('0xf')](_0x93e9('0x10'),_0x34afdd,'request\x20sent',JSON[_0x93e9('0x11')](_0x55d4bc));if(_0x55d4bc['error']){if(_0x55d4bc['error']['code']===0x1f4){logger[_0x93e9('0x12')](_0x93e9('0xd'),_0x34afdd,_0x55d4bc[_0x93e9('0x12')][_0x93e9('0x13')]);return _0x4c5eba(_0x55d4bc[_0x93e9('0x12')][_0x93e9('0x13')]);}logger[_0x93e9('0x12')](_0x93e9('0xd'),_0x34afdd,_0x55d4bc[_0x93e9('0x12')][_0x93e9('0x13')]);return _0x240dba(_0x55d4bc[_0x93e9('0x12')][_0x93e9('0x13')]);}else{logger[_0x93e9('0xc')]('FaxApplication,\x20%s,\x20%s',_0x34afdd,_0x93e9('0xe'));_0x240dba(_0x55d4bc[_0x93e9('0x14')][_0x93e9('0x13')]);}})[_0x93e9('0x15')](function(_0x6eed82){logger[_0x93e9('0x12')](_0x93e9('0xd'),_0x34afdd,_0x6eed82);_0x4c5eba(_0x6eed82);});});}exports[_0x93e9('0x16')]=function(_0x3ed72f){var _0x34bb6e=this;return new Promise(function(_0x2069b4,_0x402bd3){return db['FaxApplication'][_0x93e9('0x17')](_0x3ed72f[_0x93e9('0x18')],{'raw':_0x3ed72f[_0x93e9('0x19')]?_0x3ed72f['options'][_0x93e9('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3ed72f[_0x93e9('0x19')]?_0x3ed72f[_0x93e9('0x19')]['where']||null:null,'attributes':_0x3ed72f[_0x93e9('0x19')]?_0x3ed72f['options'][_0x93e9('0x1b')]||null:null,'limit':_0x3ed72f['options']?_0x3ed72f[_0x93e9('0x19')][_0x93e9('0x1c')]||null:null})['then'](function(_0x5f58ab){logger['info'](_0x93e9('0x16'),_0x3ed72f);logger[_0x93e9('0xf')]('UpdateFaxApplication',_0x3ed72f,JSON['stringify'](_0x5f58ab));_0x2069b4(_0x5f58ab);})['catch'](function(_0x213933){logger[_0x93e9('0x12')](_0x93e9('0x16'),_0x213933[_0x93e9('0x13')],_0x3ed72f);_0x402bd3(_0x34bb6e[_0x93e9('0x12')](0x1f4,_0x213933[_0x93e9('0x13')]));});});};