diff options
Diffstat (limited to 'server/src/rwgps.cppm')
| -rw-r--r-- | server/src/rwgps.cppm | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/server/src/rwgps.cppm b/server/src/rwgps.cppm index 8269ee8..f2f1681 100644 --- a/server/src/rwgps.cppm +++ b/server/src/rwgps.cppm | |||
| @@ -46,50 +46,50 @@ struct get_routes_response | |||
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | auto tag_invoke(json::value_to_tag<route_summary> const&, json::value const& jv) | 48 | auto tag_invoke(json::value_to_tag<route_summary> const&, json::value const& jv) |
| 49 | -> route_summary | 49 | -> route_summary |
| 50 | { | 50 | { |
| 51 | return { | 51 | return { |
| 52 | .id = json::value_to<std::int64_t>(jv.at("id")), | 52 | .id = json::value_to<std::int64_t>(jv.at("id")), |
| 53 | .user_id = json::value_to<std::int64_t>(jv.at("user_id")), | 53 | .user_id = json::value_to<std::int64_t>(jv.at("user_id")), |
| 54 | .url = json::value_to<std::string>(jv.at("url")), | 54 | .url = json::value_to<std::string>(jv.at("url")), |
| 55 | .name = json::value_to<std::string>(jv.at("name")), | 55 | .name = json::value_to<std::string>(jv.at("name")), |
| 56 | .description = json::value_to<std::string>(jv.at("description")), | 56 | .description = json::value_to<std::string>(jv.at("description")), |
| 57 | }; | 57 | }; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | auto tag_invoke(json::value_to_tag<pagination> const&, json::value const& jv) | 60 | auto tag_invoke(json::value_to_tag<pagination> const&, json::value const& jv) |
| 61 | -> pagination | 61 | -> pagination |
| 62 | { | 62 | { |
| 63 | return { | 63 | return { |
| 64 | .record_count = json::value_to<std::size_t>(jv.at("record_count")), | 64 | .record_count = json::value_to<std::size_t>(jv.at("record_count")), |
| 65 | .page_count = json::value_to<std::size_t>(jv.at("page_count")), | 65 | .page_count = json::value_to<std::size_t>(jv.at("page_count")), |
| 66 | .page_size = json::value_to<std::size_t>(jv.at("page_size")), | 66 | .page_size = json::value_to<std::size_t>(jv.at("page_size")), |
| 67 | .next_page_url = | 67 | .next_page_url = |
| 68 | json::value_to<std::optional<std::string>>(jv.at("next_page_url")), | 68 | json::value_to<std::optional<std::string>>(jv.at("next_page_url")), |
| 69 | }; | 69 | }; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | auto tag_invoke( | 72 | auto tag_invoke( |
| 73 | json::value_to_tag<get_routes_meta> const&, json::value const& jv) | 73 | json::value_to_tag<get_routes_meta> const&, json::value const& jv) |
| 74 | -> get_routes_meta | 74 | -> get_routes_meta |
| 75 | { | 75 | { |
| 76 | return { | 76 | return { |
| 77 | .pagination = json::value_to<pagination>(jv.at("pagination")), | 77 | .pagination = json::value_to<pagination>(jv.at("pagination")), |
| 78 | }; | 78 | }; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | auto tag_invoke( | 81 | auto tag_invoke( |
| 82 | json::value_to_tag<get_routes_response> const&, json::value const& jv) | 82 | json::value_to_tag<get_routes_response> const&, json::value const& jv) |
| 83 | -> get_routes_response | 83 | -> get_routes_response |
| 84 | { | 84 | { |
| 85 | return { | 85 | return { |
| 86 | .routes = json::value_to<std::vector<route_summary>>(jv.at("routes")), | 86 | .routes = json::value_to<std::vector<route_summary>>(jv.at("routes")), |
| 87 | .meta = json::value_to<get_routes_meta>(jv.at("meta")), | 87 | .meta = json::value_to<get_routes_meta>(jv.at("meta")), |
| 88 | }; | 88 | }; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | auto json_value_to_get_routes_response(json::value const& jv) | 91 | auto json_value_to_get_routes_response(json::value const& jv) |
| 92 | -> get_routes_response | 92 | -> get_routes_response |
| 93 | { | 93 | { |
| 94 | return json::value_to<get_routes_response>(jv); | 94 | return json::value_to<get_routes_response>(jv); |
| 95 | } | 95 | } |
| @@ -107,9 +107,9 @@ export class client | |||
| 107 | auto get_routes_page(std::size_t page) -> get_routes_response | 107 | auto get_routes_page(std::size_t page) -> get_routes_response |
| 108 | { | 108 | { |
| 109 | auto req = bhttp::request<bhttp::string_body>{ | 109 | auto req = bhttp::request<bhttp::string_body>{ |
| 110 | bhttp::verb::get, | 110 | bhttp::verb::get, |
| 111 | std::format("/api/v1/routes.json?page_size=200?page={}", page), | 111 | std::format("/api/v1/routes.json?page_size=200?page={}", page), |
| 112 | 11, // HTTP 1.1 | 112 | 11, // HTTP 1.1 |
| 113 | }; | 113 | }; |
| 114 | req.set(bhttp::field::host, host); | 114 | req.set(bhttp::field::host, host); |
| 115 | req.set("x-rwgps-api-key", api_key_); | 115 | req.set("x-rwgps-api-key", api_key_); |
| @@ -127,8 +127,8 @@ export class client | |||
| 127 | 127 | ||
| 128 | public: | 128 | public: |
| 129 | explicit client( | 129 | explicit client( |
| 130 | net::io_context& ioc, log::logger const& l, std::string api_key, | 130 | net::io_context& ioc, log::logger const& l, std::string api_key, |
| 131 | std::string auth_token) | 131 | std::string auth_token) |
| 132 | : l_{l.sub("rwgps-client")}, hc_{ioc}, api_key_{std::move(api_key)}, | 132 | : l_{l.sub("rwgps-client")}, hc_{ioc}, api_key_{std::move(api_key)}, |
| 133 | auth_token_{std::move(auth_token)} | 133 | auth_token_{std::move(auth_token)} |
| 134 | { | 134 | { |