Class OmieContractProvider
Omie Service Contracts, read whole (ListarContratos, paginated) and indexed by the contract number
(cNumCtr) — the number a caller's own configuration stores, because it is what the user reads in Omie.
A contract is a price registry: it carries the negotiated value and the validity period of one client, and is
never billed through.
Listed whole and cached for NuvTools.Payment.Omie.ApiClient.Services.OmieContractProvider.CacheDuration, never consulted one by one. A screen that shows contracts in a grid would otherwise ask Omie once per row, and Omie answers a burst of repeated calls with "Consumo redundante detectado" — which blocks the app_key for every other integration, not just the grid.
public class OmieContractProvider
- Inheritance
-
OmieContractProvider
- Inherited Members
Constructors
OmieContractProvider(IOmieApiClient, IMemoryCache)
Omie Service Contracts, read whole (ListarContratos, paginated) and indexed by the contract number
(cNumCtr) — the number a caller's own configuration stores, because it is what the user reads in Omie.
A contract is a price registry: it carries the negotiated value and the validity period of one client, and is
never billed through.
Listed whole and cached for NuvTools.Payment.Omie.ApiClient.Services.OmieContractProvider.CacheDuration, never consulted one by one. A screen that shows contracts in a grid would otherwise ask Omie once per row, and Omie answers a burst of repeated calls with "Consumo redundante detectado" — which blocks the app_key for every other integration, not just the grid.
public OmieContractProvider(IOmieApiClient omie, IMemoryCache cache)
Parameters
omieIOmieApiClientcacheIMemoryCache
Methods
GetAsync(string, bool, CancellationToken)
One contract by the number (or internal code) the caller stored. Reads the same cached listing — asking for several contracts in a row costs Omie a single call, which is the whole point of listing instead of consulting.
public Task<IResult<OmieContractInfo?>> GetAsync(string contractNumber, bool forceRefresh = false, CancellationToken cancellationToken = default)
Parameters
contractNumberstringforceRefreshboolcancellationTokenCancellationToken
Returns
GetByNumberAsync(bool, CancellationToken)
Contracts indexed by cNumCtr. With forceRefresh the cache is ignored and rewritten
with whatever Omie returns — the explicit "reload from ERP" of a screen, not the screen's own load.
public Task<IResult<IReadOnlyDictionary<string, OmieContractInfo>>> GetByNumberAsync(bool forceRefresh, CancellationToken cancellationToken = default)
Parameters
forceRefreshboolcancellationTokenCancellationToken
Returns
NormalizeNumber(string?)
The key both sides of the match are reduced to: letters and digits only, upper-cased. Everything else — spaces, dots, slashes, hyphens — is dropped.
The contract number is read off a screen and typed into the caller's configuration by hand, so "CTR 001/2026", "ctr-001-2026" and "CTR0012026" are the same contract for the person typing it, and matching them literally would report a contract that plainly exists in Omie as missing. Callers must run their stored number through this same function — GetAsync(string, bool, CancellationToken) does it for them.
public static string NormalizeNumber(string? value)
Parameters
valuestring