c915d65a8d26ee6ae556539743711906e54a1c3b
[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 _0x3408=['SquareRecording,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','CreateSquareRecording','SquareRecording','create','body','options','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','then','info','SquareRecording,\x20%s,\x20%s','debug'];(function(_0x324df7,_0x5053af){var _0x2584cf=function(_0x2a5075){while(--_0x2a5075){_0x324df7['push'](_0x324df7['shift']());}};_0x2584cf(++_0x5053af);}(_0x3408,0x11a));var _0x8340=function(_0x10cd49,_0x3affdc){_0x10cd49=_0x10cd49-0x0;var _0x5594d7=_0x3408[_0x10cd49];return _0x5594d7;};'use strict';var _=require('lodash');var util=require(_0x8340('0x0'));var moment=require(_0x8340('0x1'));var BPromise=require(_0x8340('0x2'));var rs=require(_0x8340('0x3'));var fs=require('fs');var Redis=require(_0x8340('0x4'));var db=require(_0x8340('0x5'))['db'];var utils=require(_0x8340('0x6'));var logger=require(_0x8340('0x7'))('rpc');var config=require(_0x8340('0x8'));var jayson=require(_0x8340('0x9'));var client=jayson[_0x8340('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x370cd8,_0x4007a0,_0x5ea79a){return new BPromise(function(_0x45e172,_0x52a7c4){return client['request'](_0x370cd8,_0x5ea79a)[_0x8340('0xb')](function(_0x53062e){logger[_0x8340('0xc')](_0x8340('0xd'),_0x4007a0,'request\x20sent');logger[_0x8340('0xe')](_0x8340('0xf'),_0x4007a0,_0x8340('0x10'),JSON[_0x8340('0x11')](_0x53062e));if(_0x53062e['error']){if(_0x53062e[_0x8340('0x12')][_0x8340('0x13')]===0x1f4){logger[_0x8340('0x12')]('SquareRecording,\x20%s,\x20%s',_0x4007a0,_0x53062e[_0x8340('0x12')][_0x8340('0x14')]);return _0x52a7c4(_0x53062e['error'][_0x8340('0x14')]);}logger[_0x8340('0x12')](_0x8340('0xd'),_0x4007a0,_0x53062e[_0x8340('0x12')]['message']);return _0x45e172(_0x53062e['error'][_0x8340('0x14')]);}else{logger['info'](_0x8340('0xd'),_0x4007a0,_0x8340('0x10'));_0x45e172(_0x53062e['result'][_0x8340('0x14')]);}})[_0x8340('0x15')](function(_0x5338b5){logger[_0x8340('0x12')](_0x8340('0xd'),_0x4007a0,_0x5338b5);_0x52a7c4(_0x5338b5);});});}exports[_0x8340('0x16')]=function(_0x1e6253){var _0x48db65=this;return new Promise(function(_0x3acd91,_0x1a1d79){return db[_0x8340('0x17')][_0x8340('0x18')](_0x1e6253[_0x8340('0x19')],{'raw':_0x1e6253['options']?_0x1e6253[_0x8340('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0x8340('0xb')](function(_0x5bceee){logger[_0x8340('0xc')](_0x8340('0x16'),_0x1e6253);logger[_0x8340('0xe')](_0x8340('0x16'),_0x1e6253,JSON['stringify'](_0x5bceee));_0x3acd91(_0x5bceee);})[_0x8340('0x15')](function(_0x557e56){logger['error'](_0x8340('0x16'),_0x557e56[_0x8340('0x14')],_0x1e6253);_0x1a1d79(_0x48db65[_0x8340('0x12')](0x1f4,_0x557e56[_0x8340('0x14')]));});});};