06f02a473208605cc95452bc9dbc6aa61431662e
[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 _0x28cf=['info','FaxApplication,\x20%s,\x20%s','debug','FaxApplication,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','catch','UpdateFaxApplication','update','body','options','raw','where','limit','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then'];(function(_0x5b818e,_0x4200d9){var _0x1d689f=function(_0x7c3799){while(--_0x7c3799){_0x5b818e['push'](_0x5b818e['shift']());}};_0x1d689f(++_0x4200d9);}(_0x28cf,0x165));var _0xf28c=function(_0x3de061,_0xfa3361){_0x3de061=_0x3de061-0x0;var _0x5c6ffe=_0x28cf[_0x3de061];return _0x5c6ffe;};'use strict';var _=require('lodash');var util=require(_0xf28c('0x0'));var moment=require(_0xf28c('0x1'));var BPromise=require(_0xf28c('0x2'));var rs=require(_0xf28c('0x3'));var fs=require('fs');var Redis=require(_0xf28c('0x4'));var db=require(_0xf28c('0x5'))['db'];var utils=require(_0xf28c('0x6'));var logger=require(_0xf28c('0x7'))(_0xf28c('0x8'));var config=require(_0xf28c('0x9'));var jayson=require(_0xf28c('0xa'));var client=jayson[_0xf28c('0xb')][_0xf28c('0xc')]({'port':0x232a});function respondWithRpcPromise(_0xe65589,_0x3faaea,_0x5cfc06){return new BPromise(function(_0x51027b,_0x4f2dc6){return client[_0xf28c('0xd')](_0xe65589,_0x5cfc06)[_0xf28c('0xe')](function(_0x9fd238){logger[_0xf28c('0xf')](_0xf28c('0x10'),_0x3faaea,'request\x20sent');logger[_0xf28c('0x11')](_0xf28c('0x12'),_0x3faaea,_0xf28c('0x13'),JSON['stringify'](_0x9fd238));if(_0x9fd238[_0xf28c('0x14')]){if(_0x9fd238[_0xf28c('0x14')]['code']===0x1f4){logger['error'](_0xf28c('0x10'),_0x3faaea,_0x9fd238[_0xf28c('0x14')][_0xf28c('0x15')]);return _0x4f2dc6(_0x9fd238[_0xf28c('0x14')][_0xf28c('0x15')]);}logger[_0xf28c('0x14')](_0xf28c('0x10'),_0x3faaea,_0x9fd238[_0xf28c('0x14')][_0xf28c('0x15')]);return _0x51027b(_0x9fd238['error'][_0xf28c('0x15')]);}else{logger[_0xf28c('0xf')](_0xf28c('0x10'),_0x3faaea,'request\x20sent');_0x51027b(_0x9fd238[_0xf28c('0x16')][_0xf28c('0x15')]);}})[_0xf28c('0x17')](function(_0x4ed5c9){logger[_0xf28c('0x14')]('FaxApplication,\x20%s,\x20%s',_0x3faaea,_0x4ed5c9);_0x4f2dc6(_0x4ed5c9);});});}exports[_0xf28c('0x18')]=function(_0xeea8f9){var _0x3b0166=this;return new Promise(function(_0x3d6e68,_0x17719a){return db['FaxApplication'][_0xf28c('0x19')](_0xeea8f9[_0xf28c('0x1a')],{'raw':_0xeea8f9[_0xf28c('0x1b')]?_0xeea8f9[_0xf28c('0x1b')][_0xf28c('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xeea8f9[_0xf28c('0x1b')]?_0xeea8f9['options'][_0xf28c('0x1d')]||null:null,'attributes':_0xeea8f9[_0xf28c('0x1b')]?_0xeea8f9[_0xf28c('0x1b')]['attributes']||null:null,'limit':_0xeea8f9[_0xf28c('0x1b')]?_0xeea8f9[_0xf28c('0x1b')][_0xf28c('0x1e')]||null:null})['then'](function(_0x219ea0){logger['info'](_0xf28c('0x18'),_0xeea8f9);logger[_0xf28c('0x11')]('UpdateFaxApplication',_0xeea8f9,JSON['stringify'](_0x219ea0));_0x3d6e68(_0x219ea0);})[_0xf28c('0x17')](function(_0x4da866){logger[_0xf28c('0x14')](_0xf28c('0x18'),_0x4da866['message'],_0xeea8f9);_0x17719a(_0x3b0166[_0xf28c('0x14')](0x1f4,_0x4da866['message']));});});};