2e986e2c09ebb7a69d4df7a3ade235abe283da41
[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 _0x9ac2=['../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','request\x20sent','debug','error','code','SquareRecording,\x20%s,\x20%s','message','info','result','catch','CreateSquareRecording','create','body','options','raw','util','moment','randomstring','ioredis'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x9ac2,0x98));var _0x29ac=function(_0x2f2ed0,_0x1c6435){_0x2f2ed0=_0x2f2ed0-0x0;var _0x250b0d=_0x9ac2[_0x2f2ed0];return _0x250b0d;};'use strict';var _=require('lodash');var util=require(_0x29ac('0x0'));var moment=require(_0x29ac('0x1'));var BPromise=require('bluebird');var rs=require(_0x29ac('0x2'));var fs=require('fs');var Redis=require(_0x29ac('0x3'));var db=require(_0x29ac('0x4'))['db'];var utils=require(_0x29ac('0x5'));var logger=require(_0x29ac('0x6'))('rpc');var config=require(_0x29ac('0x7'));var jayson=require(_0x29ac('0x8'));var client=jayson[_0x29ac('0x9')][_0x29ac('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x9f5328,_0x85a492,_0x6d49b7){return new BPromise(function(_0x1bbe0f,_0x36e665){return client['request'](_0x9f5328,_0x6d49b7)[_0x29ac('0xb')](function(_0xe9369a){logger['info']('SquareRecording,\x20%s,\x20%s',_0x85a492,_0x29ac('0xc'));logger[_0x29ac('0xd')]('SquareRecording,\x20%s,\x20%s,\x20%s',_0x85a492,'request\x20sent',JSON['stringify'](_0xe9369a));if(_0xe9369a[_0x29ac('0xe')]){if(_0xe9369a['error'][_0x29ac('0xf')]===0x1f4){logger[_0x29ac('0xe')](_0x29ac('0x10'),_0x85a492,_0xe9369a['error'][_0x29ac('0x11')]);return _0x36e665(_0xe9369a[_0x29ac('0xe')][_0x29ac('0x11')]);}logger[_0x29ac('0xe')](_0x29ac('0x10'),_0x85a492,_0xe9369a['error'][_0x29ac('0x11')]);return _0x1bbe0f(_0xe9369a[_0x29ac('0xe')][_0x29ac('0x11')]);}else{logger[_0x29ac('0x12')](_0x29ac('0x10'),_0x85a492,_0x29ac('0xc'));_0x1bbe0f(_0xe9369a[_0x29ac('0x13')][_0x29ac('0x11')]);}})[_0x29ac('0x14')](function(_0x5f0889){logger[_0x29ac('0xe')]('SquareRecording,\x20%s,\x20%s',_0x85a492,_0x5f0889);_0x36e665(_0x5f0889);});});}exports[_0x29ac('0x15')]=function(_0x5a2083){var _0x1ba219=this;return new Promise(function(_0x41aaec,_0x414ee8){return db['SquareRecording'][_0x29ac('0x16')](_0x5a2083[_0x29ac('0x17')],{'raw':_0x5a2083[_0x29ac('0x18')]?_0x5a2083[_0x29ac('0x18')][_0x29ac('0x19')]===undefined?!![]:![]:!![]})[_0x29ac('0xb')](function(_0x4151fe){logger['info']('CreateSquareRecording',_0x5a2083);logger[_0x29ac('0xd')](_0x29ac('0x15'),_0x5a2083,JSON['stringify'](_0x4151fe));_0x41aaec(_0x4151fe);})[_0x29ac('0x14')](function(_0x1740f9){logger[_0x29ac('0xe')](_0x29ac('0x15'),_0x1740f9[_0x29ac('0x11')],_0x5a2083);_0x414ee8(_0x1ba219[_0x29ac('0xe')](0x1f4,_0x1740f9[_0x29ac('0x11')]));});});};