Class ApiClient
Provides a default implementation of an Api client (both synchronous and asynchronous implementations), encapsulating general REST accessor use cases.
Inherited Members
Namespace: mailslurp.Client
Assembly: mailslurp.dll
Syntax
public class ApiClient : ISynchronousClient, IAsynchronousClient
Constructors
View SourceApiClient()
Initializes a new instance of the ApiClient, defaulting to the global configurations' base url.
Declaration
public ApiClient()
ApiClient(string)
Initializes a new instance of the ApiClient
Declaration
public ApiClient(string basePath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | basePath | The target service's base path in URL format. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
Properties
View SourceSerializerSettings
Specifies the settings on a Newtonsoft.Json.JsonSerializer object. These settings can be adjusted to accommodate custom serialization rules.
Declaration
public JsonSerializerSettings SerializerSettings { get; set; }
Property Value
| Type | Description |
|---|---|
| JsonSerializerSettings |
Methods
View SourceDeleteAsync<T>(string, RequestOptions, IReadableConfiguration, CancellationToken)
Make a HTTP DELETE request (async).
Declaration
public Task<ApiResponse<T>> DeleteAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
| CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
| Type | Description |
|---|---|
| Task<ApiResponse<T>> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
Delete<T>(string, RequestOptions, IReadableConfiguration)
Make a HTTP DELETE request (synchronous).
Declaration
public ApiResponse<T> Delete<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
Returns
| Type | Description |
|---|---|
| ApiResponse<T> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
GetAsync<T>(string, RequestOptions, IReadableConfiguration, CancellationToken)
Make a HTTP GET request (async).
Declaration
public Task<ApiResponse<T>> GetAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
| CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
| Type | Description |
|---|---|
| Task<ApiResponse<T>> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
Get<T>(string, RequestOptions, IReadableConfiguration)
Make a HTTP GET request (synchronous).
Declaration
public ApiResponse<T> Get<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
Returns
| Type | Description |
|---|---|
| ApiResponse<T> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
HeadAsync<T>(string, RequestOptions, IReadableConfiguration, CancellationToken)
Make a HTTP HEAD request (async).
Declaration
public Task<ApiResponse<T>> HeadAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
| CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
| Type | Description |
|---|---|
| Task<ApiResponse<T>> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
Head<T>(string, RequestOptions, IReadableConfiguration)
Make a HTTP HEAD request (synchronous).
Declaration
public ApiResponse<T> Head<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
Returns
| Type | Description |
|---|---|
| ApiResponse<T> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
OptionsAsync<T>(string, RequestOptions, IReadableConfiguration, CancellationToken)
Make a HTTP OPTION request (async).
Declaration
public Task<ApiResponse<T>> OptionsAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
| CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
| Type | Description |
|---|---|
| Task<ApiResponse<T>> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
Options<T>(string, RequestOptions, IReadableConfiguration)
Make a HTTP OPTION request (synchronous).
Declaration
public ApiResponse<T> Options<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
Returns
| Type | Description |
|---|---|
| ApiResponse<T> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
PatchAsync<T>(string, RequestOptions, IReadableConfiguration, CancellationToken)
Make a HTTP PATCH request (async).
Declaration
public Task<ApiResponse<T>> PatchAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
| CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
| Type | Description |
|---|---|
| Task<ApiResponse<T>> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
Patch<T>(string, RequestOptions, IReadableConfiguration)
Make a HTTP PATCH request (synchronous).
Declaration
public ApiResponse<T> Patch<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
Returns
| Type | Description |
|---|---|
| ApiResponse<T> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
PostAsync<T>(string, RequestOptions, IReadableConfiguration, CancellationToken)
Make a HTTP POST request (async).
Declaration
public Task<ApiResponse<T>> PostAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
| CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
| Type | Description |
|---|---|
| Task<ApiResponse<T>> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
Post<T>(string, RequestOptions, IReadableConfiguration)
Make a HTTP POST request (synchronous).
Declaration
public ApiResponse<T> Post<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
Returns
| Type | Description |
|---|---|
| ApiResponse<T> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
PutAsync<T>(string, RequestOptions, IReadableConfiguration, CancellationToken)
Make a HTTP PUT request (async).
Declaration
public Task<ApiResponse<T>> PutAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
| CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
| Type | Description |
|---|---|
| Task<ApiResponse<T>> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |
Put<T>(string, RequestOptions, IReadableConfiguration)
Make a HTTP PUT request (synchronous).
Declaration
public ApiResponse<T> Put<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The target path (or resource). |
| RequestOptions | options | The additional request options. |
| IReadableConfiguration | configuration | A per-request configuration object. It is assumed that any merge with GlobalConfiguration has been done before calling this method. |
Returns
| Type | Description |
|---|---|
| ApiResponse<T> | A Task containing ApiResponse |
Type Parameters
| Name | Description |
|---|---|
| T |