83ddf9c24fae86d02c5321f5e6e80eec902a0f0e
[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 _0x87bb=['../../config/environment','jayson/promise','client','http','request','info','SquareReport,\x20%s,\x20%s','debug','SquareReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','CreateSquareReport','body','options','then','catch','UpdateSquareReport','SquareReport','attributes','limit','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x18ae01,_0x16f801){var _0x30260d=function(_0xe0279a){while(--_0xe0279a){_0x18ae01['push'](_0x18ae01['shift']());}};_0x30260d(++_0x16f801);}(_0x87bb,0x144));var _0xb87b=function(_0x567260,_0x14ca34){_0x567260=_0x567260-0x0;var _0x473a0d=_0x87bb[_0x567260];return _0x473a0d;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xb87b('0x0'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb87b('0x1'));var db=require(_0xb87b('0x2'))['db'];var utils=require(_0xb87b('0x3'));var logger=require(_0xb87b('0x4'))(_0xb87b('0x5'));var config=require(_0xb87b('0x6'));var jayson=require(_0xb87b('0x7'));var client=jayson[_0xb87b('0x8')][_0xb87b('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5ba2cc,_0x1b7562,_0x4afdef){return new BPromise(function(_0x19c348,_0x3ecc81){return client[_0xb87b('0xa')](_0x5ba2cc,_0x4afdef)['then'](function(_0x1bd2f0){logger[_0xb87b('0xb')](_0xb87b('0xc'),_0x1b7562,'request\x20sent');logger[_0xb87b('0xd')](_0xb87b('0xe'),_0x1b7562,_0xb87b('0xf'),JSON[_0xb87b('0x10')](_0x1bd2f0));if(_0x1bd2f0['error']){if(_0x1bd2f0[_0xb87b('0x11')][_0xb87b('0x12')]===0x1f4){logger[_0xb87b('0x11')](_0xb87b('0xc'),_0x1b7562,_0x1bd2f0[_0xb87b('0x11')][_0xb87b('0x13')]);return _0x3ecc81(_0x1bd2f0[_0xb87b('0x11')]['message']);}logger[_0xb87b('0x11')]('SquareReport,\x20%s,\x20%s',_0x1b7562,_0x1bd2f0[_0xb87b('0x11')][_0xb87b('0x13')]);return _0x19c348(_0x1bd2f0['error']['message']);}else{logger[_0xb87b('0xb')](_0xb87b('0xc'),_0x1b7562,'request\x20sent');_0x19c348(_0x1bd2f0[_0xb87b('0x14')][_0xb87b('0x13')]);}})['catch'](function(_0x1c754c){logger['error'](_0xb87b('0xc'),_0x1b7562,_0x1c754c);_0x3ecc81(_0x1c754c);});});}exports[_0xb87b('0x15')]=function(_0x389f11){var _0x58512c=this;return new Promise(function(_0x370e0c,_0x129506){return db['SquareReport']['create'](_0x389f11[_0xb87b('0x16')],{'raw':_0x389f11[_0xb87b('0x17')]?_0x389f11[_0xb87b('0x17')]['raw']===undefined?!![]:![]:!![]})[_0xb87b('0x18')](function(_0x56700b){logger[_0xb87b('0xb')](_0xb87b('0x15'),_0x389f11);logger[_0xb87b('0xd')](_0xb87b('0x15'),_0x389f11,JSON[_0xb87b('0x10')](_0x56700b));_0x370e0c(_0x56700b);})[_0xb87b('0x19')](function(_0x21b939){logger[_0xb87b('0x11')](_0xb87b('0x15'),_0x21b939[_0xb87b('0x13')],_0x389f11);_0x129506(_0x58512c['error'](0x1f4,_0x21b939[_0xb87b('0x13')]));});});};exports[_0xb87b('0x1a')]=function(_0x27e1aa){var _0x26847b=this;return new Promise(function(_0x4d5994,_0x39303b){return db[_0xb87b('0x1b')]['update'](_0x27e1aa[_0xb87b('0x16')],{'raw':_0x27e1aa[_0xb87b('0x17')]?_0x27e1aa['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x27e1aa[_0xb87b('0x17')]?_0x27e1aa[_0xb87b('0x17')]['where']||null:null,'attributes':_0x27e1aa[_0xb87b('0x17')]?_0x27e1aa[_0xb87b('0x17')][_0xb87b('0x1c')]||null:null,'limit':_0x27e1aa['options']?_0x27e1aa[_0xb87b('0x17')][_0xb87b('0x1d')]||null:null})[_0xb87b('0x18')](function(_0x14d58b){logger[_0xb87b('0xb')](_0xb87b('0x1a'),_0x27e1aa);logger['debug'](_0xb87b('0x1a'),_0x27e1aa,JSON['stringify'](_0x14d58b));_0x4d5994(_0x14d58b);})['catch'](function(_0x138a74){logger[_0xb87b('0x11')](_0xb87b('0x1a'),_0x138a74[_0xb87b('0x13')],_0x27e1aa);_0x39303b(_0x26847b['error'](0x1f4,_0x138a74[_0xb87b('0x13')]));});});};