Skip to content

Commit

Permalink
Merge pull request #65 from CodeCasterNL/feature/interfaces
Browse files Browse the repository at this point in the history
#64: interface ALL the (public) things
  • Loading branch information
pyrocumulus authored Jun 1, 2021
2 parents cba88ab + 57627d4 commit d69aaf3
Show file tree
Hide file tree
Showing 28 changed files with 838 additions and 511 deletions.
91 changes: 91 additions & 0 deletions src/PVOutput.Net/IPVOutputClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using PVOutput.Net.Modules;

namespace PVOutput.Net
{
/// <summary>
/// The client used to communicate with the PVOutput service.
/// </summary>
public interface IPVOutputClient
{
/// <summary>ApiKey to use with authenticating.</summary>
string ApiKey { get; set; }

/// <summary>Id of the currently owned system used for authenticating.</summary>
int OwnedSystemId { get; set; }

/// <summary>Indicates whether or not the client should throw exceptions when the api returns errors.</summary>
bool ThrowResponseExceptions { get; set; }

/// <summary>
/// The output service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getoutput">API information</see>.</para>
/// </summary>
IOutputService Output { get; }

/// <summary>
/// The system service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getsystem">API information</see>.</para>
/// </summary>
ISystemService System { get; }

/// <summary>
/// The status service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getstatus">API information</see>.</para>
/// </summary>
IStatusService Status { get; }

/// <summary>
/// The statistic service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getstatistic">API information</see>.</para>
/// </summary>
IStatisticsService Statistics { get; }

/// <summary>
/// The missing service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getmissing">API information</see>.</para>
/// </summary>
IMissingService Missing { get; }

/// <summary>
/// The team service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getsupply">API information</see>.</para>
/// </summary>
ITeamService Team { get; }

/// <summary>
/// The extended service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getextended">API information</see>.</para>
/// </summary>
IExtendedService Extended { get; }

/// <summary>
/// The favourite service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getfavourite">API information</see>.</para>
/// </summary>
IFavouriteService Favourite { get; }

/// <summary>
/// The insolation service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getinsolation">API information</see>.</para>
/// </summary>
IInsolationService Insolation { get; }

/// <summary>
/// The supply service.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getsupply">API information</see>.</para>
/// </summary>
ISupplyService Supply { get; }

/// <summary>
/// The search service
/// <para>See the official <see href="https://pvoutput.org/help.html#api-search">API information</see>.</para>
/// </summary>
ISearchService Search { get; }

/// <summary>
/// The notification service
/// <para>See the official <see href="https://pvoutput.org/help.html#api-registernotification">API information</see>.</para>
/// </summary>
INotificationService Notification { get; }
}
}
26 changes: 4 additions & 22 deletions src/PVOutput.Net/Modules/ExtendedService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Dawn;
Expand All @@ -12,23 +11,14 @@

namespace PVOutput.Net.Modules
{
/// <summary>
/// The Get Extended service retrieves system daily extended data.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getextended">API information</see>.</para>
/// <para><strong>Note: this is a donation only service.</strong></para>
/// </summary>
public sealed class ExtendedService : BaseService
/// <inheritdoc cref="IExtendedService"/>
public sealed class ExtendedService : BaseService, IExtendedService
{
internal ExtendedService(PVOutputClient client) : base(client)
{
}

/// <summary>
/// Retrieve most recently created extended data.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>Most recent extended data.</returns>
/// <inheritdoc />
public Task<PVOutputResponse<IExtended>> GetRecentExtendedDataAsync(CancellationToken cancellationToken = default)
{
var loggingScope = new Dictionary<string, object>()
Expand All @@ -40,15 +30,7 @@ public Task<PVOutputResponse<IExtended>> GetRecentExtendedDataAsync(Cancellation
return handler.ExecuteSingleItemRequestAsync<IExtended>(new ExtendedRequest(), loggingScope, cancellationToken);
}

/// <summary>
/// Retrieve extended data for a certain period.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="fromDate">Minimum DateTime for the requested range.</param>
/// <param name="toDate">Maximum DateTime for the requested range.</param>
/// <param name="limit">Optional limit of number of items. <c>50 is the maximum.</c></param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>List of extended data objects.</returns>
/// <inheritdoc />
public Task<PVOutputArrayResponse<IExtended>> GetExtendedDataForPeriodAsync(DateTime fromDate, DateTime toDate, int? limit = null, CancellationToken cancellationToken = default)
{
var loggingScope = new Dictionary<string, object>()
Expand Down
18 changes: 4 additions & 14 deletions src/PVOutput.Net/Modules/FavouriteService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using PVOutput.Net.Objects;
Expand All @@ -11,22 +9,14 @@

namespace PVOutput.Net.Modules
{
/// <summary>
/// The Get Favourite service retrieves the systems in your favourites or another user's favourites.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getfavourite">API information</see>.</para>
/// </summary>
public sealed class FavouriteService : BaseService
/// <inheritdoc cref="IFavouriteService"/>
public sealed class FavouriteService : BaseService, IFavouriteService
{
internal FavouriteService(PVOutputClient client) : base(client)
{
}

/// <summary>
/// Retrieves the favourites for the owned system, or another.
/// </summary>
/// <param name="systemId">Optional SystemId to request the favourites for.</param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>List of favourites.</returns>
/// <inheritdoc />
public Task<PVOutputArrayResponse<IFavourite>> GetFavouritesAsync(int? systemId = null, CancellationToken cancellationToken = default)
{
var loggingScope = new Dictionary<string, object>()
Expand Down
36 changes: 5 additions & 31 deletions src/PVOutput.Net/Modules/InsolationService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using PVOutput.Net.Objects;
using PVOutput.Net.Objects.Core;
using PVOutput.Net.Requests.Handler;
Expand All @@ -12,24 +10,14 @@

namespace PVOutput.Net.Modules
{
/// <summary>
/// The Get Insolation service retrieves 5-minute insolation data (power and energy) under ideal weather conditions.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getinsolation">API information</see>.</para>
/// <para><strong>Note: this is a donation only service.</strong></para>
/// </summary>
public sealed class InsolationService : BaseService
/// <inheritdoc cref="IInsolationService"/>
public sealed class InsolationService : BaseService, IInsolationService
{
internal InsolationService(PVOutputClient client) : base(client)
{
}

/// <summary>
/// Get insolation data for own system.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="date">The DateTime to calculate the insolation for. If empty, the current date will be calculated.</param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>Insolation data for the owned system.</returns>
/// <inheritdoc />
public Task<PVOutputArrayResponse<IInsolation>> GetInsolationForOwnSystemAsync(DateTime? date = null, CancellationToken cancellationToken = default)
{
var loggingScope = new Dictionary<string, object>()
Expand All @@ -43,14 +31,7 @@ public Task<PVOutputArrayResponse<IInsolation>> GetInsolationForOwnSystemAsync(D
return response;
}

/// <summary>
/// Get insolation data for a system.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="systemId">Id of the system to get insolation for.</param>
/// <param name="date">The DateTime to calculate the insolation for. If empty, the current date will be calculated.</param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>Insolation data for the requested system.</returns>
/// <inheritdoc />
public Task<PVOutputArrayResponse<IInsolation>> GetInsolationForSystemAsync(int systemId, DateTime? date = null, CancellationToken cancellationToken = default)
{
var loggingScope = new Dictionary<string, object>()
Expand All @@ -65,14 +46,7 @@ public Task<PVOutputArrayResponse<IInsolation>> GetInsolationForSystemAsync(int
return response;
}

/// <summary>
/// Get insolation data for a location.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="coordinate">GPS coordinate, to request insolation for.</param>
/// <param name="date">The DateTime to calculate the insolation for. If empty, the current date will be calculated.</param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>Insolation data for the requested location.</returns>
/// <inheritdoc />
public Task<PVOutputArrayResponse<IInsolation>> GetInsolationForLocationAsync(PVCoordinate coordinate, DateTime? date = null, CancellationToken cancellationToken = default)
{
var loggingScope = new Dictionary<string, object>()
Expand Down
35 changes: 35 additions & 0 deletions src/PVOutput.Net/Modules/Interfaces/IExtendedService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using PVOutput.Net.Objects;
using PVOutput.Net.Responses;

namespace PVOutput.Net.Modules
{
/// <summary>
/// The Get Extended service retrieves system daily extended data.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getextended">API information</see>.</para>
/// <para><strong>Note: this is a donation only service.</strong></para>
/// </summary>
public interface IExtendedService
{
/// <summary>
/// Retrieve most recently created extended data.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>Most recent extended data.</returns>
Task<PVOutputResponse<IExtended>> GetRecentExtendedDataAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve extended data for a certain period.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="fromDate">Minimum DateTime for the requested range.</param>
/// <param name="toDate">Maximum DateTime for the requested range.</param>
/// <param name="limit">Optional limit of number of items. <c>50 is the maximum.</c></param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>List of extended data objects.</returns>
Task<PVOutputArrayResponse<IExtended>> GetExtendedDataForPeriodAsync(DateTime fromDate, DateTime toDate, int? limit = null, CancellationToken cancellationToken = default);
}
}
22 changes: 22 additions & 0 deletions src/PVOutput.Net/Modules/Interfaces/IFavouriteService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Threading;
using System.Threading.Tasks;
using PVOutput.Net.Objects;
using PVOutput.Net.Responses;

namespace PVOutput.Net.Modules
{
/// <summary>
/// The Get Favourite service retrieves the systems in your favourites or another user's favourites.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getfavourite">API information</see>.</para>
/// </summary>
public interface IFavouriteService
{
/// <summary>
/// Retrieves the favourites for the owned system, or another.
/// </summary>
/// <param name="systemId">Optional SystemId to request the favourites for.</param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>List of favourites.</returns>
Task<PVOutputArrayResponse<IFavourite>> GetFavouritesAsync(int? systemId = null, CancellationToken cancellationToken = default);
}
}
45 changes: 45 additions & 0 deletions src/PVOutput.Net/Modules/Interfaces/IInsolationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using PVOutput.Net.Objects;
using PVOutput.Net.Responses;

namespace PVOutput.Net.Modules
{
/// <summary>
/// The Get Insolation service retrieves 5-minute insolation data (power and energy) under ideal weather conditions.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getinsolation">API information</see>.</para>
/// <para><strong>Note: this is a donation only service.</strong></para>
/// </summary>
public interface IInsolationService
{
/// <summary>
/// Get insolation data for own system.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="date">The DateTime to calculate the insolation for. If empty, the current date will be calculated.</param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>Insolation data for the owned system.</returns>
Task<PVOutputArrayResponse<IInsolation>> GetInsolationForOwnSystemAsync(DateTime? date = null, CancellationToken cancellationToken = default);

/// <summary>
/// Get insolation data for a system.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="systemId">Id of the system to get insolation for.</param>
/// <param name="date">The DateTime to calculate the insolation for. If empty, the current date will be calculated.</param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>Insolation data for the requested system.</returns>
Task<PVOutputArrayResponse<IInsolation>> GetInsolationForSystemAsync(int systemId, DateTime? date = null, CancellationToken cancellationToken = default);

/// <summary>
/// Get insolation data for a location.
/// <para><strong>Note: this is a donation only request.</strong></para>
/// </summary>
/// <param name="coordinate">GPS coordinate, to request insolation for.</param>
/// <param name="date">The DateTime to calculate the insolation for. If empty, the current date will be calculated.</param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>Insolation data for the requested location.</returns>
Task<PVOutputArrayResponse<IInsolation>> GetInsolationForLocationAsync(PVCoordinate coordinate, DateTime? date = null, CancellationToken cancellationToken = default);
}
}
24 changes: 24 additions & 0 deletions src/PVOutput.Net/Modules/Interfaces/IMissingService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using PVOutput.Net.Objects;
using PVOutput.Net.Responses;

namespace PVOutput.Net.Modules
{
/// <summary>
/// The Get Missing service retrieves a list of output dates missing from a system.
/// <para>See the official <see href="https://pvoutput.org/help.html#api-getmissing">API information</see>.</para>
/// </summary>
public interface IMissingService
{
/// <summary>
/// Retrieves a list of output dates with no data
/// </summary>
/// <param name="fromDate">Minimum date for the requested range.</param>
/// <param name="toDate">Maximum date for the requested range.</param>
/// <param name="cancellationToken">A cancellation token for the request.</param>
/// <returns>List of missing dates</returns>
Task<PVOutputResponse<IMissing>> GetMissingDaysInPeriodAsync(DateTime fromDate, DateTime toDate, CancellationToken cancellationToken = default);
}
}
Loading

0 comments on commit d69aaf3

Please sign in to comment.