|
1 | 1 | #include "databento/historical.hpp" |
2 | 2 |
|
| 3 | +#include <unordered_map> |
| 4 | + |
| 5 | +#include "databento/publishers.hpp" |
| 6 | + |
3 | 7 | #ifndef CPPHTTPLIB_OPENSSL_SUPPORT |
4 | 8 | #define CPPHTTPLIB_OPENSSL_SUPPORT |
5 | 9 | #endif |
@@ -529,8 +533,27 @@ databento::DatasetRange Historical::MetadataGetDatasetRange( |
529 | 533 | if (!json.is_object()) { |
530 | 534 | throw JsonResponseError::TypeMismatch(kEndpoint, "object", json); |
531 | 535 | } |
| 536 | + const auto& schema_json = detail::CheckedAt(kEndpoint, json, "schema"); |
| 537 | + if (!schema_json.is_object()) { |
| 538 | + throw JsonResponseError::TypeMismatch(kEndpoint, "schema object", json); |
| 539 | + } |
| 540 | + std::unordered_map<Schema, DateTimeRange<std::string>> range_by_schema; |
| 541 | + for (const auto& schema_item : schema_json.items()) { |
| 542 | + if (!schema_item.value().is_object()) { |
| 543 | + throw JsonResponseError::TypeMismatch(kEndpoint, "nested schema object", |
| 544 | + json); |
| 545 | + } |
| 546 | + auto start = |
| 547 | + detail::ParseAt<std::string>(kEndpoint, schema_item.value(), "start"); |
| 548 | + auto end = |
| 549 | + detail::ParseAt<std::string>(kEndpoint, schema_item.value(), "end"); |
| 550 | + range_by_schema.emplace( |
| 551 | + FromString<Schema>(schema_item.key()), |
| 552 | + DateTimeRange<std::string>{std::move(start), std::move(end)}); |
| 553 | + } |
532 | 554 | return DatasetRange{detail::ParseAt<std::string>(kEndpoint, json, "start"), |
533 | | - detail::ParseAt<std::string>(kEndpoint, json, "end")}; |
| 555 | + detail::ParseAt<std::string>(kEndpoint, json, "end"), |
| 556 | + std::move(range_by_schema)}; |
534 | 557 | } |
535 | 558 |
|
536 | 559 | static const std::string kMetadataGetRecordCountEndpoint = |
|
0 commit comments