0794611870b7a0d86628a9bcc9120f6e5691bd42
[motion2.git] / server / api / squareRecording / squareRecording.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 _0x812a=['lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','jayson/promise','http','then','info','SquareRecording,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','CreateSquareRecording','SquareRecording','create','body','options'];(function(_0x27af45,_0x1b57aa){var _0x18df21=function(_0x4b7679){while(--_0x4b7679){_0x27af45['push'](_0x27af45['shift']());}};_0x18df21(++_0x1b57aa);}(_0x812a,0x1db));var _0xa812=function(_0xaaec1d,_0xadf275){_0xaaec1d=_0xaaec1d-0x0;var _0x482a1a=_0x812a[_0xaaec1d];return _0x482a1a;};'use strict';var _=require(_0xa812('0x0'));var util=require(_0xa812('0x1'));var moment=require(_0xa812('0x2'));var BPromise=require(_0xa812('0x3'));var rs=require(_0xa812('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa812('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xa812('0x6'))(_0xa812('0x7'));var config=require('../../config/environment');var jayson=require(_0xa812('0x8'));var client=jayson['client'][_0xa812('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4c1ed3,_0x3a6b83,_0x3b2494){return new BPromise(function(_0x9e2a5c,_0x3c0907){return client['request'](_0x4c1ed3,_0x3b2494)[_0xa812('0xa')](function(_0x5dd5ca){logger[_0xa812('0xb')](_0xa812('0xc'),_0x3a6b83,_0xa812('0xd'));logger[_0xa812('0xe')]('SquareRecording,\x20%s,\x20%s,\x20%s',_0x3a6b83,_0xa812('0xd'),JSON[_0xa812('0xf')](_0x5dd5ca));if(_0x5dd5ca[_0xa812('0x10')]){if(_0x5dd5ca['error'][_0xa812('0x11')]===0x1f4){logger[_0xa812('0x10')](_0xa812('0xc'),_0x3a6b83,_0x5dd5ca[_0xa812('0x10')]['message']);return _0x3c0907(_0x5dd5ca['error'][_0xa812('0x12')]);}logger[_0xa812('0x10')](_0xa812('0xc'),_0x3a6b83,_0x5dd5ca[_0xa812('0x10')][_0xa812('0x12')]);return _0x9e2a5c(_0x5dd5ca[_0xa812('0x10')][_0xa812('0x12')]);}else{logger[_0xa812('0xb')]('SquareRecording,\x20%s,\x20%s',_0x3a6b83,'request\x20sent');_0x9e2a5c(_0x5dd5ca['result'][_0xa812('0x12')]);}})[_0xa812('0x13')](function(_0x4ef540){logger[_0xa812('0x10')](_0xa812('0xc'),_0x3a6b83,_0x4ef540);_0x3c0907(_0x4ef540);});});}exports[_0xa812('0x14')]=function(_0x241f0f){var _0x127652=this;return new Promise(function(_0x53be33,_0x30d964){return db[_0xa812('0x15')][_0xa812('0x16')](_0x241f0f[_0xa812('0x17')],{'raw':_0x241f0f['options']?_0x241f0f[_0xa812('0x18')]['raw']===undefined?!![]:![]:!![]})[_0xa812('0xa')](function(_0x359399){logger[_0xa812('0xb')]('CreateSquareRecording',_0x241f0f);logger['debug'](_0xa812('0x14'),_0x241f0f,JSON[_0xa812('0xf')](_0x359399));_0x53be33(_0x359399);})[_0xa812('0x13')](function(_0x58fc9c){logger['error'](_0xa812('0x14'),_0x58fc9c[_0xa812('0x12')],_0x241f0f);_0x30d964(_0x127652[_0xa812('0x10')](0x1f4,_0x58fc9c[_0xa812('0x12')]));});});};