MonthlyApi
extends BaseApi
in package
Classe responsável por fazer requisições para a API de Mensal.
Herda os métodos da classe BaseApi.
Table of Contents
Methods
- __construct() : mixed
- confirm() : mixed
- Confirma a geração da guia.
- downloadFile() : mixed
- Faz o download de qualquer arquivo (não da API, mas necessário para baixar PDFs).
- generateInvoice() : array<string|int, mixed>|string
- Gera a guia de pagamento com os dados fornecidos.
- getCompetencies() : array<string|int, mixed>
- Captura as competências disponíveis.
- getDebitsCart() : array<string|int, mixed>
- Captura os débitos existentes para as informações passadas.
- getDetailedInvoiceFile() : array<string|int, mixed>|string
- Retorna o arquivo binário da guia de pagamento detalhada.
- getEmployer() : string|array<string|int, mixed>
- Captura os dados do empregador.
- getGroupings() : array<string|int, mixed>|string
- Generates the payment invoice with the provided data.
- makeRequest() : array<string|int, mixed>|string
- Makes an HTTP request using the specified method, URI, and options.
- setCnpj() : self
- Define o CNPJ para contexto de logs
- setUuid() : self
- Define o UUID para contexto de logs
Methods
__construct()
public
__construct(Client $client) : mixed
Parameters
- $client : Client
confirm()
Confirma a geração da guia.
public
confirm() : mixed
downloadFile()
Faz o download de qualquer arquivo (não da API, mas necessário para baixar PDFs).
public
downloadFile(string $endpoint) : mixed
Parameters
- $endpoint : string
-
O endpoint ou URL de onde baixar o arquivo.
Return values
mixed —A resposta do método makeRequest, ou um array com detalhes do erro em caso de falha.
generateInvoice()
Gera a guia de pagamento com os dados fornecidos.
public
generateInvoice(string $query, string $uuid) : array<string|int, mixed>|string
Usa um loop de tentativas porque a API pode demorar para gerar a guia, evitando respostas vazias.
Parameters
- $query : string
-
O parâmetro de consulta para a requisição.
- $uuid : string
-
O UUID para a requisição.
Return values
array<string|int, mixed>|string —A resposta da API ou detalhes do erro.
getCompetencies()
Captura as competências disponíveis.
public
getCompetencies() : array<string|int, mixed>
Return values
array<string|int, mixed>getDebitsCart()
Captura os débitos existentes para as informações passadas.
public
getDebitsCart(mixed $competency, mixed $allowMonthly, mixed $allowTermination) : array<string|int, mixed>
Parameters
- $competency : mixed
- $allowMonthly : mixed
- $allowTermination : mixed
Return values
array<string|int, mixed>getDetailedInvoiceFile()
Retorna o arquivo binário da guia de pagamento detalhada.
public
getDetailedInvoiceFile(mixed $invoiceId, mixed $uuid) : array<string|int, mixed>|string
Tenta novamente a requisição em um loop, pois a API pode ter um atraso na geração da guia detalhada.
Parameters
- $invoiceId : mixed
-
O ID da guia a ser reimpressa.
- $uuid : mixed
-
O UUID associado à requisição.
Return values
array<string|int, mixed>|string —O arquivo binário ou um array com detalhes do erro.
getEmployer()
Captura os dados do empregador.
public
getEmployer() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>getGroupings()
Generates the payment invoice with the provided data.
public
getGroupings(string $query, string $uuid) : array<string|int, mixed>|string
Uses a retry loop because the API may take time to generate the invoice, avoiding empty responses.
Parameters
- $query : string
-
The query parameter for the request.
- $uuid : string
-
The UUID for the request.
Return values
array<string|int, mixed>|string —The API response or error details.
makeRequest()
Makes an HTTP request using the specified method, URI, and options.
public
makeRequest(string $method, string $uri[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>|string
Handles retries for connection exceptions, decodes JSON responses, and throws custom exceptions for errors.
Parameters
- $method : string
-
The HTTP method to use (e.g., 'GET', 'POST').
- $uri : string
-
The URI to request.
- $options : array<string|int, mixed> = []
-
Optional request options to pass to the HTTP client.
Tags
Return values
array<string|int, mixed>|string —Returns the decoded JSON response as an array, or the raw response body as a string for non-JSON content.
setCnpj()
Define o CNPJ para contexto de logs
public
setCnpj(string $cnpj) : self
Parameters
- $cnpj : string
Return values
selfsetUuid()
Define o UUID para contexto de logs
public
setUuid(string $uuid) : self
Parameters
- $uuid : string