7b4eec8f112209a08f32ca13b8ea8a7d0cfeebfd
[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 _0xccfd=['UpdateSquareReport','SquareReport','body','where','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','SquareReport,\x20%s,\x20%s','request\x20sent','debug','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','create','options','raw','CreateSquareReport'];(function(_0x5ccb33,_0xa4bcbe){var _0x4c1db8=function(_0x195494){while(--_0x195494){_0x5ccb33['push'](_0x5ccb33['shift']());}};_0x4c1db8(++_0xa4bcbe);}(_0xccfd,0xf3));var _0xdccf=function(_0x942433,_0x22c9e4){_0x942433=_0x942433-0x0;var _0x2b3cd3=_0xccfd[_0x942433];return _0x2b3cd3;};'use strict';var _=require(_0xdccf('0x0'));var util=require(_0xdccf('0x1'));var moment=require(_0xdccf('0x2'));var BPromise=require(_0xdccf('0x3'));var rs=require(_0xdccf('0x4'));var fs=require('fs');var Redis=require(_0xdccf('0x5'));var db=require(_0xdccf('0x6'))['db'];var utils=require(_0xdccf('0x7'));var logger=require(_0xdccf('0x8'))(_0xdccf('0x9'));var config=require(_0xdccf('0xa'));var jayson=require('jayson/promise');var client=jayson[_0xdccf('0xb')][_0xdccf('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x1d4ee5,_0x4a85a2,_0x5524ec){return new BPromise(function(_0x1569cb,_0x5e45fa){return client[_0xdccf('0xd')](_0x1d4ee5,_0x5524ec)[_0xdccf('0xe')](function(_0xefd5b5){logger['info'](_0xdccf('0xf'),_0x4a85a2,_0xdccf('0x10'));logger[_0xdccf('0x11')](_0xdccf('0x12'),_0x4a85a2,_0xdccf('0x10'),JSON[_0xdccf('0x13')](_0xefd5b5));if(_0xefd5b5['error']){if(_0xefd5b5[_0xdccf('0x14')][_0xdccf('0x15')]===0x1f4){logger[_0xdccf('0x14')](_0xdccf('0xf'),_0x4a85a2,_0xefd5b5[_0xdccf('0x14')][_0xdccf('0x16')]);return _0x5e45fa(_0xefd5b5[_0xdccf('0x14')]['message']);}logger[_0xdccf('0x14')]('SquareReport,\x20%s,\x20%s',_0x4a85a2,_0xefd5b5[_0xdccf('0x14')]['message']);return _0x1569cb(_0xefd5b5[_0xdccf('0x14')][_0xdccf('0x16')]);}else{logger[_0xdccf('0x17')](_0xdccf('0xf'),_0x4a85a2,'request\x20sent');_0x1569cb(_0xefd5b5[_0xdccf('0x18')][_0xdccf('0x16')]);}})['catch'](function(_0x44db24){logger[_0xdccf('0x14')](_0xdccf('0xf'),_0x4a85a2,_0x44db24);_0x5e45fa(_0x44db24);});});}exports['CreateSquareReport']=function(_0x3e7e1b){var _0x584f26=this;return new Promise(function(_0x572148,_0x29fb04){return db['SquareReport'][_0xdccf('0x19')](_0x3e7e1b['body'],{'raw':_0x3e7e1b[_0xdccf('0x1a')]?_0x3e7e1b[_0xdccf('0x1a')][_0xdccf('0x1b')]===undefined?!![]:![]:!![]})['then'](function(_0x4690bc){logger[_0xdccf('0x17')](_0xdccf('0x1c'),_0x3e7e1b);logger[_0xdccf('0x11')](_0xdccf('0x1c'),_0x3e7e1b,JSON[_0xdccf('0x13')](_0x4690bc));_0x572148(_0x4690bc);})['catch'](function(_0x2e869b){logger[_0xdccf('0x14')](_0xdccf('0x1c'),_0x2e869b[_0xdccf('0x16')],_0x3e7e1b);_0x29fb04(_0x584f26[_0xdccf('0x14')](0x1f4,_0x2e869b['message']));});});};exports[_0xdccf('0x1d')]=function(_0x764aa2){var _0x5e2ea0=this;return new Promise(function(_0x562175,_0x30fa81){return db[_0xdccf('0x1e')]['update'](_0x764aa2[_0xdccf('0x1f')],{'raw':_0x764aa2[_0xdccf('0x1a')]?_0x764aa2[_0xdccf('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x764aa2[_0xdccf('0x1a')]?_0x764aa2['options'][_0xdccf('0x20')]||null:null,'attributes':_0x764aa2[_0xdccf('0x1a')]?_0x764aa2[_0xdccf('0x1a')]['attributes']||null:null,'limit':_0x764aa2[_0xdccf('0x1a')]?_0x764aa2[_0xdccf('0x1a')]['limit']||null:null})['then'](function(_0x4f66e5){logger[_0xdccf('0x17')](_0xdccf('0x1d'),_0x764aa2);logger['debug']('UpdateSquareReport',_0x764aa2,JSON[_0xdccf('0x13')](_0x4f66e5));_0x562175(_0x4f66e5);})[_0xdccf('0x21')](function(_0x37f69f){logger[_0xdccf('0x14')](_0xdccf('0x1d'),_0x37f69f[_0xdccf('0x16')],_0x764aa2);_0x30fa81(_0x5e2ea0['error'](0x1f4,_0x37f69f['message']));});});};