Class 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:
- the
Content-Typegoes without thecharsetparameter — with it, the Omie gateway answers a SOAP "Bad Request" envelope (and that is exactly whatPostAsJsonAsync/JsonContentwould send); - business errors come in the body (
faultstring) alongside an HTTP 5xx — without reading it, the failure turns into an "InternalServerError" that says nothing; - 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:
- the
Content-Typegoes without thecharsetparameter — with it, the Omie gateway answers a SOAP "Bad Request" envelope (and that is exactly whatPostAsJsonAsync/JsonContentwould send); - business errors come in the body (
faultstring) alongside an HTTP 5xx — without reading it, the failure turns into an "InternalServerError" that says nothing; - 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
httpClientHttpClientoptionsAccessorIOptions<OmieApiClientConfig>loggerILogger<OmieDirectApiClient>
Properties
Options
The same configuration the typed client uses — credentials, base URL and endpoint paths.
public OmieApiClientConfig Options { get; }
Property Value
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
endpointstringcallstringparamobjectcancellationTokenCancellationToken
Returns
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
messagestring