Built motion from commit (unavailable).|2.3.1
[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 _0x9675=['request\x20sent','debug','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','SquareReport,\x20%s,\x20%s','catch','CreateSquareReport','SquareReport','create','options','raw','then','UpdateSquareReport','update','attributes','limit','util','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','info'];(function(_0x507881,_0x23cc61){var _0x2c2063=function(_0x3ddecc){while(--_0x3ddecc){_0x507881['push'](_0x507881['shift']());}};_0x2c2063(++_0x23cc61);}(_0x9675,0x8b));var _0x5967=function(_0x1e1193,_0x36654c){_0x1e1193=_0x1e1193-0x0;var _0x90d6b3=_0x9675[_0x1e1193];return _0x90d6b3;};'use strict';var _=require('lodash');var util=require(_0x5967('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x5967('0x1'));var fs=require('fs');var Redis=require(_0x5967('0x2'));var db=require(_0x5967('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x5967('0x4'))(_0x5967('0x5'));var config=require(_0x5967('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x5967('0x7')][_0x5967('0x8')]({'port':0x232a});function respondWithRpcPromise(_0xcecaa4,_0x3f40c0,_0x581091){return new BPromise(function(_0x514ed1,_0x2a5b23){return client[_0x5967('0x9')](_0xcecaa4,_0x581091)['then'](function(_0x253af6){logger[_0x5967('0xa')]('SquareReport,\x20%s,\x20%s',_0x3f40c0,_0x5967('0xb'));logger[_0x5967('0xc')](_0x5967('0xd'),_0x3f40c0,_0x5967('0xb'),JSON[_0x5967('0xe')](_0x253af6));if(_0x253af6[_0x5967('0xf')]){if(_0x253af6[_0x5967('0xf')][_0x5967('0x10')]===0x1f4){logger['error']('SquareReport,\x20%s,\x20%s',_0x3f40c0,_0x253af6['error'][_0x5967('0x11')]);return _0x2a5b23(_0x253af6[_0x5967('0xf')][_0x5967('0x11')]);}logger[_0x5967('0xf')](_0x5967('0x12'),_0x3f40c0,_0x253af6['error']['message']);return _0x514ed1(_0x253af6[_0x5967('0xf')][_0x5967('0x11')]);}else{logger[_0x5967('0xa')](_0x5967('0x12'),_0x3f40c0,_0x5967('0xb'));_0x514ed1(_0x253af6['result'][_0x5967('0x11')]);}})[_0x5967('0x13')](function(_0x8da288){logger[_0x5967('0xf')]('SquareReport,\x20%s,\x20%s',_0x3f40c0,_0x8da288);_0x2a5b23(_0x8da288);});});}exports[_0x5967('0x14')]=function(_0x42ee8a){var _0x4e2ec6=this;return new Promise(function(_0xa0b3ca,_0x46f614){return db[_0x5967('0x15')][_0x5967('0x16')](_0x42ee8a['body'],{'raw':_0x42ee8a['options']?_0x42ee8a[_0x5967('0x17')][_0x5967('0x18')]===undefined?!![]:![]:!![]})[_0x5967('0x19')](function(_0x964fa5){logger[_0x5967('0xa')](_0x5967('0x14'),_0x42ee8a);logger['debug'](_0x5967('0x14'),_0x42ee8a,JSON[_0x5967('0xe')](_0x964fa5));_0xa0b3ca(_0x964fa5);})['catch'](function(_0x4152f6){logger['error'](_0x5967('0x14'),_0x4152f6['message'],_0x42ee8a);_0x46f614(_0x4e2ec6[_0x5967('0xf')](0x1f4,_0x4152f6[_0x5967('0x11')]));});});};exports[_0x5967('0x1a')]=function(_0x5c34ea){var _0xd14495=this;return new Promise(function(_0x3541e0,_0x5360cc){return db[_0x5967('0x15')][_0x5967('0x1b')](_0x5c34ea['body'],{'raw':_0x5c34ea[_0x5967('0x17')]?_0x5c34ea[_0x5967('0x17')][_0x5967('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5c34ea[_0x5967('0x17')]?_0x5c34ea[_0x5967('0x17')]['where']||null:null,'attributes':_0x5c34ea[_0x5967('0x17')]?_0x5c34ea[_0x5967('0x17')][_0x5967('0x1c')]||null:null,'limit':_0x5c34ea['options']?_0x5c34ea[_0x5967('0x17')][_0x5967('0x1d')]||null:null})[_0x5967('0x19')](function(_0x264039){logger[_0x5967('0xa')](_0x5967('0x1a'),_0x5c34ea);logger['debug'](_0x5967('0x1a'),_0x5c34ea,JSON[_0x5967('0xe')](_0x264039));_0x3541e0(_0x264039);})[_0x5967('0x13')](function(_0x533525){logger[_0x5967('0xf')]('UpdateSquareReport',_0x533525[_0x5967('0x11')],_0x5c34ea);_0x5360cc(_0xd14495[_0x5967('0xf')](0x1f4,_0x533525['message']));});});};