6c103fa32e281ec646879c82a7b2850ab022ac32
[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 _0x2b28=['../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','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','options','raw','lodash','util','moment','ioredis'];(function(_0x5951b9,_0xa33e50){var _0x426c13=function(_0x1cd3a4){while(--_0x1cd3a4){_0x5951b9['push'](_0x5951b9['shift']());}};_0x426c13(++_0xa33e50);}(_0x2b28,0x1d8));var _0x82b2=function(_0x4358f5,_0x5b1ac6){_0x4358f5=_0x4358f5-0x0;var _0x4d8104=_0x2b28[_0x4358f5];return _0x4d8104;};'use strict';var _=require(_0x82b2('0x0'));var util=require(_0x82b2('0x1'));var moment=require(_0x82b2('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x82b2('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x82b2('0x4'));var logger=require(_0x82b2('0x5'))(_0x82b2('0x6'));var config=require(_0x82b2('0x7'));var jayson=require(_0x82b2('0x8'));var client=jayson[_0x82b2('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1ad117,_0x2ea9fc,_0x299f1a){return new BPromise(function(_0x546e6c,_0x1e5259){return client[_0x82b2('0xa')](_0x1ad117,_0x299f1a)[_0x82b2('0xb')](function(_0x30aa23){logger[_0x82b2('0xc')]('SquareRecording,\x20%s,\x20%s',_0x2ea9fc,_0x82b2('0xd'));logger[_0x82b2('0xe')](_0x82b2('0xf'),_0x2ea9fc,_0x82b2('0xd'),JSON[_0x82b2('0x10')](_0x30aa23));if(_0x30aa23[_0x82b2('0x11')]){if(_0x30aa23[_0x82b2('0x11')][_0x82b2('0x12')]===0x1f4){logger[_0x82b2('0x11')](_0x82b2('0x13'),_0x2ea9fc,_0x30aa23[_0x82b2('0x11')]['message']);return _0x1e5259(_0x30aa23[_0x82b2('0x11')]['message']);}logger['error'](_0x82b2('0x13'),_0x2ea9fc,_0x30aa23[_0x82b2('0x11')][_0x82b2('0x14')]);return _0x546e6c(_0x30aa23['error'][_0x82b2('0x14')]);}else{logger[_0x82b2('0xc')](_0x82b2('0x13'),_0x2ea9fc,'request\x20sent');_0x546e6c(_0x30aa23[_0x82b2('0x15')]['message']);}})[_0x82b2('0x16')](function(_0x96f8f7){logger[_0x82b2('0x11')]('SquareRecording,\x20%s,\x20%s',_0x2ea9fc,_0x96f8f7);_0x1e5259(_0x96f8f7);});});}exports[_0x82b2('0x17')]=function(_0xfc3354){var _0x3bcc2b=this;return new Promise(function(_0x367dca,_0x207f8b){return db[_0x82b2('0x18')][_0x82b2('0x19')](_0xfc3354['body'],{'raw':_0xfc3354['options']?_0xfc3354[_0x82b2('0x1a')][_0x82b2('0x1b')]===undefined?!![]:![]:!![]})[_0x82b2('0xb')](function(_0x5d6824){logger['info']('CreateSquareRecording',_0xfc3354);logger[_0x82b2('0xe')]('CreateSquareRecording',_0xfc3354,JSON[_0x82b2('0x10')](_0x5d6824));_0x367dca(_0x5d6824);})[_0x82b2('0x16')](function(_0x2d8cfb){logger[_0x82b2('0x11')](_0x82b2('0x17'),_0x2d8cfb[_0x82b2('0x14')],_0xfc3354);_0x207f8b(_0x3bcc2b['error'](0x1f4,_0x2d8cfb[_0x82b2('0x14')]));});});};