615384948c8c0d531a4f8897b15edf457c5be2e2
[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 _0x964c=['jayson/promise','client','http','request','then','SquareReport,\x20%s,\x20%s','request\x20sent','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','CreateSquareReport','SquareReport','create','options','debug','UpdateSquareReport','body','raw','attributes','lodash','util','randomstring','../../mysqldb','../../config/utils','../../config/environment'];(function(_0x9c7c77,_0x49751f){var _0x2fee9b=function(_0x54858d){while(--_0x54858d){_0x9c7c77['push'](_0x9c7c77['shift']());}};_0x2fee9b(++_0x49751f);}(_0x964c,0x108));var _0xc964=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x964c[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xc964('0x0'));var util=require(_0xc964('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xc964('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc964('0x3'))['db'];var utils=require(_0xc964('0x4'));var logger=require('../../config/logger')('rpc');var config=require(_0xc964('0x5'));var jayson=require(_0xc964('0x6'));var client=jayson[_0xc964('0x7')][_0xc964('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x481ba7,_0x4485eb,_0x11f57d){return new BPromise(function(_0x100c22,_0x5aed50){return client[_0xc964('0x9')](_0x481ba7,_0x11f57d)[_0xc964('0xa')](function(_0x38e81b){logger['info'](_0xc964('0xb'),_0x4485eb,_0xc964('0xc'));logger['debug'](_0xc964('0xd'),_0x4485eb,'request\x20sent',JSON[_0xc964('0xe')](_0x38e81b));if(_0x38e81b[_0xc964('0xf')]){if(_0x38e81b[_0xc964('0xf')][_0xc964('0x10')]===0x1f4){logger[_0xc964('0xf')]('SquareReport,\x20%s,\x20%s',_0x4485eb,_0x38e81b[_0xc964('0xf')]['message']);return _0x5aed50(_0x38e81b['error']['message']);}logger[_0xc964('0xf')]('SquareReport,\x20%s,\x20%s',_0x4485eb,_0x38e81b[_0xc964('0xf')][_0xc964('0x11')]);return _0x100c22(_0x38e81b['error']['message']);}else{logger[_0xc964('0x12')](_0xc964('0xb'),_0x4485eb,_0xc964('0xc'));_0x100c22(_0x38e81b[_0xc964('0x13')][_0xc964('0x11')]);}})[_0xc964('0x14')](function(_0x237cae){logger[_0xc964('0xf')](_0xc964('0xb'),_0x4485eb,_0x237cae);_0x5aed50(_0x237cae);});});}exports[_0xc964('0x15')]=function(_0x5da13d){var _0x4ff157=this;return new Promise(function(_0x58fe5c,_0x21cbea){return db[_0xc964('0x16')][_0xc964('0x17')](_0x5da13d['body'],{'raw':_0x5da13d['options']?_0x5da13d[_0xc964('0x18')]['raw']===undefined?!![]:![]:!![]})[_0xc964('0xa')](function(_0x5da215){logger[_0xc964('0x12')](_0xc964('0x15'),_0x5da13d);logger[_0xc964('0x19')](_0xc964('0x15'),_0x5da13d,JSON[_0xc964('0xe')](_0x5da215));_0x58fe5c(_0x5da215);})['catch'](function(_0x2b6ac2){logger['error'](_0xc964('0x15'),_0x2b6ac2[_0xc964('0x11')],_0x5da13d);_0x21cbea(_0x4ff157['error'](0x1f4,_0x2b6ac2['message']));});});};exports[_0xc964('0x1a')]=function(_0x422a2c){var _0xa03b4d=this;return new Promise(function(_0xec8af5,_0x44bd38){return db['SquareReport']['update'](_0x422a2c[_0xc964('0x1b')],{'raw':_0x422a2c[_0xc964('0x18')]?_0x422a2c[_0xc964('0x18')][_0xc964('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x422a2c[_0xc964('0x18')]?_0x422a2c['options']['where']||null:null,'attributes':_0x422a2c['options']?_0x422a2c[_0xc964('0x18')][_0xc964('0x1d')]||null:null,'limit':_0x422a2c[_0xc964('0x18')]?_0x422a2c[_0xc964('0x18')]['limit']||null:null})[_0xc964('0xa')](function(_0x48e037){logger[_0xc964('0x12')]('UpdateSquareReport',_0x422a2c);logger[_0xc964('0x19')]('UpdateSquareReport',_0x422a2c,JSON[_0xc964('0xe')](_0x48e037));_0xec8af5(_0x48e037);})['catch'](function(_0x123fc7){logger[_0xc964('0xf')]('UpdateSquareReport',_0x123fc7[_0xc964('0x11')],_0x422a2c);_0x44bd38(_0xa03b4d[_0xc964('0xf')](0x1f4,_0x123fc7[_0xc964('0x11')]));});});};