c3caee39c02fb2e3ba754e9716f24db61e878adf
[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 _0x99f9=['CreateSquareReport','SquareReport','create','body','options','raw','UpdateSquareReport','update','where','attributes','limit','then','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','info','SquareReport,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch'];(function(_0x299908,_0xadc128){var _0x22dc34=function(_0x53413b){while(--_0x53413b){_0x299908['push'](_0x299908['shift']());}};_0x22dc34(++_0xadc128);}(_0x99f9,0x88));var _0x999f=function(_0x774895,_0x441885){_0x774895=_0x774895-0x0;var _0x56c0bb=_0x99f9[_0x774895];return _0x56c0bb;};'use strict';var _=require(_0x999f('0x0'));var util=require(_0x999f('0x1'));var moment=require(_0x999f('0x2'));var BPromise=require('bluebird');var rs=require(_0x999f('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x999f('0x4'))['db'];var utils=require(_0x999f('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x999f('0x6'));var jayson=require(_0x999f('0x7'));var client=jayson[_0x999f('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2994d0,_0x543ba7,_0x195711){return new BPromise(function(_0x33b87d,_0xb13c54){return client['request'](_0x2994d0,_0x195711)['then'](function(_0x1e05fd){logger[_0x999f('0x9')](_0x999f('0xa'),_0x543ba7,_0x999f('0xb'));logger[_0x999f('0xc')]('SquareReport,\x20%s,\x20%s,\x20%s',_0x543ba7,_0x999f('0xb'),JSON[_0x999f('0xd')](_0x1e05fd));if(_0x1e05fd[_0x999f('0xe')]){if(_0x1e05fd[_0x999f('0xe')][_0x999f('0xf')]===0x1f4){logger[_0x999f('0xe')]('SquareReport,\x20%s,\x20%s',_0x543ba7,_0x1e05fd[_0x999f('0xe')]['message']);return _0xb13c54(_0x1e05fd[_0x999f('0xe')][_0x999f('0x10')]);}logger[_0x999f('0xe')]('SquareReport,\x20%s,\x20%s',_0x543ba7,_0x1e05fd[_0x999f('0xe')][_0x999f('0x10')]);return _0x33b87d(_0x1e05fd['error'][_0x999f('0x10')]);}else{logger['info'](_0x999f('0xa'),_0x543ba7,_0x999f('0xb'));_0x33b87d(_0x1e05fd[_0x999f('0x11')][_0x999f('0x10')]);}})[_0x999f('0x12')](function(_0x6037c6){logger[_0x999f('0xe')](_0x999f('0xa'),_0x543ba7,_0x6037c6);_0xb13c54(_0x6037c6);});});}exports[_0x999f('0x13')]=function(_0x165add){var _0x241341=this;return new Promise(function(_0x9e07b,_0x52b60e){return db[_0x999f('0x14')][_0x999f('0x15')](_0x165add[_0x999f('0x16')],{'raw':_0x165add[_0x999f('0x17')]?_0x165add[_0x999f('0x17')][_0x999f('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x4e841f){logger[_0x999f('0x9')](_0x999f('0x13'),_0x165add);logger[_0x999f('0xc')](_0x999f('0x13'),_0x165add,JSON['stringify'](_0x4e841f));_0x9e07b(_0x4e841f);})[_0x999f('0x12')](function(_0x4823a4){logger['error']('CreateSquareReport',_0x4823a4[_0x999f('0x10')],_0x165add);_0x52b60e(_0x241341[_0x999f('0xe')](0x1f4,_0x4823a4[_0x999f('0x10')]));});});};exports[_0x999f('0x19')]=function(_0x2ea2c5){var _0x233ba7=this;return new Promise(function(_0x31cee0,_0x32eb60){return db[_0x999f('0x14')][_0x999f('0x1a')](_0x2ea2c5[_0x999f('0x16')],{'raw':_0x2ea2c5[_0x999f('0x17')]?_0x2ea2c5[_0x999f('0x17')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2ea2c5['options']?_0x2ea2c5[_0x999f('0x17')][_0x999f('0x1b')]||null:null,'attributes':_0x2ea2c5[_0x999f('0x17')]?_0x2ea2c5['options'][_0x999f('0x1c')]||null:null,'limit':_0x2ea2c5['options']?_0x2ea2c5[_0x999f('0x17')][_0x999f('0x1d')]||null:null})[_0x999f('0x1e')](function(_0x434da9){logger[_0x999f('0x9')](_0x999f('0x19'),_0x2ea2c5);logger['debug']('UpdateSquareReport',_0x2ea2c5,JSON['stringify'](_0x434da9));_0x31cee0(_0x434da9);})[_0x999f('0x12')](function(_0x13837d){logger['error'](_0x999f('0x19'),_0x13837d[_0x999f('0x10')],_0x2ea2c5);_0x32eb60(_0x233ba7['error'](0x1f4,_0x13837d[_0x999f('0x10')]));});});};