Built motion from commit 47436d59.|2.6.7
[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 _0x5d5a=['../../config/logger','rpc','../../config/environment','jayson/promise','client','request','info','SquareReport,\x20%s,\x20%s','request\x20sent','debug','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','SquareReport','body','options','raw','CreateSquareReport','UpdateSquareReport','update','where','attributes','limit','then','util','moment','randomstring','../../mysqldb'];(function(_0x99405c,_0x445476){var _0x3daed0=function(_0x21d002){while(--_0x21d002){_0x99405c['push'](_0x99405c['shift']());}};_0x3daed0(++_0x445476);}(_0x5d5a,0x1bc));var _0xa5d5=function(_0x50c779,_0x31c99a){_0x50c779=_0x50c779-0x0;var _0x1c6c0=_0x5d5a[_0x50c779];return _0x1c6c0;};'use strict';var _=require('lodash');var util=require(_0xa5d5('0x0'));var moment=require(_0xa5d5('0x1'));var BPromise=require('bluebird');var rs=require(_0xa5d5('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa5d5('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0xa5d5('0x4'))(_0xa5d5('0x5'));var config=require(_0xa5d5('0x6'));var jayson=require(_0xa5d5('0x7'));var client=jayson[_0xa5d5('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5018b3,_0x63173f,_0x3a6bf2){return new BPromise(function(_0x387639,_0x36505c){return client[_0xa5d5('0x9')](_0x5018b3,_0x3a6bf2)['then'](function(_0x4c5b9a){logger[_0xa5d5('0xa')](_0xa5d5('0xb'),_0x63173f,_0xa5d5('0xc'));logger[_0xa5d5('0xd')](_0xa5d5('0xe'),_0x63173f,'request\x20sent',JSON[_0xa5d5('0xf')](_0x4c5b9a));if(_0x4c5b9a['error']){if(_0x4c5b9a[_0xa5d5('0x10')][_0xa5d5('0x11')]===0x1f4){logger[_0xa5d5('0x10')](_0xa5d5('0xb'),_0x63173f,_0x4c5b9a[_0xa5d5('0x10')][_0xa5d5('0x12')]);return _0x36505c(_0x4c5b9a[_0xa5d5('0x10')][_0xa5d5('0x12')]);}logger[_0xa5d5('0x10')](_0xa5d5('0xb'),_0x63173f,_0x4c5b9a[_0xa5d5('0x10')][_0xa5d5('0x12')]);return _0x387639(_0x4c5b9a[_0xa5d5('0x10')][_0xa5d5('0x12')]);}else{logger[_0xa5d5('0xa')](_0xa5d5('0xb'),_0x63173f,'request\x20sent');_0x387639(_0x4c5b9a[_0xa5d5('0x13')][_0xa5d5('0x12')]);}})[_0xa5d5('0x14')](function(_0x91d161){logger[_0xa5d5('0x10')](_0xa5d5('0xb'),_0x63173f,_0x91d161);_0x36505c(_0x91d161);});});}exports['CreateSquareReport']=function(_0x6920e7){var _0x424abc=this;return new Promise(function(_0x13c5da,_0x40b035){return db[_0xa5d5('0x15')]['create'](_0x6920e7[_0xa5d5('0x16')],{'raw':_0x6920e7['options']?_0x6920e7[_0xa5d5('0x17')][_0xa5d5('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x188b25){logger[_0xa5d5('0xa')](_0xa5d5('0x19'),_0x6920e7);logger[_0xa5d5('0xd')](_0xa5d5('0x19'),_0x6920e7,JSON[_0xa5d5('0xf')](_0x188b25));_0x13c5da(_0x188b25);})[_0xa5d5('0x14')](function(_0x5bed62){logger['error']('CreateSquareReport',_0x5bed62['message'],_0x6920e7);_0x40b035(_0x424abc['error'](0x1f4,_0x5bed62[_0xa5d5('0x12')]));});});};exports[_0xa5d5('0x1a')]=function(_0x1007bd){var _0x289196=this;return new Promise(function(_0x306b95,_0x24c9ea){return db[_0xa5d5('0x15')][_0xa5d5('0x1b')](_0x1007bd[_0xa5d5('0x16')],{'raw':_0x1007bd['options']?_0x1007bd[_0xa5d5('0x17')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1007bd[_0xa5d5('0x17')]?_0x1007bd[_0xa5d5('0x17')][_0xa5d5('0x1c')]||null:null,'attributes':_0x1007bd[_0xa5d5('0x17')]?_0x1007bd[_0xa5d5('0x17')][_0xa5d5('0x1d')]||null:null,'limit':_0x1007bd[_0xa5d5('0x17')]?_0x1007bd['options'][_0xa5d5('0x1e')]||null:null})[_0xa5d5('0x1f')](function(_0xb48b6){logger[_0xa5d5('0xa')]('UpdateSquareReport',_0x1007bd);logger[_0xa5d5('0xd')](_0xa5d5('0x1a'),_0x1007bd,JSON[_0xa5d5('0xf')](_0xb48b6));_0x306b95(_0xb48b6);})['catch'](function(_0x24be0b){logger[_0xa5d5('0x10')](_0xa5d5('0x1a'),_0x24be0b[_0xa5d5('0x12')],_0x1007bd);_0x24c9ea(_0x289196['error'](0x1f4,_0x24be0b[_0xa5d5('0x12')]));});});};