Class PaginatedResourceClient<TModel, TResource, TResponse, TSingletonResponse>
- Namespace
- Crews.PlanningCenter.Api.Models
- Assembly
- Crews.PlanningCenter.Api.dll
Provides a base class for making strongly-typed HTTP requests to a specified paginated resource endpoint.
public abstract class PaginatedResourceClient<TModel, TResource, TResponse, TSingletonResponse> : ResourceClient<TModel> where TResource : JsonApiResource<TModel>, new() where TResponse : ResourceResponse<IEnumerable<TResource>>, new() where TSingletonResponse : ResourceResponse<TResource>, new()
Type Parameters
TModelThe type of the model being requested.
TResourceThe type of the resource being requested.
TResponseThe type of the response being returned.
TSingletonResponseThe type of the singleton form of the response being returned.
- Inheritance
-
ResourceClient<TModel>PaginatedResourceClient<TModel, TResource, TResponse, TSingletonResponse>
- Derived
- Inherited Members
Constructors
PaginatedResourceClient(HttpClient, Uri)
Provides a base class for making strongly-typed HTTP requests to a specified paginated resource endpoint.
protected PaginatedResourceClient(HttpClient client, Uri uri)
Parameters
clientHttpClientThe HTTP client to use for making requests.
uriUriThe URI of the paginated resource endpoint.
Methods
Filter(string)
Adds a filter query parameter to the request to filter the results based on the specified criteria.
public PaginatedResourceClient<TModel, TResource, TResponse, TSingletonResponse> Filter(string filter)
Parameters
filterstringThe filter criteria.
Returns
- PaginatedResourceClient<TModel, TResource, TResponse, TSingletonResponse>
The current instance of the paginated resource client.
Remarks
See Planning Center API documentation for details on supported filter values for this resource.
GetAsync(CancellationToken)
Sends an asynchronous GET request to the specified resource endpoint and deserializes the response content.
protected Task<TResponse> GetAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<TResponse>
A task representing the asynchronous operation, containing the deserialized resource of type
TResponseif deserialization is successful; otherwise, null.
Exceptions
- JsonApiException
Thrown when the HTTP response indicates a failure status code.
Offset(int)
Sets the item offset in the paginated response.
public PaginatedResourceClient<TModel, TResource, TResponse, TSingletonResponse> Offset(int count)
Parameters
countintThe number of items to skip.
Returns
- PaginatedResourceClient<TModel, TResource, TResponse, TSingletonResponse>
The current instance of the paginated resource client.
PerPage(int)
Sets the number of items to be returned per page in the paginated response.
public PaginatedResourceClient<TModel, TResource, TResponse, TSingletonResponse> PerPage(int count)
Parameters
countintThe number of items to be returned per page.
Returns
- PaginatedResourceClient<TModel, TResource, TResponse, TSingletonResponse>
The current instance of the paginated resource client.
PostAsync(JsonApiDocument<TResource>, CancellationToken)
Sends an asynchronous POST request with a custom JSON:API document to the resource endpoint and deserializes the response content.
protected Task<TSingletonResponse> PostAsync(JsonApiDocument<TResource> document, CancellationToken cancellationToken = default)
Parameters
documentJsonApiDocument<TResource>The JSON:API document to send in the request.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<TSingletonResponse>
A task representing the asynchronous operation, containing the deserialized resource of type
TResponseif deserialization is successful; otherwise, null.
Exceptions
- JsonApiException
Thrown when the HTTP response indicates a failure status code.
PostAsync(TModel, CancellationToken)
Sends an asynchronous POST request with the specified resource data to the resource endpoint and deserializes the response content.
protected Task<TSingletonResponse> PostAsync(TModel resource, CancellationToken cancellationToken = default)
Parameters
resourceTModelThe resource data to be sent in the POST request.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<TSingletonResponse>
A task representing the asynchronous operation, containing the deserialized resource of type
TResponseif deserialization is successful; otherwise, null.
Exceptions
- JsonApiException
Thrown when the HTTP response indicates a failure status code.