52c0090a8a80b4f8039bb7ccc32e2f332fa38712
[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 _0x7af2=['bluebird','randomstring','../../config/environment','jayson/promise','request','then','info','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','stringify','error','code','SquareRecording,\x20%s,\x20%s','message','result','catch','CreateSquareRecording','SquareRecording','create','body','options','raw','lodash','util','moment'];(function(_0x4c5d84,_0x244cde){var _0x135396=function(_0x1bd442){while(--_0x1bd442){_0x4c5d84['push'](_0x4c5d84['shift']());}};_0x135396(++_0x244cde);}(_0x7af2,0x1eb));var _0x27af=function(_0x201ab2,_0x19ba32){_0x201ab2=_0x201ab2-0x0;var _0x440db9=_0x7af2[_0x201ab2];return _0x440db9;};'use strict';var _=require(_0x27af('0x0'));var util=require(_0x27af('0x1'));var moment=require(_0x27af('0x2'));var BPromise=require(_0x27af('0x3'));var rs=require(_0x27af('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x27af('0x5'));var jayson=require(_0x27af('0x6'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x5c7887,_0x36496c,_0x445b0d){return new BPromise(function(_0x26653e,_0x147b5d){return client[_0x27af('0x7')](_0x5c7887,_0x445b0d)[_0x27af('0x8')](function(_0x1649a9){logger[_0x27af('0x9')]('SquareRecording,\x20%s,\x20%s',_0x36496c,_0x27af('0xa'));logger[_0x27af('0xb')](_0x27af('0xc'),_0x36496c,_0x27af('0xa'),JSON[_0x27af('0xd')](_0x1649a9));if(_0x1649a9['error']){if(_0x1649a9[_0x27af('0xe')][_0x27af('0xf')]===0x1f4){logger['error'](_0x27af('0x10'),_0x36496c,_0x1649a9[_0x27af('0xe')][_0x27af('0x11')]);return _0x147b5d(_0x1649a9['error'][_0x27af('0x11')]);}logger[_0x27af('0xe')]('SquareRecording,\x20%s,\x20%s',_0x36496c,_0x1649a9['error'][_0x27af('0x11')]);return _0x26653e(_0x1649a9[_0x27af('0xe')][_0x27af('0x11')]);}else{logger['info'](_0x27af('0x10'),_0x36496c,_0x27af('0xa'));_0x26653e(_0x1649a9[_0x27af('0x12')]['message']);}})[_0x27af('0x13')](function(_0x4808a1){logger[_0x27af('0xe')](_0x27af('0x10'),_0x36496c,_0x4808a1);_0x147b5d(_0x4808a1);});});}exports[_0x27af('0x14')]=function(_0xd76f7a){var _0x592e09=this;return new Promise(function(_0x483ee6,_0xc01c18){return db[_0x27af('0x15')][_0x27af('0x16')](_0xd76f7a[_0x27af('0x17')],{'raw':_0xd76f7a['options']?_0xd76f7a[_0x27af('0x18')][_0x27af('0x19')]===undefined?!![]:![]:!![]})[_0x27af('0x8')](function(_0x710ed9){logger['info'](_0x27af('0x14'),_0xd76f7a);logger[_0x27af('0xb')](_0x27af('0x14'),_0xd76f7a,JSON[_0x27af('0xd')](_0x710ed9));_0x483ee6(_0x710ed9);})['catch'](function(_0x408a34){logger['error'](_0x27af('0x14'),_0x408a34[_0x27af('0x11')],_0xd76f7a);_0xc01c18(_0x592e09[_0x27af('0xe')](0x1f4,_0x408a34[_0x27af('0x11')]));});});};