Exception: Integrobr::NfseSdk::ApiError
- Inherits:
-
StandardError
- Object
- StandardError
- Integrobr::NfseSdk::ApiError
- Defined in:
- lib/integrobr/nfse_sdk/errors.rb
Overview
Erro devolvido pela API pública do IntegroBR — sempre no formato
{ statusCode, message, error }, onde message pode ser uma string
única ou uma lista (um item por campo inválido, em erros 400).
Instance Attribute Summary collapse
-
#erro_tipo ⇒ Object
readonly
Returns the value of attribute erro_tipo.
-
#mensagens ⇒ Object
readonly
Returns the value of attribute mensagens.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(status_code, mensagem, erro_tipo = nil) ⇒ ApiError
constructor
A new instance of ApiError.
-
#nao_autenticado? ⇒ Boolean
401 — chave ausente, inválida ou revogada.
-
#nao_encontrado? ⇒ Boolean
404 — cobre tanto "não existe" quanto "existe, mas no outro ambiente (sandbox/produção)" da mesma conta.
-
#rate_limited? ⇒ Boolean
429 — limite de 120 requisições/minuto por chave excedido.
Constructor Details
#initialize(status_code, mensagem, erro_tipo = nil) ⇒ ApiError
Returns a new instance of ApiError.
11 12 13 14 15 16 |
# File 'lib/integrobr/nfse_sdk/errors.rb', line 11 def initialize(status_code, mensagem, erro_tipo = nil) @status_code = status_code @mensagens = mensagem.is_a?(Array) ? mensagem : [mensagem] @erro_tipo = erro_tipo super(@mensagens.join(" ")) end |
Instance Attribute Details
#erro_tipo ⇒ Object (readonly)
Returns the value of attribute erro_tipo.
9 10 11 |
# File 'lib/integrobr/nfse_sdk/errors.rb', line 9 def erro_tipo @erro_tipo end |
#mensagens ⇒ Object (readonly)
Returns the value of attribute mensagens.
9 10 11 |
# File 'lib/integrobr/nfse_sdk/errors.rb', line 9 def mensagens @mensagens end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
9 10 11 |
# File 'lib/integrobr/nfse_sdk/errors.rb', line 9 def status_code @status_code end |
Instance Method Details
#nao_autenticado? ⇒ Boolean
401 — chave ausente, inválida ou revogada.
24 25 26 |
# File 'lib/integrobr/nfse_sdk/errors.rb', line 24 def nao_autenticado? status_code == 401 end |
#nao_encontrado? ⇒ Boolean
404 — cobre tanto "não existe" quanto "existe, mas no outro ambiente (sandbox/produção)" da mesma conta.
30 31 32 |
# File 'lib/integrobr/nfse_sdk/errors.rb', line 30 def nao_encontrado? status_code == 404 end |
#rate_limited? ⇒ Boolean
429 — limite de 120 requisições/minuto por chave excedido.
19 20 21 |
# File 'lib/integrobr/nfse_sdk/errors.rb', line 19 def rate_limited? status_code == 429 end |