From 25f852a24e76632581c4d78a461fbdef2141648d Mon Sep 17 00:00:00 2001 From: tacosontitan Date: Tue, 30 Jul 2024 20:28:48 -0500 Subject: [PATCH] Defined location lookup API models. --- .../Locations/LocationLookupEndpoint.cs | 21 +++++++++++++++ .../Locations/LocationLookupRequest.cs | 22 +++++++++++++++ .../Locations/LocationLookupResponse.cs | 27 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/Weatherstack/Locations/LocationLookupEndpoint.cs create mode 100644 src/Weatherstack/Locations/LocationLookupRequest.cs create mode 100644 src/Weatherstack/Locations/LocationLookupResponse.cs diff --git a/src/Weatherstack/Locations/LocationLookupEndpoint.cs b/src/Weatherstack/Locations/LocationLookupEndpoint.cs new file mode 100644 index 0000000..4a9ccaa --- /dev/null +++ b/src/Weatherstack/Locations/LocationLookupEndpoint.cs @@ -0,0 +1,21 @@ +// Copyright (c) 2024 tacosontitan +// This file is part of the Weatherstack project, which is distributed under the MIT license. +// See LICENSE for more information. + +using System.Net.Http; + +using Weatherstack.Net; + +namespace Weatherstack.Locations; + +/// +/// Defines the +/// +/// location lookup +/// +/// endpoint for the Weatherstack API. +/// +internal sealed class LocationLookupEndpoint() + : ApiEndpoint( + method: HttpMethod.Get, + url: "https://api.weatherstack.com/autocomplete"); diff --git a/src/Weatherstack/Locations/LocationLookupRequest.cs b/src/Weatherstack/Locations/LocationLookupRequest.cs new file mode 100644 index 0000000..7c7d888 --- /dev/null +++ b/src/Weatherstack/Locations/LocationLookupRequest.cs @@ -0,0 +1,22 @@ +// Copyright (c) 2024 tacosontitan +// This file is part of the Weatherstack project, which is distributed under the MIT license. +// See LICENSE for more information. + +using System.Text.Json.Serialization; + +using Weatherstack.Net; + +namespace Weatherstack.Locations; + +/// +/// Represents a location lookup request within the Weatherstack API. +/// +public sealed class LocationLookupRequest + : ApiRequest +{ + /// + /// Gets or sets number of results returned. + /// + [JsonPropertyName("results")] + public int? ResultCount { get; set; } +} diff --git a/src/Weatherstack/Locations/LocationLookupResponse.cs b/src/Weatherstack/Locations/LocationLookupResponse.cs new file mode 100644 index 0000000..e2c8d5c --- /dev/null +++ b/src/Weatherstack/Locations/LocationLookupResponse.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2024 tacosontitan +// This file is part of the Weatherstack project, which is distributed under the MIT license. +// See LICENSE for more information. + +using System.Collections.ObjectModel; +using System.Text.Json.Serialization; + +using Weatherstack.Net; + +namespace Weatherstack.Locations; + +/// +/// Represents the response to be received from the +/// +/// location lookup +/// +/// endpoint of the Weatherstack API. +/// +public sealed class LocationLookupResponse + : ApiResponse +{ + /// + /// Gets or sets the locations returned by the request. + /// + [JsonPropertyName("locations")] + public ReadOnlyCollection? Locations { get; set; } +}