removed unnecessary variables
This commit is contained in:
parent
c7475a16c8
commit
c871bcf6db
|
@ -36,10 +36,7 @@ const char* const traceHTTPLib = "KICAD_HTTP_LIB";
|
||||||
|
|
||||||
HTTP_LIB_CONNECTION::HTTP_LIB_CONNECTION( const HTTP_LIB_SOURCE& aSource, bool aTestConnectionNow )
|
HTTP_LIB_CONNECTION::HTTP_LIB_CONNECTION( const HTTP_LIB_SOURCE& aSource, bool aTestConnectionNow )
|
||||||
{
|
{
|
||||||
m_rootURL = aSource.root_url;
|
m_source = aSource;
|
||||||
m_token = aSource.token;
|
|
||||||
m_sourceType = aSource.type;
|
|
||||||
m_timeout = aSource.timeout_parts;
|
|
||||||
|
|
||||||
if( aTestConnectionNow )
|
if( aTestConnectionNow )
|
||||||
{
|
{
|
||||||
|
@ -60,7 +57,7 @@ bool HTTP_LIB_CONNECTION::ValidateHTTPLibraryEndpoints()
|
||||||
std::string res = "";
|
std::string res = "";
|
||||||
|
|
||||||
std::unique_ptr<KICAD_CURL_EASY> curl = createCurlEasyObject();
|
std::unique_ptr<KICAD_CURL_EASY> curl = createCurlEasyObject();
|
||||||
curl->SetURL( m_rootURL );
|
curl->SetURL( m_source.root_url );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -126,7 +123,7 @@ bool HTTP_LIB_CONNECTION::syncCategories()
|
||||||
std::string res = "";
|
std::string res = "";
|
||||||
|
|
||||||
std::unique_ptr<KICAD_CURL_EASY> curl = createCurlEasyObject();
|
std::unique_ptr<KICAD_CURL_EASY> curl = createCurlEasyObject();
|
||||||
curl->SetURL( m_rootURL + http_endpoint_categories + ".json" );
|
curl->SetURL( m_source.root_url + http_endpoint_categories + ".json" );
|
||||||
|
|
||||||
try
|
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() )
|
if( m_cachedParts.find( aPartID ) != m_cachedParts.end() )
|
||||||
{
|
{
|
||||||
// check if it's outdated, if so re-fetch
|
// 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];
|
aFetchedPart = m_cachedParts[aPartID];
|
||||||
return true;
|
return true;
|
||||||
|
@ -193,7 +190,7 @@ bool HTTP_LIB_CONNECTION::SelectOne( const std::string& aPartID, HTTP_LIB_PART&
|
||||||
std::string res = "";
|
std::string res = "";
|
||||||
|
|
||||||
std::unique_ptr<KICAD_CURL_EASY> curl = createCurlEasyObject();
|
std::unique_ptr<KICAD_CURL_EASY> 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
|
try
|
||||||
{
|
{
|
||||||
|
@ -312,7 +309,7 @@ bool HTTP_LIB_CONNECTION::SelectAll( const HTTP_LIB_CATEGORY& aCategory,
|
||||||
std::string res = "";
|
std::string res = "";
|
||||||
|
|
||||||
std::unique_ptr<KICAD_CURL_EASY> curl = createCurlEasyObject();
|
std::unique_ptr<KICAD_CURL_EASY> curl = createCurlEasyObject();
|
||||||
curl->SetURL( m_rootURL
|
curl->SetURL( m_source.root_url
|
||||||
+ fmt::format( http_endpoint_parts + "/category/{}.json", aCategory.id ) );
|
+ fmt::format( http_endpoint_parts + "/category/{}.json", aCategory.id ) );
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -73,7 +73,7 @@ private:
|
||||||
|
|
||||||
// prepare curl
|
// prepare curl
|
||||||
aCurl->SetHeader( "Accept", "application/json" );
|
aCurl->SetHeader( "Accept", "application/json" );
|
||||||
aCurl->SetHeader( "Authorization", "Token " + m_token );
|
aCurl->SetHeader( "Authorization", "Token " + m_source.token );
|
||||||
|
|
||||||
return aCurl;
|
return aCurl;
|
||||||
}
|
}
|
||||||
|
@ -88,11 +88,8 @@ private:
|
||||||
|
|
||||||
wxString httpErrorCodeDescription( uint16_t aHttpCode );
|
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_TYPE m_sourceType;
|
||||||
|
HTTP_LIB_SOURCE m_source;
|
||||||
|
|
||||||
// part.id part
|
// part.id part
|
||||||
std::map<std::string, HTTP_LIB_PART> m_cachedParts;
|
std::map<std::string, HTTP_LIB_PART> m_cachedParts;
|
||||||
|
|
Loading…
Reference in New Issue