| 539 | } |
| 540 | |
| 541 | bool 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 | |
| 574 | bool OpenWeatherPlugin::preProcessAsyncWebResponse(const char* payload, size_t payloadSize, DynamicJsonDocument& jsonDoc) |
| 575 | { |
nothing calls this directly
no test coverage detected