mirror of
https://github.com/AskDavis/Casinotest.git
synced 2026-01-10 06:39:46 -08:00
Coin Information API integrated
This commit is contained in:
@@ -31,6 +31,11 @@ void CasinoCoinWebAPI::GetActiveExchanges()
|
||||
Get( s_strServerAddress + s_strServerEndpoint + "/ActiveExchanges" );
|
||||
}
|
||||
|
||||
void CasinoCoinWebAPI::GetCoinInfo()
|
||||
{
|
||||
Get( s_strServerAddress + s_strServerEndpoint + "/CoinInfo" );
|
||||
}
|
||||
|
||||
void CasinoCoinWebAPI::Get( const QString& a_rUrl )
|
||||
{
|
||||
QUrl oUrl ( a_rUrl );
|
||||
@@ -43,7 +48,7 @@ void CasinoCoinWebAPI::slotParseNetworkResponse( QNetworkReply *finished )
|
||||
if ( finished->error() != QNetworkReply::NoError )
|
||||
{
|
||||
// A communication error has occurred
|
||||
qDebug() << finished->request().url();
|
||||
qDebug() << "API Network Error: " << finished->errorString();
|
||||
emit signalNetworkError( finished->error(), finished->request().url() );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
void GetActiveCasinos();
|
||||
void GetActiveNewsItems();
|
||||
void GetActiveExchanges();
|
||||
void GetCoinInfo();
|
||||
|
||||
static const QString s_strServerAddress;
|
||||
static const QString s_strServerEndpoint;
|
||||
|
||||
@@ -48,8 +48,21 @@ void CasinoCoinWebAPIParser::slotParseAnswer( const QByteArray& a_rJsonFile )
|
||||
StoreFile( "ActiveExchanges", a_rJsonFile );
|
||||
ParseExchanges( docAsObject );
|
||||
}
|
||||
}
|
||||
else if ( jsonObjectResult.find( "CoinInfo" ).value().isObject() )
|
||||
{
|
||||
StoreFile( "CoinInfo", a_rJsonFile );
|
||||
ParseCoinInfo( docAsObject );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "CasinoCoinWebAPIParser -> No Result object found: " << docAsObject.begin().key();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "CasinoCoinWebAPIParser -> Parse Error: " << oError.errorString();
|
||||
}
|
||||
}
|
||||
|
||||
void CasinoCoinWebAPIParser::slotNetworkError( QNetworkReply::NetworkError a_eError
|
||||
@@ -85,6 +98,12 @@ void CasinoCoinWebAPIParser::ParseNewsItems( const QJsonObject& a_rJsonNewsItems
|
||||
qDebug() << a_rJsonNewsItems;
|
||||
}
|
||||
|
||||
void CasinoCoinWebAPIParser::ParseCoinInfo( const QJsonObject& a_rJsonCoinInfo )
|
||||
{
|
||||
qDebug() << "ParseCoinInfo";
|
||||
emit signalCoinInfoParsed( new JsonCoinInfoParser( a_rJsonCoinInfo ) );
|
||||
}
|
||||
|
||||
QByteArray CasinoCoinWebAPIParser::ReadFile( QString a_strSourcePath )
|
||||
{
|
||||
QByteArray strAnswer;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "jsonactivepromotionsparser.h"
|
||||
#include "jsonsingleactivepromotion.h"
|
||||
#include "jsoncoininfoparser.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
|
||||
signals:
|
||||
void signalActivePromotionsParsed( JsonActivePromotionsParser* a_pActivePromotions );
|
||||
void signalCoinInfoParsed( JsonCoinInfoParser* a_pCoinInfo );
|
||||
// void signalActiveCasinosParsed( JsonActiveCasinosParser* a_pActivePromotions );
|
||||
// void signalActiveExchangesParsed( JsonActiveExchangesParser* a_pActivePromotions );
|
||||
// void signalActiveNewsItemsParsed( JsonActiveNewsItemsParser* a_pActivePromotions );
|
||||
@@ -32,6 +34,7 @@ private:
|
||||
void ParseCasinos ( const QJsonObject& a_rJsonCasinos );
|
||||
void ParseExchanges ( const QJsonObject& a_rJsonExchanges );
|
||||
void ParseNewsItems ( const QJsonObject& a_rJsonNewsItems );
|
||||
void ParseCoinInfo ( const QJsonObject& a_rJsonCoinInfo );
|
||||
|
||||
QByteArray ReadFile( QString a_strSourcePath );
|
||||
void StoreFile( QString a_strDestinationPath, const QByteArray& a_rJsonFile );
|
||||
|
||||
29
src/qt/CSCPublicAPI/jsoncoininfoparser.cpp
Normal file
29
src/qt/CSCPublicAPI/jsoncoininfoparser.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "jsoncoininfoparser.h"
|
||||
#include <QDebug>
|
||||
|
||||
JsonCoinInfoParser::JsonCoinInfoParser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JsonCoinInfoParser::JsonCoinInfoParser( const QJsonObject& apiResult )
|
||||
: QJsonObject( apiResult )
|
||||
{
|
||||
qDebug() << "JsonCoinInfoParser: " << apiResult.begin().key();
|
||||
if ( apiResult.find( "Result" ).value().isObject() )
|
||||
{
|
||||
if ( apiResult.find( "Result" ).value().toObject().find( "CoinInfo" ).value().isObject() )
|
||||
{
|
||||
coinInfoObject = apiResult.find( "Result" ).value().toObject().find( "CoinInfo" ).value().toObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"JsonCoinInfoParser first key: " << apiResult.find( "Result" ).value().toObject().begin().key();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QJsonObject& JsonCoinInfoParser::getCoinInfo() const
|
||||
{
|
||||
return coinInfoObject;
|
||||
}
|
||||
20
src/qt/CSCPublicAPI/jsoncoininfoparser.h
Normal file
20
src/qt/CSCPublicAPI/jsoncoininfoparser.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef JSONCOININFOPARSER_H
|
||||
#define JSONCOININFOPARSER_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
class JsonCoinInfoParser : public QJsonObject
|
||||
{
|
||||
public:
|
||||
JsonCoinInfoParser();
|
||||
JsonCoinInfoParser( const QJsonObject& a_rOther );
|
||||
virtual ~JsonCoinInfoParser(){}
|
||||
|
||||
const QJsonObject& getCoinInfo() const;
|
||||
|
||||
private:
|
||||
QJsonObject coinInfoObject;
|
||||
};
|
||||
|
||||
#endif // JSONCOININFOPARSER_H
|
||||
Reference in New Issue
Block a user