24#include <boost/algorithm/string.hpp>
60 using RETRIEVER = std::function<bool(
const std::string& aUrl,
int& aStatusCode,
61 std::string& aBody, std::string& aError )>;
129 auto it =
m_cache.find( aPartName );
134 aPartId = std::get<0>( it->second );
135 aCategoryId = std::get<1>( it->second );
157 bool retrieve(
const std::string& aUrl,
int& aStatusCode, std::string& aBody );
192 std::map<std::string, std::tuple<std::string, std::string>>
m_cache;
bool GetCachedPartRelation(const std::string &aPartName, std::string &aPartId, std::string &aCategoryId) const
Resolve a cached part name to its part ID and category ID.
std::map< std::string, std::string > m_parts
bool validateHttpLibraryEndpoints()
std::vector< HTTP_LIB_CATEGORY > getCategories() const
std::map< std::string, HTTP_LIB_PART > m_cachedParts
std::map< std::string, std::string > m_categoryDescriptions
bool checkServerResponse(int aStatusCode)
bool retrieve(const std::string &aUrl, int &aStatusCode, std::string &aBody)
Fetch aUrl through the transport.
bool SelectAll(const HTTP_LIB_CATEGORY &aCategory, std::vector< HTTP_LIB_PART > &aParts)
Retrieve all parts from a specific category from the HTTP library.
HTTP_LIB_CONNECTION(const HTTP_LIB_SOURCE &aSource, bool aTestConnectionNow)
std::map< std::string, std::tuple< std::string, std::string > > m_cache
std::vector< HTTP_LIB_CATEGORY > m_categories
bool IsValidEndpoint() const
virtual ~HTTP_LIB_CONNECTION()=default
std::function< bool(const std::string &aUrl, int &aStatusCode, std::string &aBody, std::string &aError)> RETRIEVER
Allows replacing CURL fetches with a mock for testing.
bool SelectOne(const std::string &aPartID, HTTP_LIB_PART &aFetchedPart)
Retrieve a single part with full details from the HTTP library.
wxString httpErrorCodeDescription(uint16_t aHttpCode)
HTTP response status codes indicate whether a specific HTTP request has been successfully completed.
std::string GetLastError() const
std::string getCategoryDescription(const std::string &aCategoryName) const
bool HasCachedParts() const
const char *const traceHTTPLib
bool setPartExtendedData(const nlohmann::json &aPartJson, HTTP_LIB_PART &aPart)
Parse the exclusion flags and field content from a part's JSON record into aPart.
Connection parameters for one HTTP library.