Built motion from commit f7863d46.|2.5.41
[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 _0x734a=['randomstring','ioredis','../../config/utils','rpc','../../config/environment','request','then','info','SquareReport,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','SquareReport','create','raw','CreateSquareReport','catch','update','body','options','where','limit','UpdateSquareReport','util','moment'];(function(_0x3e85cd,_0x453310){var _0x440ba1=function(_0x37c588){while(--_0x37c588){_0x3e85cd['push'](_0x3e85cd['shift']());}};_0x440ba1(++_0x453310);}(_0x734a,0xa6));var _0xa734=function(_0x4f2c3a,_0x6bde90){_0x4f2c3a=_0x4f2c3a-0x0;var _0x17d91c=_0x734a[_0x4f2c3a];return _0x17d91c;};'use strict';var _=require('lodash');var util=require(_0xa734('0x0'));var moment=require(_0xa734('0x1'));var BPromise=require('bluebird');var rs=require(_0xa734('0x2'));var fs=require('fs');var Redis=require(_0xa734('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xa734('0x4'));var logger=require('../../config/logger')(_0xa734('0x5'));var config=require(_0xa734('0x6'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x224b60,_0xa91c86,_0x2c4ef1){return new BPromise(function(_0x4cb362,_0x41949e){return client[_0xa734('0x7')](_0x224b60,_0x2c4ef1)[_0xa734('0x8')](function(_0xa02135){logger[_0xa734('0x9')](_0xa734('0xa'),_0xa91c86,_0xa734('0xb'));logger['debug']('SquareReport,\x20%s,\x20%s,\x20%s',_0xa91c86,_0xa734('0xb'),JSON[_0xa734('0xc')](_0xa02135));if(_0xa02135[_0xa734('0xd')]){if(_0xa02135['error'][_0xa734('0xe')]===0x1f4){logger['error']('SquareReport,\x20%s,\x20%s',_0xa91c86,_0xa02135[_0xa734('0xd')][_0xa734('0xf')]);return _0x41949e(_0xa02135[_0xa734('0xd')][_0xa734('0xf')]);}logger[_0xa734('0xd')](_0xa734('0xa'),_0xa91c86,_0xa02135[_0xa734('0xd')]['message']);return _0x4cb362(_0xa02135['error'][_0xa734('0xf')]);}else{logger['info'](_0xa734('0xa'),_0xa91c86,'request\x20sent');_0x4cb362(_0xa02135[_0xa734('0x10')][_0xa734('0xf')]);}})['catch'](function(_0x25af1e){logger[_0xa734('0xd')]('SquareReport,\x20%s,\x20%s',_0xa91c86,_0x25af1e);_0x41949e(_0x25af1e);});});}exports['CreateSquareReport']=function(_0x583a6e){var _0x307f78=this;return new Promise(function(_0x123698,_0x59f355){return db[_0xa734('0x11')][_0xa734('0x12')](_0x583a6e['body'],{'raw':_0x583a6e['options']?_0x583a6e['options'][_0xa734('0x13')]===undefined?!![]:![]:!![]})[_0xa734('0x8')](function(_0x4514e4){logger[_0xa734('0x9')](_0xa734('0x14'),_0x583a6e);logger['debug'](_0xa734('0x14'),_0x583a6e,JSON['stringify'](_0x4514e4));_0x123698(_0x4514e4);})[_0xa734('0x15')](function(_0x4a5b2d){logger['error'](_0xa734('0x14'),_0x4a5b2d['message'],_0x583a6e);_0x59f355(_0x307f78[_0xa734('0xd')](0x1f4,_0x4a5b2d[_0xa734('0xf')]));});});};exports['UpdateSquareReport']=function(_0x2e2972){var _0x8889e4=this;return new Promise(function(_0x1728c6,_0x57305a){return db['SquareReport'][_0xa734('0x16')](_0x2e2972[_0xa734('0x17')],{'raw':_0x2e2972[_0xa734('0x18')]?_0x2e2972[_0xa734('0x18')][_0xa734('0x13')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2e2972[_0xa734('0x18')]?_0x2e2972[_0xa734('0x18')][_0xa734('0x19')]||null:null,'attributes':_0x2e2972['options']?_0x2e2972[_0xa734('0x18')]['attributes']||null:null,'limit':_0x2e2972['options']?_0x2e2972[_0xa734('0x18')][_0xa734('0x1a')]||null:null})[_0xa734('0x8')](function(_0x1f208b){logger[_0xa734('0x9')](_0xa734('0x1b'),_0x2e2972);logger['debug']('UpdateSquareReport',_0x2e2972,JSON['stringify'](_0x1f208b));_0x1728c6(_0x1f208b);})[_0xa734('0x15')](function(_0x284434){logger[_0xa734('0xd')](_0xa734('0x1b'),_0x284434[_0xa734('0xf')],_0x2e2972);_0x57305a(_0x8889e4[_0xa734('0xd')](0x1f4,_0x284434[_0xa734('0xf')]));});});};