Table of Contents

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

TModel

The type of the model being requested.

TResource

The type of the resource being requested.

TResponse

The type of the response being returned.

TSingletonResponse

The type of the singleton form of the response being returned.

Inheritance
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

client HttpClient

The HTTP client to use for making requests.

uri Uri

The 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

filter string

The 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

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<TResponse>

A task representing the asynchronous operation, containing the deserialized resource of type TResponse if 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

count int

The 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

count int

The 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

document JsonApiDocument<TResource>

The JSON:API document to send in the request.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<TSingletonResponse>

A task representing the asynchronous operation, containing the deserialized resource of type TResponse if 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

resource TModel

The resource data to be sent in the POST request.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<TSingletonResponse>

A task representing the asynchronous operation, containing the deserialized resource of type TResponse if deserialization is successful; otherwise, null.

Exceptions

JsonApiException

Thrown when the HTTP response indicates a failure status code.