Skip to content

Commit 77a52e0

Browse files
committed
1.5.1 Fix calendar get request
1 parent cad2b5a commit 77a52e0

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed
+37-37
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
using HADotNet.Core.Models;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Threading.Tasks;
5-
6-
namespace HADotNet.Core.Clients
7-
{
8-
/// <summary>
9-
/// Provides access to the calendar API for retrieving information about calendar entries.
10-
/// </summary>
11-
public sealed class CalendarClient : BaseClient
12-
{
13-
/// <summary>
14-
/// Initializes a new instance of the <see cref="CalendarClient" />.
15-
/// </summary>
16-
/// <param name="instance">The Home Assistant base instance URL.</param>
17-
/// <param name="apiKey">The Home Assistant long-lived access token.</param>
18-
public CalendarClient(Uri instance, string apiKey) : base(instance, apiKey) { }
19-
20-
/// <summary>
21-
/// Retrieves a list of current and future calendar items, from now until the specified <paramref name="daysFromNow" />. The maximum number of results is driven by the "max_results" configuration option in the calendar config.
22-
/// </summary>
23-
/// <param name="calendarEntityName">The full name of the calendar entity. If this paramter does not start with "calendar.", it will be prepended automatically.</param>
24-
/// <param name="daysFromNow">Optional, defaults to 30. The number of days from the current point in time to retrieve calendar items for.</param>
25-
/// <returns>A <see cref="List{CalendarObject}" /> representing the calendar items found.</returns>
26-
public async Task<List<CalendarObject>> GetEvents(string calendarEntityName, int daysFromNow = 30) => await GetEvents(calendarEntityName, DateTimeOffset.Now, DateTimeOffset.Now.AddDays(daysFromNow));
27-
28-
/// <summary>
29-
/// Retrieves a list of current and future calendar items, between the <paramref name="start" /> and <paramref name="end" /> parameters. The maximum number of results is driven by the "max_results" configuration option in the calendar config.
30-
/// </summary>
31-
/// <param name="calendarEntityName">The full name of the calendar entity. If this paramter does not start with "calendar.", it will be prepended automatically.</param>
32-
/// <param name="start">The start date/time to search.</param>
33-
/// <param name="end">The end date/time to search.</param>
34-
/// <returns>A <see cref="List{CalendarObject}" /> representing the calendar items found.</returns>
35-
public async Task<List<CalendarObject>> GetEvents(string calendarEntityName, DateTimeOffset start, DateTimeOffset end) => await Get<List<CalendarObject>>($"/api/calendars/{(calendarEntityName.StartsWith("calendar.") ? calendarEntityName : "calendar." + calendarEntityName)}?start={start:yyyy-MM-dd\\THH:mm:sszzz}&end={end:yyyy-MM-dd\\THH:mm:sszzz}");
36-
}
37-
}
1+
using HADotNet.Core.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Threading.Tasks;
5+
6+
namespace HADotNet.Core.Clients
7+
{
8+
/// <summary>
9+
/// Provides access to the calendar API for retrieving information about calendar entries.
10+
/// </summary>
11+
public sealed class CalendarClient : BaseClient
12+
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="CalendarClient" />.
15+
/// </summary>
16+
/// <param name="instance">The Home Assistant base instance URL.</param>
17+
/// <param name="apiKey">The Home Assistant long-lived access token.</param>
18+
public CalendarClient(Uri instance, string apiKey) : base(instance, apiKey) { }
19+
20+
/// <summary>
21+
/// Retrieves a list of current and future calendar items, from now until the specified <paramref name="daysFromNow" />. The maximum number of results is driven by the "max_results" configuration option in the calendar config.
22+
/// </summary>
23+
/// <param name="calendarEntityName">The full name of the calendar entity. If this paramter does not start with "calendar.", it will be prepended automatically.</param>
24+
/// <param name="daysFromNow">Optional, defaults to 30. The number of days from the current point in time to retrieve calendar items for.</param>
25+
/// <returns>A <see cref="List{CalendarObject}" /> representing the calendar items found.</returns>
26+
public async Task<List<CalendarObject>> GetEvents(string calendarEntityName, int daysFromNow = 30) => await GetEvents(calendarEntityName, DateTimeOffset.Now, DateTimeOffset.Now.AddDays(daysFromNow));
27+
28+
/// <summary>
29+
/// Retrieves a list of current and future calendar items, between the <paramref name="start" /> and <paramref name="end" /> parameters. The maximum number of results is driven by the "max_results" configuration option in the calendar config.
30+
/// </summary>
31+
/// <param name="calendarEntityName">The full name of the calendar entity. If this paramter does not start with "calendar.", it will be prepended automatically.</param>
32+
/// <param name="start">The start date/time to search.</param>
33+
/// <param name="end">The end date/time to search.</param>
34+
/// <returns>A <see cref="List{CalendarObject}" /> representing the calendar items found.</returns>
35+
public async Task<List<CalendarObject>> GetEvents(string calendarEntityName, DateTimeOffset start, DateTimeOffset end) => await Get<List<CalendarObject>>($"/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");
36+
}
37+
}

HADotNet.Core/HADotNet.Core.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
<PackageTags>home-assistant external api library</PackageTags>
1313
<Title>HADotNet Core Library</Title>
1414
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
15-
<Version>1.5.0</Version>
15+
<Version>1.5.1</Version>
1616
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1717
<PackageProjectUrl>https://github.com/qJake/HADotNet</PackageProjectUrl>
1818
<RepositoryUrl>https://github.com/qJake/HADotNet.git</RepositoryUrl>
1919
<RepositoryType>git</RepositoryType>
2020
<PackageReleaseNotes></PackageReleaseNotes>
2121
<LangVersion>7.3</LangVersion>
22-
<AssemblyVersion>1.5.0.0</AssemblyVersion>
23-
<FileVersion>1.5.0.0</FileVersion>
22+
<AssemblyVersion>1.5.1.0</AssemblyVersion>
23+
<FileVersion>1.5.1.0</FileVersion>
2424
</PropertyGroup>
2525

2626
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

0 commit comments

Comments
 (0)