MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / startHttpRequest

Method startHttpRequest

lib/OpenWeatherPlugin/src/OpenWeatherPlugin.cpp:541–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541bool OpenWeatherPlugin::startHttpRequest(const IOpenWeatherGeneric* source)
542{
543 bool status = false;
544 RestService::PreProcessCallback preProcessCallback =
545 [this](const char* payload, size_t size, DynamicJsonDocument& doc) {
546 return this->preProcessAsyncWebResponse(payload, size, doc);
547 };
548
549 if ((nullptr != source) &&
550 (false == source->getApiKey().isEmpty()) &&
551 (false == source->getLatitude().isEmpty()) &&
552 (false == source->getLongitude().isEmpty()) &&
553 (false == source->getUnits().isEmpty()))
554 {
555 String url = OPEN_WEATHER_BASE_URI;
556
557 source->getUrl(url);
558
559 m_dynamicRestId = RestService::getInstance().get(url, preProcessCallback);
560
561 if (RestService::INVALID_REST_ID == m_dynamicRestId)
562 {
563 LOG_WARNING("GET %s failed.", url.c_str());
564 }
565 else
566 {
567 status = true;
568 }
569 }
570
571 return status;
572}
573
574bool OpenWeatherPlugin::preProcessAsyncWebResponse(const char* payload, size_t payloadSize, DynamicJsonDocument& jsonDoc)
575{

Callers

nothing calls this directly

Calls 5

c_strMethod · 0.80
isEmptyMethod · 0.45
getUrlMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected