d83c1bb3890e56f110285a1aae22aa48aaf9ad2c
[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 _0xc7fc=['catch','SquareRecording','body','options','CreateSquareRecording','debug','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','info','request\x20sent','SquareRecording,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result'];(function(_0x243b59,_0x3f9495){var _0x3e1676=function(_0x354052){while(--_0x354052){_0x243b59['push'](_0x243b59['shift']());}};_0x3e1676(++_0x3f9495);}(_0xc7fc,0xf9));var _0xcc7f=function(_0x145435,_0x326220){_0x145435=_0x145435-0x0;var _0x55a234=_0xc7fc[_0x145435];return _0x55a234;};'use strict';var _=require('lodash');var util=require(_0xcc7f('0x0'));var moment=require(_0xcc7f('0x1'));var BPromise=require(_0xcc7f('0x2'));var rs=require(_0xcc7f('0x3'));var fs=require('fs');var Redis=require(_0xcc7f('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xcc7f('0x5'));var logger=require(_0xcc7f('0x6'))(_0xcc7f('0x7'));var config=require(_0xcc7f('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xcc7f('0x9')][_0xcc7f('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3ea0a2,_0x492498,_0xad2b39){return new BPromise(function(_0xa0fb75,_0x265a02){return client[_0xcc7f('0xb')](_0x3ea0a2,_0xad2b39)[_0xcc7f('0xc')](function(_0x38bc0e){logger[_0xcc7f('0xd')]('SquareRecording,\x20%s,\x20%s',_0x492498,_0xcc7f('0xe'));logger['debug'](_0xcc7f('0xf'),_0x492498,_0xcc7f('0xe'),JSON[_0xcc7f('0x10')](_0x38bc0e));if(_0x38bc0e[_0xcc7f('0x11')]){if(_0x38bc0e['error'][_0xcc7f('0x12')]===0x1f4){logger['error']('SquareRecording,\x20%s,\x20%s',_0x492498,_0x38bc0e[_0xcc7f('0x11')][_0xcc7f('0x13')]);return _0x265a02(_0x38bc0e[_0xcc7f('0x11')]['message']);}logger[_0xcc7f('0x11')]('SquareRecording,\x20%s,\x20%s',_0x492498,_0x38bc0e[_0xcc7f('0x11')][_0xcc7f('0x13')]);return _0xa0fb75(_0x38bc0e['error'][_0xcc7f('0x13')]);}else{logger[_0xcc7f('0xd')]('SquareRecording,\x20%s,\x20%s',_0x492498,_0xcc7f('0xe'));_0xa0fb75(_0x38bc0e[_0xcc7f('0x14')][_0xcc7f('0x13')]);}})[_0xcc7f('0x15')](function(_0x4c5274){logger['error']('SquareRecording,\x20%s,\x20%s',_0x492498,_0x4c5274);_0x265a02(_0x4c5274);});});}exports['CreateSquareRecording']=function(_0x5f41d4){var _0x48c347=this;return new Promise(function(_0x250349,_0x16004c){return db[_0xcc7f('0x16')]['create'](_0x5f41d4[_0xcc7f('0x17')],{'raw':_0x5f41d4[_0xcc7f('0x18')]?_0x5f41d4[_0xcc7f('0x18')]['raw']===undefined?!![]:![]:!![]})[_0xcc7f('0xc')](function(_0x3caaee){logger[_0xcc7f('0xd')](_0xcc7f('0x19'),_0x5f41d4);logger[_0xcc7f('0x1a')](_0xcc7f('0x19'),_0x5f41d4,JSON[_0xcc7f('0x10')](_0x3caaee));_0x250349(_0x3caaee);})[_0xcc7f('0x15')](function(_0x1cf687){logger['error']('CreateSquareRecording',_0x1cf687[_0xcc7f('0x13')],_0x5f41d4);_0x16004c(_0x48c347['error'](0x1f4,_0x1cf687[_0xcc7f('0x13')]));});});};