0d83d229e8c8e24e17783dfb95da80b2594a10c5
[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 _0x486c=['../../config/utils','rpc','jayson/promise','client','http','request','then','info','SquareReport,\x20%s,\x20%s','request\x20sent','debug','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateSquareReport','SquareReport','create','body','options','raw','UpdateSquareReport','update','where','attributes','limit','lodash','util','ioredis','../../mysqldb'];(function(_0x57f12a,_0x5b40e3){var _0x1fe002=function(_0x1699af){while(--_0x1699af){_0x57f12a['push'](_0x57f12a['shift']());}};_0x1fe002(++_0x5b40e3);}(_0x486c,0x1eb));var _0xc486=function(_0x25c508,_0x48265f){_0x25c508=_0x25c508-0x0;var _0xfc6162=_0x486c[_0x25c508];return _0xfc6162;};'use strict';var _=require(_0xc486('0x0'));var util=require(_0xc486('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xc486('0x2'));var db=require(_0xc486('0x3'))['db'];var utils=require(_0xc486('0x4'));var logger=require('../../config/logger')(_0xc486('0x5'));var config=require('../../config/environment');var jayson=require(_0xc486('0x6'));var client=jayson[_0xc486('0x7')][_0xc486('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x267d24,_0x532c48,_0x4ebab4){return new BPromise(function(_0x136193,_0x12ed7b){return client[_0xc486('0x9')](_0x267d24,_0x4ebab4)[_0xc486('0xa')](function(_0x4e3c5c){logger[_0xc486('0xb')](_0xc486('0xc'),_0x532c48,_0xc486('0xd'));logger[_0xc486('0xe')](_0xc486('0xf'),_0x532c48,_0xc486('0xd'),JSON[_0xc486('0x10')](_0x4e3c5c));if(_0x4e3c5c['error']){if(_0x4e3c5c[_0xc486('0x11')][_0xc486('0x12')]===0x1f4){logger[_0xc486('0x11')]('SquareReport,\x20%s,\x20%s',_0x532c48,_0x4e3c5c['error']['message']);return _0x12ed7b(_0x4e3c5c[_0xc486('0x11')]['message']);}logger[_0xc486('0x11')]('SquareReport,\x20%s,\x20%s',_0x532c48,_0x4e3c5c[_0xc486('0x11')]['message']);return _0x136193(_0x4e3c5c[_0xc486('0x11')][_0xc486('0x13')]);}else{logger[_0xc486('0xb')](_0xc486('0xc'),_0x532c48,_0xc486('0xd'));_0x136193(_0x4e3c5c[_0xc486('0x14')]['message']);}})[_0xc486('0x15')](function(_0x1ce65d){logger[_0xc486('0x11')]('SquareReport,\x20%s,\x20%s',_0x532c48,_0x1ce65d);_0x12ed7b(_0x1ce65d);});});}exports[_0xc486('0x16')]=function(_0x6b8bac){var _0x4c9fe8=this;return new Promise(function(_0x298d92,_0x1220ca){return db[_0xc486('0x17')][_0xc486('0x18')](_0x6b8bac[_0xc486('0x19')],{'raw':_0x6b8bac[_0xc486('0x1a')]?_0x6b8bac[_0xc486('0x1a')][_0xc486('0x1b')]===undefined?!![]:![]:!![]})[_0xc486('0xa')](function(_0x4ce4cb){logger[_0xc486('0xb')](_0xc486('0x16'),_0x6b8bac);logger[_0xc486('0xe')](_0xc486('0x16'),_0x6b8bac,JSON[_0xc486('0x10')](_0x4ce4cb));_0x298d92(_0x4ce4cb);})[_0xc486('0x15')](function(_0x4a862b){logger[_0xc486('0x11')](_0xc486('0x16'),_0x4a862b[_0xc486('0x13')],_0x6b8bac);_0x1220ca(_0x4c9fe8['error'](0x1f4,_0x4a862b['message']));});});};exports[_0xc486('0x1c')]=function(_0x412334){var _0x342b85=this;return new Promise(function(_0x59b147,_0x5d51af){return db[_0xc486('0x17')][_0xc486('0x1d')](_0x412334['body'],{'raw':_0x412334[_0xc486('0x1a')]?_0x412334['options'][_0xc486('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x412334[_0xc486('0x1a')]?_0x412334[_0xc486('0x1a')][_0xc486('0x1e')]||null:null,'attributes':_0x412334[_0xc486('0x1a')]?_0x412334[_0xc486('0x1a')][_0xc486('0x1f')]||null:null,'limit':_0x412334[_0xc486('0x1a')]?_0x412334[_0xc486('0x1a')][_0xc486('0x20')]||null:null})[_0xc486('0xa')](function(_0x29ab2c){logger[_0xc486('0xb')]('UpdateSquareReport',_0x412334);logger['debug']('UpdateSquareReport',_0x412334,JSON['stringify'](_0x29ab2c));_0x59b147(_0x29ab2c);})['catch'](function(_0x183bef){logger[_0xc486('0x11')](_0xc486('0x1c'),_0x183bef[_0xc486('0x13')],_0x412334);_0x5d51af(_0x342b85[_0xc486('0x11')](0x1f4,_0x183bef[_0xc486('0x13')]));});});};