From c871bcf6db13138d70927739630b17c11ebfda2f Mon Sep 17 00:00:00 2001 From: afkiwers Date: Tue, 23 Jan 2024 12:36:10 +1100 Subject: [PATCH] removed unnecessary variables --- common/http_lib/http_lib_connection.cpp | 15 ++++++--------- include/http_lib/http_lib_connection.h | 7 ++----- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/common/http_lib/http_lib_connection.cpp b/common/http_lib/http_lib_connection.cpp index 684f310c9c..7a2f31553c 100644 --- a/common/http_lib/http_lib_connection.cpp +++ b/common/http_lib/http_lib_connection.cpp @@ -36,10 +36,7 @@ const char* const traceHTTPLib = "KICAD_HTTP_LIB"; HTTP_LIB_CONNECTION::HTTP_LIB_CONNECTION( const HTTP_LIB_SOURCE& aSource, bool aTestConnectionNow ) { - m_rootURL = aSource.root_url; - m_token = aSource.token; - m_sourceType = aSource.type; - m_timeout = aSource.timeout_parts; + m_source = aSource; if( aTestConnectionNow ) { @@ -60,7 +57,7 @@ bool HTTP_LIB_CONNECTION::ValidateHTTPLibraryEndpoints() std::string res = ""; std::unique_ptr curl = createCurlEasyObject(); - curl->SetURL( m_rootURL ); + curl->SetURL( m_source.root_url ); try { @@ -126,7 +123,7 @@ bool HTTP_LIB_CONNECTION::syncCategories() std::string res = ""; std::unique_ptr curl = createCurlEasyObject(); - curl->SetURL( m_rootURL + http_endpoint_categories + ".json" ); + curl->SetURL( m_source.root_url + http_endpoint_categories + ".json" ); try { @@ -182,7 +179,7 @@ bool HTTP_LIB_CONNECTION::SelectOne( const std::string& aPartID, HTTP_LIB_PART& if( m_cachedParts.find( aPartID ) != m_cachedParts.end() ) { // check if it's outdated, if so re-fetch - if( std::difftime( std::time( nullptr ), m_cachedParts[aPartID].lastCached ) < m_timeout ) + if( std::difftime( std::time( nullptr ), m_cachedParts[aPartID].lastCached ) < m_source.timeout_parts ) { aFetchedPart = m_cachedParts[aPartID]; return true; @@ -193,7 +190,7 @@ bool HTTP_LIB_CONNECTION::SelectOne( const std::string& aPartID, HTTP_LIB_PART& std::string res = ""; std::unique_ptr curl = createCurlEasyObject(); - curl->SetURL( m_rootURL + fmt::format( http_endpoint_parts + "/{}.json", aPartID ) ); + curl->SetURL( m_source.root_url + fmt::format( http_endpoint_parts + "/{}.json", aPartID ) ); try { @@ -312,7 +309,7 @@ bool HTTP_LIB_CONNECTION::SelectAll( const HTTP_LIB_CATEGORY& aCategory, std::string res = ""; std::unique_ptr curl = createCurlEasyObject(); - curl->SetURL( m_rootURL + curl->SetURL( m_source.root_url + fmt::format( http_endpoint_parts + "/category/{}.json", aCategory.id ) ); try diff --git a/include/http_lib/http_lib_connection.h b/include/http_lib/http_lib_connection.h index 342aeffc6a..43399d3f8d 100644 --- a/include/http_lib/http_lib_connection.h +++ b/include/http_lib/http_lib_connection.h @@ -73,7 +73,7 @@ private: // prepare curl aCurl->SetHeader( "Accept", "application/json" ); - aCurl->SetHeader( "Authorization", "Token " + m_token ); + aCurl->SetHeader( "Authorization", "Token " + m_source.token ); return aCurl; } @@ -88,11 +88,8 @@ private: wxString httpErrorCodeDescription( uint16_t aHttpCode ); - std::string m_token; - std::string m_rootURL; - int m_timeout; - HTTP_LIB_SOURCE_TYPE m_sourceType; + HTTP_LIB_SOURCE m_source; // part.id part std::map m_cachedParts;