b1a6ac739728820f301e7c1ee99678a4acc8cde4
[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 _0xcdbf=['then','CreateSquareReport','stringify','catch','UpdateSquareReport','where','attributes','lodash','util','bluebird','../../mysqldb','rpc','../../config/environment','client','http','info','debug','request\x20sent','error','SquareReport,\x20%s,\x20%s','message','result','SquareReport','body','options','raw'];(function(_0x199572,_0x33e667){var _0x13cfa3=function(_0x53c075){while(--_0x53c075){_0x199572['push'](_0x199572['shift']());}};_0x13cfa3(++_0x33e667);}(_0xcdbf,0x1a7));var _0xfcdb=function(_0x5f1391,_0x19c132){_0x5f1391=_0x5f1391-0x0;var _0x50ebe3=_0xcdbf[_0x5f1391];return _0x50ebe3;};'use strict';var _=require(_0xfcdb('0x0'));var util=require(_0xfcdb('0x1'));var moment=require('moment');var BPromise=require(_0xfcdb('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xfcdb('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xfcdb('0x4'));var config=require(_0xfcdb('0x5'));var jayson=require('jayson/promise');var client=jayson[_0xfcdb('0x6')][_0xfcdb('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x4a1f6a,_0x58124f,_0x26f9ea){return new BPromise(function(_0x696bf0,_0x74e77f){return client['request'](_0x4a1f6a,_0x26f9ea)['then'](function(_0x38993b){logger[_0xfcdb('0x8')]('SquareReport,\x20%s,\x20%s',_0x58124f,'request\x20sent');logger[_0xfcdb('0x9')]('SquareReport,\x20%s,\x20%s,\x20%s',_0x58124f,_0xfcdb('0xa'),JSON['stringify'](_0x38993b));if(_0x38993b[_0xfcdb('0xb')]){if(_0x38993b[_0xfcdb('0xb')]['code']===0x1f4){logger[_0xfcdb('0xb')](_0xfcdb('0xc'),_0x58124f,_0x38993b['error']['message']);return _0x74e77f(_0x38993b[_0xfcdb('0xb')][_0xfcdb('0xd')]);}logger[_0xfcdb('0xb')]('SquareReport,\x20%s,\x20%s',_0x58124f,_0x38993b[_0xfcdb('0xb')][_0xfcdb('0xd')]);return _0x696bf0(_0x38993b[_0xfcdb('0xb')][_0xfcdb('0xd')]);}else{logger['info']('SquareReport,\x20%s,\x20%s',_0x58124f,_0xfcdb('0xa'));_0x696bf0(_0x38993b[_0xfcdb('0xe')][_0xfcdb('0xd')]);}})['catch'](function(_0x1d1ad3){logger[_0xfcdb('0xb')](_0xfcdb('0xc'),_0x58124f,_0x1d1ad3);_0x74e77f(_0x1d1ad3);});});}exports['CreateSquareReport']=function(_0x44c9af){var _0x301f71=this;return new Promise(function(_0x43adbd,_0x265d37){return db[_0xfcdb('0xf')]['create'](_0x44c9af[_0xfcdb('0x10')],{'raw':_0x44c9af[_0xfcdb('0x11')]?_0x44c9af[_0xfcdb('0x11')][_0xfcdb('0x12')]===undefined?!![]:![]:!![]})[_0xfcdb('0x13')](function(_0x505696){logger[_0xfcdb('0x8')](_0xfcdb('0x14'),_0x44c9af);logger[_0xfcdb('0x9')](_0xfcdb('0x14'),_0x44c9af,JSON[_0xfcdb('0x15')](_0x505696));_0x43adbd(_0x505696);})[_0xfcdb('0x16')](function(_0x552b9c){logger[_0xfcdb('0xb')](_0xfcdb('0x14'),_0x552b9c[_0xfcdb('0xd')],_0x44c9af);_0x265d37(_0x301f71[_0xfcdb('0xb')](0x1f4,_0x552b9c[_0xfcdb('0xd')]));});});};exports[_0xfcdb('0x17')]=function(_0x4e8f86){var _0x21ade2=this;return new Promise(function(_0x5bac6b,_0x190528){return db[_0xfcdb('0xf')]['update'](_0x4e8f86['body'],{'raw':_0x4e8f86[_0xfcdb('0x11')]?_0x4e8f86['options'][_0xfcdb('0x12')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4e8f86[_0xfcdb('0x11')]?_0x4e8f86['options'][_0xfcdb('0x18')]||null:null,'attributes':_0x4e8f86[_0xfcdb('0x11')]?_0x4e8f86[_0xfcdb('0x11')][_0xfcdb('0x19')]||null:null,'limit':_0x4e8f86['options']?_0x4e8f86[_0xfcdb('0x11')]['limit']||null:null})['then'](function(_0x771771){logger['info'](_0xfcdb('0x17'),_0x4e8f86);logger[_0xfcdb('0x9')]('UpdateSquareReport',_0x4e8f86,JSON[_0xfcdb('0x15')](_0x771771));_0x5bac6b(_0x771771);})[_0xfcdb('0x16')](function(_0x471f6a){logger['error'](_0xfcdb('0x17'),_0x471f6a[_0xfcdb('0xd')],_0x4e8f86);_0x190528(_0x21ade2[_0xfcdb('0xb')](0x1f4,_0x471f6a['message']));});});};