98efa78a7f76c67facf1dd25015d85325b4b8f1e
[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 _0xacea=['bluebird','ioredis','../../config/logger','jayson/promise','client','request','then','info','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','error','code','message','SquareRecording,\x20%s,\x20%s','catch','create','body','options','raw','CreateSquareRecording','stringify','moment'];(function(_0x32ec9f,_0x859a63){var _0x3b1676=function(_0x5c8fa5){while(--_0x5c8fa5){_0x32ec9f['push'](_0x32ec9f['shift']());}};_0x3b1676(++_0x859a63);}(_0xacea,0xfc));var _0xaace=function(_0x5d77a6,_0x55dbe9){_0x5d77a6=_0x5d77a6-0x0;var _0x49ed21=_0xacea[_0x5d77a6];return _0x49ed21;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xaace('0x0'));var BPromise=require(_0xaace('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xaace('0x2'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xaace('0x3'))('rpc');var config=require('../../config/environment');var jayson=require(_0xaace('0x4'));var client=jayson[_0xaace('0x5')]['http']({'port':0x232a});function respondWithRpcPromise(_0x292f5c,_0x2e7a34,_0x38de3d){return new BPromise(function(_0x3e6a89,_0x3c2928){return client[_0xaace('0x6')](_0x292f5c,_0x38de3d)[_0xaace('0x7')](function(_0x151bde){logger[_0xaace('0x8')]('SquareRecording,\x20%s,\x20%s',_0x2e7a34,_0xaace('0x9'));logger[_0xaace('0xa')](_0xaace('0xb'),_0x2e7a34,_0xaace('0x9'),JSON['stringify'](_0x151bde));if(_0x151bde[_0xaace('0xc')]){if(_0x151bde[_0xaace('0xc')][_0xaace('0xd')]===0x1f4){logger[_0xaace('0xc')]('SquareRecording,\x20%s,\x20%s',_0x2e7a34,_0x151bde[_0xaace('0xc')][_0xaace('0xe')]);return _0x3c2928(_0x151bde[_0xaace('0xc')][_0xaace('0xe')]);}logger[_0xaace('0xc')](_0xaace('0xf'),_0x2e7a34,_0x151bde[_0xaace('0xc')][_0xaace('0xe')]);return _0x3e6a89(_0x151bde[_0xaace('0xc')][_0xaace('0xe')]);}else{logger[_0xaace('0x8')](_0xaace('0xf'),_0x2e7a34,_0xaace('0x9'));_0x3e6a89(_0x151bde['result'][_0xaace('0xe')]);}})[_0xaace('0x10')](function(_0x2658a5){logger['error'](_0xaace('0xf'),_0x2e7a34,_0x2658a5);_0x3c2928(_0x2658a5);});});}exports['CreateSquareRecording']=function(_0x129eb8){var _0x5d3fa5=this;return new Promise(function(_0x141054,_0x10e111){return db['SquareRecording'][_0xaace('0x11')](_0x129eb8[_0xaace('0x12')],{'raw':_0x129eb8[_0xaace('0x13')]?_0x129eb8['options'][_0xaace('0x14')]===undefined?!![]:![]:!![]})[_0xaace('0x7')](function(_0x5bd5e2){logger[_0xaace('0x8')]('CreateSquareRecording',_0x129eb8);logger['debug'](_0xaace('0x15'),_0x129eb8,JSON[_0xaace('0x16')](_0x5bd5e2));_0x141054(_0x5bd5e2);})['catch'](function(_0x20368b){logger['error']('CreateSquareRecording',_0x20368b['message'],_0x129eb8);_0x10e111(_0x5d3fa5['error'](0x1f4,_0x20368b['message']));});});};