Class MercadoPagoClient<TResource>
Base class for APIs clients.
Inheritance
Inherited Members
Namespace: MercadoPago.Client
Assembly: MercadoPago.dll
Syntax
public abstract class MercadoPagoClient<TResource> where TResource : IResource, new()
Type Parameters
Name | Description |
---|---|
TResource | Type of the resource. |
Constructors
| Edit this page View SourceMercadoPagoClient(IHttpClient, ISerializer)
Constructor of the MercadoPagoClient<TResource> class.
Declaration
protected MercadoPagoClient(IHttpClient httpClient, ISerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The http client that will be used in HTTP requests. |
ISerializer | serializer | The serializer that will be used to serialize the HTTP requests content and to deserialize the HTTP response content. |
Properties
| Edit this page View SourceDefaultHeaders
The defaults headers that will be sended in every request.
Declaration
protected IDictionary<string, string> DefaultHeaders { get; }
Property Value
Type | Description |
---|---|
IDictionary<string, string> |
HttpClient
The IHttpClient used to make HTTP requests.
Declaration
public IHttpClient HttpClient { get; }
Property Value
Type | Description |
---|---|
IHttpClient |
Serializer
The ISerializer used to serialize request objects to JSON and deserialize API response to IResource.
Declaration
public ISerializer Serializer { get; }
Property Value
Type | Description |
---|---|
ISerializer |
Methods
| Edit this page View SourceList(string, HttpMethod, object, RequestOptions)
List the resources from path
.
Declaration
protected ResourcesList<TResource> List(string path, HttpMethod httpMethod, object request, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
string | path | Path of API. |
HttpMethod | httpMethod | HTTP method. |
object | request | Object with request data. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
ResourcesList<TResource> | A task whose result is a list of resources. |
ListAsync(string, HttpMethod, object, RequestOptions, CancellationToken)
List async the resources from path
.
Declaration
protected Task<ResourcesList<TResource>> ListAsync(string path, HttpMethod httpMethod, object request, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | path | Path of API. |
HttpMethod | httpMethod | HTTP method. |
object | request | Object with request data. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<ResourcesList<TResource>> | A task whose result is a list of resources. |
SearchAsync<TPageResult>(string, SearchRequest, RequestOptions, CancellationToken)
Searches async and returns a result page with resources.
Declaration
protected Task<TPageResult> SearchAsync<TPageResult>(string path, SearchRequest request, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) where TPageResult : IResourcesPage<TResource>, new()
Parameters
Type | Name | Description |
---|---|---|
string | path | Path of search API. |
SearchRequest | request | Object with search parameters. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<TPageResult> | A task whose result is a search response page. |
Type Parameters
Name | Description |
---|---|
TPageResult | The type of page. |
Search<TPageResult>(string, SearchRequest, RequestOptions)
Searches and returns a result page with resources.
Declaration
protected TPageResult Search<TPageResult>(string path, SearchRequest request, RequestOptions requestOptions = null) where TPageResult : IResourcesPage<TResource>, new()
Parameters
Type | Name | Description |
---|---|---|
string | path | Path of search API. |
SearchRequest | request | Object with search parameters. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
TPageResult | A search response page. |
Type Parameters
Name | Description |
---|---|
TPageResult | The type of page. |
Send(string, HttpMethod, object, RequestOptions)
Send a request to api path
with HTTP method httpMethod
.
The content body is in request
.
Declaration
protected TResource Send(string path, HttpMethod httpMethod, object request, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
string | path | Path of the endpoint. |
HttpMethod | httpMethod | HTTP method. |
object | request | Object with request data. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
TResource | A resource that represents the API response. |
SendAsync(string, HttpMethod, object, RequestOptions, CancellationToken)
Send a async request to api path
with HTTP method httpMethod
.
The content body is in request
.
Declaration
protected Task<TResource> SendAsync(string path, HttpMethod httpMethod, object request, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | path | Path of the endpoint. |
HttpMethod | httpMethod | HTTP method. |
object | request | Object with request data. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<TResource> | A task whose result is a resource that represents the API response. |