Built motion from commit 97153652.|2.6.26
[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 _0x2f02=['UpdateSquareReport','lodash','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','SquareReport,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','CreateSquareReport','SquareReport','body','options','raw','update','attributes','limit'];(function(_0x25ba6a,_0x4422d6){var _0x1be09a=function(_0x308e7b){while(--_0x308e7b){_0x25ba6a['push'](_0x25ba6a['shift']());}};_0x1be09a(++_0x4422d6);}(_0x2f02,0x156));var _0x22f0=function(_0x4d7707,_0x9784ca){_0x4d7707=_0x4d7707-0x0;var _0x5d3421=_0x2f02[_0x4d7707];return _0x5d3421;};'use strict';var _=require(_0x22f0('0x0'));var util=require('util');var moment=require(_0x22f0('0x1'));var BPromise=require(_0x22f0('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x22f0('0x3'))['db'];var utils=require(_0x22f0('0x4'));var logger=require(_0x22f0('0x5'))(_0x22f0('0x6'));var config=require('../../config/environment');var jayson=require(_0x22f0('0x7'));var client=jayson[_0x22f0('0x8')][_0x22f0('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3ab38b,_0x45b013,_0x5230df){return new BPromise(function(_0x1ccef3,_0x5369e6){return client[_0x22f0('0xa')](_0x3ab38b,_0x5230df)[_0x22f0('0xb')](function(_0x19724f){logger[_0x22f0('0xc')](_0x22f0('0xd'),_0x45b013,_0x22f0('0xe'));logger[_0x22f0('0xf')]('SquareReport,\x20%s,\x20%s,\x20%s',_0x45b013,_0x22f0('0xe'),JSON[_0x22f0('0x10')](_0x19724f));if(_0x19724f[_0x22f0('0x11')]){if(_0x19724f[_0x22f0('0x11')][_0x22f0('0x12')]===0x1f4){logger[_0x22f0('0x11')](_0x22f0('0xd'),_0x45b013,_0x19724f[_0x22f0('0x11')][_0x22f0('0x13')]);return _0x5369e6(_0x19724f[_0x22f0('0x11')]['message']);}logger['error'](_0x22f0('0xd'),_0x45b013,_0x19724f[_0x22f0('0x11')][_0x22f0('0x13')]);return _0x1ccef3(_0x19724f[_0x22f0('0x11')][_0x22f0('0x13')]);}else{logger[_0x22f0('0xc')](_0x22f0('0xd'),_0x45b013,'request\x20sent');_0x1ccef3(_0x19724f[_0x22f0('0x14')][_0x22f0('0x13')]);}})[_0x22f0('0x15')](function(_0x231d06){logger[_0x22f0('0x11')](_0x22f0('0xd'),_0x45b013,_0x231d06);_0x5369e6(_0x231d06);});});}exports[_0x22f0('0x16')]=function(_0x467c2b){var _0x33a615=this;return new Promise(function(_0x59413e,_0x5cc498){return db[_0x22f0('0x17')]['create'](_0x467c2b[_0x22f0('0x18')],{'raw':_0x467c2b[_0x22f0('0x19')]?_0x467c2b[_0x22f0('0x19')][_0x22f0('0x1a')]===undefined?!![]:![]:!![]})[_0x22f0('0xb')](function(_0x30dd2e){logger[_0x22f0('0xc')](_0x22f0('0x16'),_0x467c2b);logger[_0x22f0('0xf')]('CreateSquareReport',_0x467c2b,JSON[_0x22f0('0x10')](_0x30dd2e));_0x59413e(_0x30dd2e);})[_0x22f0('0x15')](function(_0x36bbce){logger[_0x22f0('0x11')]('CreateSquareReport',_0x36bbce[_0x22f0('0x13')],_0x467c2b);_0x5cc498(_0x33a615[_0x22f0('0x11')](0x1f4,_0x36bbce[_0x22f0('0x13')]));});});};exports['UpdateSquareReport']=function(_0x39f81c){var _0x4f6f51=this;return new Promise(function(_0x3873ec,_0xcd91dc){return db[_0x22f0('0x17')][_0x22f0('0x1b')](_0x39f81c[_0x22f0('0x18')],{'raw':_0x39f81c[_0x22f0('0x19')]?_0x39f81c['options'][_0x22f0('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x39f81c[_0x22f0('0x19')]?_0x39f81c[_0x22f0('0x19')]['where']||null:null,'attributes':_0x39f81c[_0x22f0('0x19')]?_0x39f81c[_0x22f0('0x19')][_0x22f0('0x1c')]||null:null,'limit':_0x39f81c[_0x22f0('0x19')]?_0x39f81c[_0x22f0('0x19')][_0x22f0('0x1d')]||null:null})[_0x22f0('0xb')](function(_0x367408){logger[_0x22f0('0xc')](_0x22f0('0x1e'),_0x39f81c);logger[_0x22f0('0xf')](_0x22f0('0x1e'),_0x39f81c,JSON['stringify'](_0x367408));_0x3873ec(_0x367408);})[_0x22f0('0x15')](function(_0x1abf1b){logger[_0x22f0('0x11')]('UpdateSquareReport',_0x1abf1b['message'],_0x39f81c);_0xcd91dc(_0x4f6f51['error'](0x1f4,_0x1abf1b[_0x22f0('0x13')]));});});};