ad2cbba9da3c9353a7a0eee479fd409ff14cc82e
[motion2.git] / server / api / squareReport / squareReport.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 _0x69ca=['attributes','limit','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','http','request','then','SquareReport,\x20%s,\x20%s','SquareReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','info','result','CreateSquareReport','SquareReport','create','body','options','raw','debug','UpdateSquareReport'];(function(_0x133296,_0xe8ff9a){var _0x193517=function(_0x161ffd){while(--_0x161ffd){_0x133296['push'](_0x133296['shift']());}};_0x193517(++_0xe8ff9a);}(_0x69ca,0xfb));var _0xa69c=function(_0x1dc82c,_0x4f43eb){_0x1dc82c=_0x1dc82c-0x0;var _0x39b34a=_0x69ca[_0x1dc82c];return _0x39b34a;};'use strict';var _=require('lodash');var util=require(_0xa69c('0x0'));var moment=require(_0xa69c('0x1'));var BPromise=require(_0xa69c('0x2'));var rs=require(_0xa69c('0x3'));var fs=require('fs');var Redis=require(_0xa69c('0x4'));var db=require(_0xa69c('0x5'))['db'];var utils=require(_0xa69c('0x6'));var logger=require(_0xa69c('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0xa69c('0x8'));var client=jayson['client'][_0xa69c('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x130aef,_0x375164,_0x4e5af6){return new BPromise(function(_0x231592,_0x303ceb){return client[_0xa69c('0xa')](_0x130aef,_0x4e5af6)[_0xa69c('0xb')](function(_0x30e04c){logger['info'](_0xa69c('0xc'),_0x375164,'request\x20sent');logger['debug'](_0xa69c('0xd'),_0x375164,_0xa69c('0xe'),JSON[_0xa69c('0xf')](_0x30e04c));if(_0x30e04c[_0xa69c('0x10')]){if(_0x30e04c['error']['code']===0x1f4){logger[_0xa69c('0x10')](_0xa69c('0xc'),_0x375164,_0x30e04c[_0xa69c('0x10')]['message']);return _0x303ceb(_0x30e04c[_0xa69c('0x10')][_0xa69c('0x11')]);}logger[_0xa69c('0x10')]('SquareReport,\x20%s,\x20%s',_0x375164,_0x30e04c[_0xa69c('0x10')][_0xa69c('0x11')]);return _0x231592(_0x30e04c[_0xa69c('0x10')][_0xa69c('0x11')]);}else{logger[_0xa69c('0x12')]('SquareReport,\x20%s,\x20%s',_0x375164,_0xa69c('0xe'));_0x231592(_0x30e04c[_0xa69c('0x13')][_0xa69c('0x11')]);}})['catch'](function(_0x835181){logger['error'](_0xa69c('0xc'),_0x375164,_0x835181);_0x303ceb(_0x835181);});});}exports[_0xa69c('0x14')]=function(_0x2bf801){var _0x2328bc=this;return new Promise(function(_0x117d7d,_0x194213){return db[_0xa69c('0x15')][_0xa69c('0x16')](_0x2bf801[_0xa69c('0x17')],{'raw':_0x2bf801[_0xa69c('0x18')]?_0x2bf801[_0xa69c('0x18')][_0xa69c('0x19')]===undefined?!![]:![]:!![]})[_0xa69c('0xb')](function(_0x1960c3){logger[_0xa69c('0x12')](_0xa69c('0x14'),_0x2bf801);logger[_0xa69c('0x1a')](_0xa69c('0x14'),_0x2bf801,JSON[_0xa69c('0xf')](_0x1960c3));_0x117d7d(_0x1960c3);})['catch'](function(_0x5f16b8){logger[_0xa69c('0x10')](_0xa69c('0x14'),_0x5f16b8[_0xa69c('0x11')],_0x2bf801);_0x194213(_0x2328bc['error'](0x1f4,_0x5f16b8['message']));});});};exports[_0xa69c('0x1b')]=function(_0x52c226){var _0x14e6fc=this;return new Promise(function(_0x16e011,_0x46dc55){return db[_0xa69c('0x15')]['update'](_0x52c226['body'],{'raw':_0x52c226[_0xa69c('0x18')]?_0x52c226[_0xa69c('0x18')][_0xa69c('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x52c226[_0xa69c('0x18')]?_0x52c226[_0xa69c('0x18')]['where']||null:null,'attributes':_0x52c226['options']?_0x52c226[_0xa69c('0x18')][_0xa69c('0x1c')]||null:null,'limit':_0x52c226[_0xa69c('0x18')]?_0x52c226[_0xa69c('0x18')][_0xa69c('0x1d')]||null:null})[_0xa69c('0xb')](function(_0x35b624){logger[_0xa69c('0x12')](_0xa69c('0x1b'),_0x52c226);logger['debug']('UpdateSquareReport',_0x52c226,JSON['stringify'](_0x35b624));_0x16e011(_0x35b624);})[_0xa69c('0x1e')](function(_0x5616ca){logger['error'](_0xa69c('0x1b'),_0x5616ca[_0xa69c('0x11')],_0x52c226);_0x46dc55(_0x14e6fc[_0xa69c('0x10')](0x1f4,_0x5616ca[_0xa69c('0x11')]));});});};