From 77a52e0bf7a946fc82fbf0af901a8c4fa16924b2 Mon Sep 17 00:00:00 2001 From: qJake Date: Sun, 31 Jan 2021 23:11:51 -0600 Subject: [PATCH] 1.5.1 Fix calendar get request --- HADotNet.Core/Clients/CalendarClient.cs | 74 ++++++++++++------------- HADotNet.Core/HADotNet.Core.csproj | 6 +- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/HADotNet.Core/Clients/CalendarClient.cs b/HADotNet.Core/Clients/CalendarClient.cs index f1e1c8d..2ac32b1 100644 --- a/HADotNet.Core/Clients/CalendarClient.cs +++ b/HADotNet.Core/Clients/CalendarClient.cs @@ -1,37 +1,37 @@ -using HADotNet.Core.Models; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace HADotNet.Core.Clients -{ - /// - /// Provides access to the calendar API for retrieving information about calendar entries. - /// - public sealed class CalendarClient : BaseClient - { - /// - /// Initializes a new instance of the . - /// - /// The Home Assistant base instance URL. - /// The Home Assistant long-lived access token. - public CalendarClient(Uri instance, string apiKey) : base(instance, apiKey) { } - - /// - /// Retrieves a list of current and future calendar items, from now until the specified . The maximum number of results is driven by the "max_results" configuration option in the calendar config. - /// - /// The full name of the calendar entity. If this paramter does not start with "calendar.", it will be prepended automatically. - /// Optional, defaults to 30. The number of days from the current point in time to retrieve calendar items for. - /// A representing the calendar items found. - public async Task> GetEvents(string calendarEntityName, int daysFromNow = 30) => await GetEvents(calendarEntityName, DateTimeOffset.Now, DateTimeOffset.Now.AddDays(daysFromNow)); - - /// - /// Retrieves a list of current and future calendar items, between the and parameters. The maximum number of results is driven by the "max_results" configuration option in the calendar config. - /// - /// The full name of the calendar entity. If this paramter does not start with "calendar.", it will be prepended automatically. - /// The start date/time to search. - /// The end date/time to search. - /// A representing the calendar items found. - public async Task> GetEvents(string calendarEntityName, DateTimeOffset start, DateTimeOffset end) => await Get>($"/api/calendars/{(calendarEntityName.StartsWith("calendar.") ? calendarEntityName : "calendar." + calendarEntityName)}?start={start:yyyy-MM-dd\\THH:mm:sszzz}&end={end:yyyy-MM-dd\\THH:mm:sszzz}"); - } -} +using HADotNet.Core.Models; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace HADotNet.Core.Clients +{ + /// + /// Provides access to the calendar API for retrieving information about calendar entries. + /// + public sealed class CalendarClient : BaseClient + { + /// + /// Initializes a new instance of the . + /// + /// The Home Assistant base instance URL. + /// The Home Assistant long-lived access token. + public CalendarClient(Uri instance, string apiKey) : base(instance, apiKey) { } + + /// + /// Retrieves a list of current and future calendar items, from now until the specified . The maximum number of results is driven by the "max_results" configuration option in the calendar config. + /// + /// The full name of the calendar entity. If this paramter does not start with "calendar.", it will be prepended automatically. + /// Optional, defaults to 30. The number of days from the current point in time to retrieve calendar items for. + /// A representing the calendar items found. + public async Task> GetEvents(string calendarEntityName, int daysFromNow = 30) => await GetEvents(calendarEntityName, DateTimeOffset.Now, DateTimeOffset.Now.AddDays(daysFromNow)); + + /// + /// Retrieves a list of current and future calendar items, between the and parameters. The maximum number of results is driven by the "max_results" configuration option in the calendar config. + /// + /// The full name of the calendar entity. If this paramter does not start with "calendar.", it will be prepended automatically. + /// The start date/time to search. + /// The end date/time to search. + /// A representing the calendar items found. + public async Task> GetEvents(string calendarEntityName, DateTimeOffset start, DateTimeOffset end) => await Get>($"/api/calendars/{(calendarEntityName.StartsWith("calendar.") ? calendarEntityName : "calendar." + calendarEntityName)}?start={start:yyyy-MM-dd\\THH:mm:ss}Z&end={end:yyyy-MM-dd\\THH:mm:ss}Z"); + } +} diff --git a/HADotNet.Core/HADotNet.Core.csproj b/HADotNet.Core/HADotNet.Core.csproj index 2609c95..d791bd6 100644 --- a/HADotNet.Core/HADotNet.Core.csproj +++ b/HADotNet.Core/HADotNet.Core.csproj @@ -12,15 +12,15 @@ home-assistant external api library HADotNet Core Library true - 1.5.0 + 1.5.1 Apache-2.0 https://github.com/qJake/HADotNet https://github.com/qJake/HADotNet.git git 7.3 - 1.5.0.0 - 1.5.0.0 + 1.5.1.0 + 1.5.1.0