Built motion from commit 9d1906d1.|2.5.40
[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 _0x6f0c=['attributes','limit','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','info','SquareReport,\x20%s,\x20%s','request\x20sent','debug','error','message','catch','CreateSquareReport','create','body','options','raw','then','stringify','UpdateSquareReport','SquareReport','update','where'];(function(_0x3fa183,_0x3b37a6){var _0x12dc50=function(_0x72c6b4){while(--_0x72c6b4){_0x3fa183['push'](_0x3fa183['shift']());}};_0x12dc50(++_0x3b37a6);}(_0x6f0c,0xe2));var _0xc6f0=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x6f0c[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xc6f0('0x0'));var util=require(_0xc6f0('0x1'));var moment=require(_0xc6f0('0x2'));var BPromise=require(_0xc6f0('0x3'));var rs=require(_0xc6f0('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc6f0('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xc6f0('0x6'))(_0xc6f0('0x7'));var config=require(_0xc6f0('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xc6f0('0x9')][_0xc6f0('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x396cab,_0x5354f0,_0x367d17){return new BPromise(function(_0x510954,_0x4fc157){return client[_0xc6f0('0xb')](_0x396cab,_0x367d17)['then'](function(_0x55b55c){logger[_0xc6f0('0xc')](_0xc6f0('0xd'),_0x5354f0,_0xc6f0('0xe'));logger[_0xc6f0('0xf')]('SquareReport,\x20%s,\x20%s,\x20%s',_0x5354f0,_0xc6f0('0xe'),JSON['stringify'](_0x55b55c));if(_0x55b55c[_0xc6f0('0x10')]){if(_0x55b55c[_0xc6f0('0x10')]['code']===0x1f4){logger[_0xc6f0('0x10')](_0xc6f0('0xd'),_0x5354f0,_0x55b55c[_0xc6f0('0x10')][_0xc6f0('0x11')]);return _0x4fc157(_0x55b55c[_0xc6f0('0x10')][_0xc6f0('0x11')]);}logger[_0xc6f0('0x10')](_0xc6f0('0xd'),_0x5354f0,_0x55b55c[_0xc6f0('0x10')][_0xc6f0('0x11')]);return _0x510954(_0x55b55c[_0xc6f0('0x10')][_0xc6f0('0x11')]);}else{logger[_0xc6f0('0xc')](_0xc6f0('0xd'),_0x5354f0,_0xc6f0('0xe'));_0x510954(_0x55b55c['result'][_0xc6f0('0x11')]);}})[_0xc6f0('0x12')](function(_0x580464){logger[_0xc6f0('0x10')](_0xc6f0('0xd'),_0x5354f0,_0x580464);_0x4fc157(_0x580464);});});}exports[_0xc6f0('0x13')]=function(_0x5536e9){var _0x5e23f1=this;return new Promise(function(_0x3ce3bf,_0xde4789){return db['SquareReport'][_0xc6f0('0x14')](_0x5536e9[_0xc6f0('0x15')],{'raw':_0x5536e9[_0xc6f0('0x16')]?_0x5536e9[_0xc6f0('0x16')][_0xc6f0('0x17')]===undefined?!![]:![]:!![]})[_0xc6f0('0x18')](function(_0x1d5b41){logger[_0xc6f0('0xc')](_0xc6f0('0x13'),_0x5536e9);logger[_0xc6f0('0xf')](_0xc6f0('0x13'),_0x5536e9,JSON[_0xc6f0('0x19')](_0x1d5b41));_0x3ce3bf(_0x1d5b41);})[_0xc6f0('0x12')](function(_0x214098){logger[_0xc6f0('0x10')]('CreateSquareReport',_0x214098[_0xc6f0('0x11')],_0x5536e9);_0xde4789(_0x5e23f1['error'](0x1f4,_0x214098[_0xc6f0('0x11')]));});});};exports[_0xc6f0('0x1a')]=function(_0x47518e){var _0x2641d4=this;return new Promise(function(_0x191c36,_0x4d50d7){return db[_0xc6f0('0x1b')][_0xc6f0('0x1c')](_0x47518e[_0xc6f0('0x15')],{'raw':_0x47518e[_0xc6f0('0x16')]?_0x47518e['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x47518e[_0xc6f0('0x16')]?_0x47518e[_0xc6f0('0x16')][_0xc6f0('0x1d')]||null:null,'attributes':_0x47518e[_0xc6f0('0x16')]?_0x47518e[_0xc6f0('0x16')][_0xc6f0('0x1e')]||null:null,'limit':_0x47518e[_0xc6f0('0x16')]?_0x47518e[_0xc6f0('0x16')][_0xc6f0('0x1f')]||null:null})[_0xc6f0('0x18')](function(_0x5d3125){logger[_0xc6f0('0xc')]('UpdateSquareReport',_0x47518e);logger[_0xc6f0('0xf')](_0xc6f0('0x1a'),_0x47518e,JSON[_0xc6f0('0x19')](_0x5d3125));_0x191c36(_0x5d3125);})[_0xc6f0('0x12')](function(_0x23ce43){logger[_0xc6f0('0x10')](_0xc6f0('0x1a'),_0x23ce43[_0xc6f0('0x11')],_0x47518e);_0x4d50d7(_0x2641d4['error'](0x1f4,_0x23ce43[_0xc6f0('0x11')]));});});};