Table of Contents

Class OmieDirectApiClient

Namespace
NuvTools.Payment.Omie.ApiClient.Services
Assembly
NuvTools.Payment.Omie.ApiClient.dll

Raw call to the Omie API, for the registrations IOmieApiClient does not cover or covers without the fields a caller needs. It concentrates three details that any new call would otherwise repeat:

  1. the Content-Type goes without the charset parameter — with it, the Omie gateway answers a SOAP "Bad Request" envelope (and that is exactly what PostAsJsonAsync/JsonContent would send);
  2. business errors come in the body (faultstring) alongside an HTTP 5xx — without reading it, the failure turns into an "InternalServerError" that says nothing;
  3. consumption refusals (REDUNDANT, MISUSE_API_PROCESS) are not request errors and get their own treatment (see IsThrottled(string?)).
public class OmieDirectApiClient
Inheritance
OmieDirectApiClient
Inherited Members

Constructors

OmieDirectApiClient(HttpClient, IOptions<OmieApiClientConfig>, ILogger<OmieDirectApiClient>)

Raw call to the Omie API, for the registrations IOmieApiClient does not cover or covers without the fields a caller needs. It concentrates three details that any new call would otherwise repeat:

  1. the Content-Type goes without the charset parameter — with it, the Omie gateway answers a SOAP "Bad Request" envelope (and that is exactly what PostAsJsonAsync/JsonContent would send);
  2. business errors come in the body (faultstring) alongside an HTTP 5xx — without reading it, the failure turns into an "InternalServerError" that says nothing;
  3. consumption refusals (REDUNDANT, MISUSE_API_PROCESS) are not request errors and get their own treatment (see IsThrottled(string?)).
public OmieDirectApiClient(HttpClient httpClient, IOptions<OmieApiClientConfig> optionsAccessor, ILogger<OmieDirectApiClient> logger)

Parameters

httpClient HttpClient
optionsAccessor IOptions<OmieApiClientConfig>
logger ILogger<OmieDirectApiClient>

Properties

Options

The same configuration the typed client uses — credentials, base URL and endpoint paths.

public OmieApiClientConfig Options { get; }

Property Value

OmieApiClientConfig

Methods

CallAsync<TResponse>(string, string, object, CancellationToken)

Runs an Omie call (call + param) and returns the deserialized response.

public Task<IResult<TResponse>> CallAsync<TResponse>(string endpoint, string call, object param, CancellationToken cancellationToken)

Parameters

endpoint string
call string
param object
cancellationToken CancellationToken

Returns

Task<IResult<TResponse>>

Type Parameters

TResponse

IsEndOfPages(string?)

"Não existem registros para a página [n]" — how Omie signals the end of pagination (and an empty registration). It comes as an error, so whoever paginates has to tell it apart from a real failure.

public static bool IsEndOfPages(string? message)

Parameters

message string

Returns

bool