Built motion from commit (unavailable).|2.5.14
[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 _0x4b84=['CreateSquareReport','SquareReport','create','options','raw','catch','UpdateSquareReport','update','body','where','attributes','limit','lodash','util','randomstring','../../config/utils','../../config/logger','rpc','http','then','info','request\x20sent','debug','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','SquareReport,\x20%s,\x20%s','message'];(function(_0x5b4ace,_0x411a40){var _0x32e9d9=function(_0xecb410){while(--_0xecb410){_0x5b4ace['push'](_0x5b4ace['shift']());}};_0x32e9d9(++_0x411a40);}(_0x4b84,0x1cc));var _0x44b8=function(_0x1d7300,_0x17f109){_0x1d7300=_0x1d7300-0x0;var _0x46ee98=_0x4b84[_0x1d7300];return _0x46ee98;};'use strict';var _=require(_0x44b8('0x0'));var util=require(_0x44b8('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x44b8('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x44b8('0x3'));var logger=require(_0x44b8('0x4'))(_0x44b8('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x44b8('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x54274b,_0x327f59,_0x5947f7){return new BPromise(function(_0x3e87c5,_0x5a2353){return client['request'](_0x54274b,_0x5947f7)[_0x44b8('0x7')](function(_0x42319d){logger[_0x44b8('0x8')]('SquareReport,\x20%s,\x20%s',_0x327f59,_0x44b8('0x9'));logger[_0x44b8('0xa')](_0x44b8('0xb'),_0x327f59,_0x44b8('0x9'),JSON[_0x44b8('0xc')](_0x42319d));if(_0x42319d[_0x44b8('0xd')]){if(_0x42319d[_0x44b8('0xd')]['code']===0x1f4){logger[_0x44b8('0xd')](_0x44b8('0xe'),_0x327f59,_0x42319d['error'][_0x44b8('0xf')]);return _0x5a2353(_0x42319d['error'][_0x44b8('0xf')]);}logger[_0x44b8('0xd')]('SquareReport,\x20%s,\x20%s',_0x327f59,_0x42319d[_0x44b8('0xd')]['message']);return _0x3e87c5(_0x42319d['error'][_0x44b8('0xf')]);}else{logger[_0x44b8('0x8')](_0x44b8('0xe'),_0x327f59,_0x44b8('0x9'));_0x3e87c5(_0x42319d['result']['message']);}})['catch'](function(_0x3fe9fb){logger['error'](_0x44b8('0xe'),_0x327f59,_0x3fe9fb);_0x5a2353(_0x3fe9fb);});});}exports[_0x44b8('0x10')]=function(_0x55e258){var _0x36743e=this;return new Promise(function(_0xe3de8f,_0x5103f5){return db[_0x44b8('0x11')][_0x44b8('0x12')](_0x55e258['body'],{'raw':_0x55e258[_0x44b8('0x13')]?_0x55e258[_0x44b8('0x13')][_0x44b8('0x14')]===undefined?!![]:![]:!![]})[_0x44b8('0x7')](function(_0x102ef9){logger[_0x44b8('0x8')](_0x44b8('0x10'),_0x55e258);logger[_0x44b8('0xa')](_0x44b8('0x10'),_0x55e258,JSON[_0x44b8('0xc')](_0x102ef9));_0xe3de8f(_0x102ef9);})[_0x44b8('0x15')](function(_0x14996c){logger['error'](_0x44b8('0x10'),_0x14996c[_0x44b8('0xf')],_0x55e258);_0x5103f5(_0x36743e[_0x44b8('0xd')](0x1f4,_0x14996c[_0x44b8('0xf')]));});});};exports[_0x44b8('0x16')]=function(_0x51a34a){var _0x402497=this;return new Promise(function(_0x54677c,_0x41a922){return db[_0x44b8('0x11')][_0x44b8('0x17')](_0x51a34a[_0x44b8('0x18')],{'raw':_0x51a34a[_0x44b8('0x13')]?_0x51a34a['options'][_0x44b8('0x14')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x51a34a['options']?_0x51a34a[_0x44b8('0x13')][_0x44b8('0x19')]||null:null,'attributes':_0x51a34a['options']?_0x51a34a[_0x44b8('0x13')][_0x44b8('0x1a')]||null:null,'limit':_0x51a34a[_0x44b8('0x13')]?_0x51a34a['options'][_0x44b8('0x1b')]||null:null})[_0x44b8('0x7')](function(_0x53d9c7){logger[_0x44b8('0x8')]('UpdateSquareReport',_0x51a34a);logger[_0x44b8('0xa')]('UpdateSquareReport',_0x51a34a,JSON['stringify'](_0x53d9c7));_0x54677c(_0x53d9c7);})['catch'](function(_0x387293){logger[_0x44b8('0xd')](_0x44b8('0x16'),_0x387293[_0x44b8('0xf')],_0x51a34a);_0x41a922(_0x402497[_0x44b8('0xd')](0x1f4,_0x387293[_0x44b8('0xf')]));});});};