focus_nfe 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.git-hooks/pre_push/steep.rb +18 -0
- data/.git-hooks/pre_push/yard_doc.rb +18 -0
- data/.gitattributes +1 -0
- data/.overcommit.yml +69 -0
- data/.rspec +3 -0
- data/.yardopts +11 -0
- data/CHANGELOG.md +77 -0
- data/CLAUDE.md +118 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +348 -0
- data/Rakefile +105 -0
- data/data/schemas/schema_cte.json +2793 -0
- data/data/schemas/schema_cte_os.json +1335 -0
- data/data/schemas/schema_cte_os_transporte_rodoviario.json +109 -0
- data/data/schemas/schema_cte_transporte_aereo.json +115 -0
- data/data/schemas/schema_cte_transporte_aquaviario.json +174 -0
- data/data/schemas/schema_cte_transporte_dutoviario.json +65 -0
- data/data/schemas/schema_cte_transporte_ferroviario.json +144 -0
- data/data/schemas/schema_cte_transporte_multimodal.json +45 -0
- data/data/schemas/schema_cte_transporte_rodoviario.json +78 -0
- data/data/schemas/schema_dce.json +549 -0
- data/data/schemas/schema_mdfe.json +1102 -0
- data/data/schemas/schema_mdfe_transporte_aereo.json +44 -0
- data/data/schemas/schema_mdfe_transporte_aquaviario.json +209 -0
- data/data/schemas/schema_mdfe_transporte_ferroviario.json +99 -0
- data/data/schemas/schema_mdfe_transporte_rodoviario.json +628 -0
- data/data/schemas/schema_nfcom.json +1859 -0
- data/data/schemas/schema_nfe.json +4750 -0
- data/data/schemas/schema_nfe_forma_pagamento.json +97 -0
- data/data/schemas/schema_nfe_item.json +2574 -0
- data/data/schemas/schema_nfgas.json +2316 -0
- data/data/schemas/schema_nfse_nacional.json +1847 -0
- data/data/schemas/schema_nfse_recebida.json +548 -0
- data/lib/focus_nfe/client.rb +162 -0
- data/lib/focus_nfe/configuration.rb +104 -0
- data/lib/focus_nfe/errors.rb +123 -0
- data/lib/focus_nfe/esquemas/campo.rb +171 -0
- data/lib/focus_nfe/esquemas/catalogo.rb +34 -0
- data/lib/focus_nfe/esquemas/decimal.rb +66 -0
- data/lib/focus_nfe/esquemas/esquema.rb +72 -0
- data/lib/focus_nfe/esquemas/validador.rb +87 -0
- data/lib/focus_nfe/http/adapter.rb +25 -0
- data/lib/focus_nfe/http/adapters/net_http.rb +99 -0
- data/lib/focus_nfe/http/authentication.rb +23 -0
- data/lib/focus_nfe/http/connection.rb +118 -0
- data/lib/focus_nfe/http/logging.rb +100 -0
- data/lib/focus_nfe/http/response.rb +75 -0
- data/lib/focus_nfe/modelos/documento.rb +113 -0
- data/lib/focus_nfe/modelos/inutilizacao.rb +75 -0
- data/lib/focus_nfe/modelos/pagina.rb +54 -0
- data/lib/focus_nfe/recursos/backups.rb +17 -0
- data/lib/focus_nfe/recursos/base.rb +91 -0
- data/lib/focus_nfe/recursos/ceps.rb +16 -0
- data/lib/focus_nfe/recursos/cfops.rb +16 -0
- data/lib/focus_nfe/recursos/cnaes.rb +16 -0
- data/lib/focus_nfe/recursos/cnpjs.rb +13 -0
- data/lib/focus_nfe/recursos/concerns/baixavel.rb +41 -0
- data/lib/focus_nfe/recursos/concerns/baixavel_eventos.rb +34 -0
- data/lib/focus_nfe/recursos/concerns/cancelavel.rb +25 -0
- data/lib/focus_nfe/recursos/concerns/conciliavel.rb +66 -0
- data/lib/focus_nfe/recursos/concerns/consultavel.rb +26 -0
- data/lib/focus_nfe/recursos/concerns/corrigivel.rb +45 -0
- data/lib/focus_nfe/recursos/concerns/corrigivel_cte.rb +60 -0
- data/lib/focus_nfe/recursos/concerns/emitivel.rb +51 -0
- data/lib/focus_nfe/recursos/concerns/enviavel.rb +40 -0
- data/lib/focus_nfe/recursos/concerns/eventavel.rb +46 -0
- data/lib/focus_nfe/recursos/concerns/inutilizavel.rb +96 -0
- data/lib/focus_nfe/recursos/concerns/listavel.rb +22 -0
- data/lib/focus_nfe/recursos/concerns/localizavel.rb +22 -0
- data/lib/focus_nfe/recursos/concerns/notificavel.rb +23 -0
- data/lib/focus_nfe/recursos/concerns/removivel.rb +20 -0
- data/lib/focus_nfe/recursos/concerns/visualizavel.rb +28 -0
- data/lib/focus_nfe/recursos/cte.rb +35 -0
- data/lib/focus_nfe/recursos/cte_os.rb +29 -0
- data/lib/focus_nfe/recursos/ctes_recebidas.rb +38 -0
- data/lib/focus_nfe/recursos/dce.rb +16 -0
- data/lib/focus_nfe/recursos/emails_bloqueados.rb +31 -0
- data/lib/focus_nfe/recursos/empresas.rb +35 -0
- data/lib/focus_nfe/recursos/mdfe.rb +78 -0
- data/lib/focus_nfe/recursos/municipios.rb +60 -0
- data/lib/focus_nfe/recursos/ncms.rb +16 -0
- data/lib/focus_nfe/recursos/nfce.rb +19 -0
- data/lib/focus_nfe/recursos/nfcom.rb +16 -0
- data/lib/focus_nfe/recursos/nfe.rb +106 -0
- data/lib/focus_nfe/recursos/nfes_recebidas.rb +56 -0
- data/lib/focus_nfe/recursos/nfgas.rb +16 -0
- data/lib/focus_nfe/recursos/nfse.rb +18 -0
- data/lib/focus_nfe/recursos/nfse_nacional.rb +16 -0
- data/lib/focus_nfe/recursos/nfses_nacionais_recebidas.rb +21 -0
- data/lib/focus_nfe/recursos/webhooks.rb +22 -0
- data/lib/focus_nfe/version.rb +6 -0
- data/lib/focus_nfe/webhook.rb +68 -0
- data/lib/focus_nfe.rb +124 -0
- data/sig/focus_nfe/client.rbs +38 -0
- data/sig/focus_nfe/configuration.rbs +29 -0
- data/sig/focus_nfe/errors.rbs +59 -0
- data/sig/focus_nfe/esquemas/campo.rbs +47 -0
- data/sig/focus_nfe/esquemas/catalogo.rbs +8 -0
- data/sig/focus_nfe/esquemas/decimal.rbs +25 -0
- data/sig/focus_nfe/esquemas/esquema.rbs +30 -0
- data/sig/focus_nfe/esquemas/validador.rbs +20 -0
- data/sig/focus_nfe/http/adapter.rbs +7 -0
- data/sig/focus_nfe/http/adapters/net_http.rbs +25 -0
- data/sig/focus_nfe/http/authentication.rbs +9 -0
- data/sig/focus_nfe/http/connection.rbs +32 -0
- data/sig/focus_nfe/http/logging.rbs +30 -0
- data/sig/focus_nfe/http/response.rbs +28 -0
- data/sig/focus_nfe/modelos/documento.rbs +34 -0
- data/sig/focus_nfe/modelos/inutilizacao.rbs +24 -0
- data/sig/focus_nfe/modelos/pagina.rbs +21 -0
- data/sig/focus_nfe/recursos/backups.rbs +7 -0
- data/sig/focus_nfe/recursos/base.rbs +25 -0
- data/sig/focus_nfe/recursos/ceps.rbs +10 -0
- data/sig/focus_nfe/recursos/cfops.rbs +10 -0
- data/sig/focus_nfe/recursos/cnaes.rbs +10 -0
- data/sig/focus_nfe/recursos/cnpjs.rbs +7 -0
- data/sig/focus_nfe/recursos/concerns/baixavel.rbs +12 -0
- data/sig/focus_nfe/recursos/concerns/baixavel_eventos.rbs +14 -0
- data/sig/focus_nfe/recursos/concerns/cancelavel.rbs +9 -0
- data/sig/focus_nfe/recursos/concerns/conciliavel.rbs +15 -0
- data/sig/focus_nfe/recursos/concerns/consultavel.rbs +9 -0
- data/sig/focus_nfe/recursos/concerns/corrigivel.rbs +15 -0
- data/sig/focus_nfe/recursos/concerns/corrigivel_cte.rbs +17 -0
- data/sig/focus_nfe/recursos/concerns/emitivel.rbs +14 -0
- data/sig/focus_nfe/recursos/concerns/enviavel.rbs +15 -0
- data/sig/focus_nfe/recursos/concerns/eventavel.rbs +12 -0
- data/sig/focus_nfe/recursos/concerns/inutilizavel.rbs +20 -0
- data/sig/focus_nfe/recursos/concerns/listavel.rbs +9 -0
- data/sig/focus_nfe/recursos/concerns/localizavel.rbs +9 -0
- data/sig/focus_nfe/recursos/concerns/notificavel.rbs +9 -0
- data/sig/focus_nfe/recursos/concerns/removivel.rbs +9 -0
- data/sig/focus_nfe/recursos/concerns/visualizavel.rbs +9 -0
- data/sig/focus_nfe/recursos/cte.rbs +17 -0
- data/sig/focus_nfe/recursos/cte_os.rbs +17 -0
- data/sig/focus_nfe/recursos/ctes_recebidas.rbs +14 -0
- data/sig/focus_nfe/recursos/dce.rbs +10 -0
- data/sig/focus_nfe/recursos/emails_bloqueados.rbs +12 -0
- data/sig/focus_nfe/recursos/empresas.rbs +12 -0
- data/sig/focus_nfe/recursos/mdfe.rbs +21 -0
- data/sig/focus_nfe/recursos/municipios.rbs +19 -0
- data/sig/focus_nfe/recursos/ncms.rbs +10 -0
- data/sig/focus_nfe/recursos/nfce.rbs +12 -0
- data/sig/focus_nfe/recursos/nfcom.rbs +10 -0
- data/sig/focus_nfe/recursos/nfe.rbs +23 -0
- data/sig/focus_nfe/recursos/nfes_recebidas.rbs +16 -0
- data/sig/focus_nfe/recursos/nfgas.rbs +10 -0
- data/sig/focus_nfe/recursos/nfse.rbs +11 -0
- data/sig/focus_nfe/recursos/nfse_nacional.rbs +10 -0
- data/sig/focus_nfe/recursos/nfses_nacionais_recebidas.rbs +11 -0
- data/sig/focus_nfe/recursos/webhooks.rbs +11 -0
- data/sig/focus_nfe/webhook.rbs +11 -0
- data/sig/focus_nfe.rbs +10 -0
- data/spec/focus_nfe/client_spec.rb +208 -0
- data/spec/focus_nfe/configuration_spec.rb +121 -0
- data/spec/focus_nfe/errors_mapping_spec.rb +68 -0
- data/spec/focus_nfe/errors_spec.rb +107 -0
- data/spec/focus_nfe/esquemas/campo_spec.rb +291 -0
- data/spec/focus_nfe/esquemas/decimal_spec.rb +54 -0
- data/spec/focus_nfe/esquemas/esquema_spec.rb +73 -0
- data/spec/focus_nfe/esquemas/validador_spec.rb +167 -0
- data/spec/focus_nfe/esquemas_spec.rb +42 -0
- data/spec/focus_nfe/http/adapter_spec.rb +8 -0
- data/spec/focus_nfe/http/adapters/net_http_spec.rb +181 -0
- data/spec/focus_nfe/http/authentication_spec.rb +24 -0
- data/spec/focus_nfe/http/connection_spec.rb +255 -0
- data/spec/focus_nfe/http/logging_spec.rb +83 -0
- data/spec/focus_nfe/http/response_spec.rb +161 -0
- data/spec/focus_nfe/modelos/documento_spec.rb +150 -0
- data/spec/focus_nfe/modelos/inutilizacao_spec.rb +91 -0
- data/spec/focus_nfe/modelos/pagina_spec.rb +77 -0
- data/spec/focus_nfe/recursos/backups_spec.rb +29 -0
- data/spec/focus_nfe/recursos/base_spec.rb +56 -0
- data/spec/focus_nfe/recursos/ceps_spec.rb +16 -0
- data/spec/focus_nfe/recursos/cfops_spec.rb +16 -0
- data/spec/focus_nfe/recursos/cnaes_spec.rb +20 -0
- data/spec/focus_nfe/recursos/cnpjs_spec.rb +11 -0
- data/spec/focus_nfe/recursos/concerns/emitivel_validacao_spec.rb +158 -0
- data/spec/focus_nfe/recursos/cte_os_spec.rb +9 -0
- data/spec/focus_nfe/recursos/cte_spec.rb +9 -0
- data/spec/focus_nfe/recursos/ctes_recebidas_spec.rb +56 -0
- data/spec/focus_nfe/recursos/dce_spec.rb +8 -0
- data/spec/focus_nfe/recursos/emails_bloqueados_spec.rb +29 -0
- data/spec/focus_nfe/recursos/empresas_spec.rb +45 -0
- data/spec/focus_nfe/recursos/mdfe_spec.rb +100 -0
- data/spec/focus_nfe/recursos/municipios_spec.rb +58 -0
- data/spec/focus_nfe/recursos/ncms_spec.rb +16 -0
- data/spec/focus_nfe/recursos/nfce_spec.rb +10 -0
- data/spec/focus_nfe/recursos/nfcom_spec.rb +8 -0
- data/spec/focus_nfe/recursos/nfe_spec.rb +262 -0
- data/spec/focus_nfe/recursos/nfes_recebidas_spec.rb +87 -0
- data/spec/focus_nfe/recursos/nfgas_spec.rb +8 -0
- data/spec/focus_nfe/recursos/nfse_nacional_spec.rb +8 -0
- data/spec/focus_nfe/recursos/nfse_spec.rb +9 -0
- data/spec/focus_nfe/recursos/nfses_nacionais_recebidas_spec.rb +17 -0
- data/spec/focus_nfe/recursos/webhooks_spec.rb +22 -0
- data/spec/focus_nfe/webhook_spec.rb +66 -0
- data/spec/focus_nfe_global_configuration_spec.rb +70 -0
- data/spec/focus_nfe_require_spec.rb +87 -0
- data/spec/focus_nfe_spec.rb +11 -0
- data/spec/spec_helper.rb +58 -0
- data/spec/support/shared_examples/recurso_fiscal.rb +445 -0
- data/spec/support/shared_examples/recurso_leitura.rb +217 -0
- data/tools/pull_fields.rb +62 -0
- metadata +420 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
class Client
|
|
3
|
+
attr_reader configuration: FocusNfe::Configuration
|
|
4
|
+
|
|
5
|
+
def initialize: (?FocusNfe::Configuration? configuration, **untyped options) -> void
|
|
6
|
+
|
|
7
|
+
def connection: () -> FocusNfe::HTTP::Connection
|
|
8
|
+
def connection_conta: () -> FocusNfe::HTTP::Connection
|
|
9
|
+
|
|
10
|
+
def nfe: () -> FocusNfe::Recursos::Nfe
|
|
11
|
+
def nfce: () -> FocusNfe::Recursos::Nfce
|
|
12
|
+
def nfse: () -> FocusNfe::Recursos::Nfse
|
|
13
|
+
def nfse_nacional: () -> FocusNfe::Recursos::NfseNacional
|
|
14
|
+
def cte: () -> FocusNfe::Recursos::Cte
|
|
15
|
+
def cte_os: () -> FocusNfe::Recursos::CteOs
|
|
16
|
+
def mdfe: () -> FocusNfe::Recursos::Mdfe
|
|
17
|
+
def nfcom: () -> FocusNfe::Recursos::Nfcom
|
|
18
|
+
def dce: () -> FocusNfe::Recursos::Dce
|
|
19
|
+
def nfgas: () -> FocusNfe::Recursos::Nfgas
|
|
20
|
+
def nfes_recebidas: () -> FocusNfe::Recursos::NfesRecebidas
|
|
21
|
+
def ctes_recebidas: () -> FocusNfe::Recursos::CtesRecebidas
|
|
22
|
+
def nfses_nacionais_recebidas: () -> FocusNfe::Recursos::NfsesNacionaisRecebidas
|
|
23
|
+
def ceps: () -> FocusNfe::Recursos::Ceps
|
|
24
|
+
def municipios: () -> FocusNfe::Recursos::Municipios
|
|
25
|
+
def cfops: () -> FocusNfe::Recursos::Cfops
|
|
26
|
+
def cnaes: () -> FocusNfe::Recursos::Cnaes
|
|
27
|
+
def ncms: () -> FocusNfe::Recursos::Ncms
|
|
28
|
+
def cnpjs: () -> FocusNfe::Recursos::Cnpjs
|
|
29
|
+
def empresas: () -> FocusNfe::Recursos::Empresas
|
|
30
|
+
def webhooks: () -> FocusNfe::Recursos::Webhooks
|
|
31
|
+
def emails_bloqueados: () -> FocusNfe::Recursos::EmailsBloqueados
|
|
32
|
+
def backups: () -> FocusNfe::Recursos::Backups
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def build_connection: (Symbol escopo) -> FocusNfe::HTTP::Connection
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
class Configuration
|
|
3
|
+
BASE_URLS: Hash[Symbol, String]
|
|
4
|
+
ESCOPOS_TOKEN: Hash[Symbol, Symbol]
|
|
5
|
+
DEFAULT_ENVIRONMENT: Symbol
|
|
6
|
+
DEFAULT_TIMEOUT: Integer
|
|
7
|
+
DEFAULT_OPEN_TIMEOUT: Integer
|
|
8
|
+
|
|
9
|
+
attr_accessor token_empresa: String?
|
|
10
|
+
attr_accessor token_conta: String?
|
|
11
|
+
attr_accessor environment: Symbol
|
|
12
|
+
attr_accessor timeout: Integer
|
|
13
|
+
attr_accessor open_timeout: Integer
|
|
14
|
+
attr_accessor logger: untyped
|
|
15
|
+
attr_accessor http_adapter: FocusNfe::HTTP::Adapter?
|
|
16
|
+
attr_accessor headers: Hash[untyped, untyped]
|
|
17
|
+
|
|
18
|
+
def initialize: (?token_empresa: String?, ?token_conta: String?, ?environment: Symbol, ?timeout: Integer, ?open_timeout: Integer, ?logger: untyped, ?http_adapter: FocusNfe::HTTP::Adapter?, ?headers: Hash[untyped, untyped]) -> void
|
|
19
|
+
def base_url: () -> String
|
|
20
|
+
def token_de: (Symbol escopo) -> String?
|
|
21
|
+
def validate!: () -> self
|
|
22
|
+
def validate_token!: (Symbol escopo) -> self
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def validate_environment!: () -> void
|
|
27
|
+
def token_presente?: (Symbol escopo) -> bool
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
class Error < StandardError
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
module Errors
|
|
6
|
+
class HttpError < FocusNfe::Error
|
|
7
|
+
attr_reader status: Integer?
|
|
8
|
+
attr_reader body: untyped
|
|
9
|
+
attr_reader response: FocusNfe::HTTP::Response?
|
|
10
|
+
|
|
11
|
+
def initialize: (?String? message, ?status: Integer?, ?body: untyped, ?response: FocusNfe::HTTP::Response?) -> void
|
|
12
|
+
|
|
13
|
+
def codigo: () -> String?
|
|
14
|
+
|
|
15
|
+
def erros: () -> Array[untyped]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class BadRequest < HttpError
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Unauthorized < HttpError
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Forbidden < HttpError
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class NotFound < HttpError
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Conflict < HttpError
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class ValidationError < HttpError
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class RateLimited < HttpError
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class ServerError < HttpError
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class UnexpectedResponse < HttpError
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class ConfigurationError < FocusNfe::Error
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class ConnectionError < FocusNfe::Error
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class WebhookError < FocusNfe::Error
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
BY_STATUS: Hash[Integer, singleton(FocusNfe::Errors::HttpError)]
|
|
55
|
+
|
|
56
|
+
def self?.class_for: (Integer status) -> singleton(FocusNfe::Errors::HttpError)
|
|
57
|
+
def self?.from_response: (FocusNfe::HTTP::Response response) -> FocusNfe::Errors::HttpError
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Esquemas
|
|
3
|
+
class Campo
|
|
4
|
+
ESCALAR: Regexp
|
|
5
|
+
CODIGO_ENUM: Regexp
|
|
6
|
+
|
|
7
|
+
@definicao: Hash[untyped, untyped]
|
|
8
|
+
@tipo: Symbol?
|
|
9
|
+
@tamanho_minimo: Integer?
|
|
10
|
+
@tamanho_maximo: Integer?
|
|
11
|
+
@decimal: FocusNfe::Esquemas::Decimal?
|
|
12
|
+
@valores_enum: Array[String]?
|
|
13
|
+
@esquema_colecao: FocusNfe::Esquemas::Esquema?
|
|
14
|
+
|
|
15
|
+
attr_reader tipo: Symbol?
|
|
16
|
+
attr_reader tamanho_minimo: Integer?
|
|
17
|
+
attr_reader tamanho_maximo: Integer?
|
|
18
|
+
attr_reader decimal: FocusNfe::Esquemas::Decimal?
|
|
19
|
+
|
|
20
|
+
def initialize: (Hash[untyped, untyped] definicao) -> void
|
|
21
|
+
def nome: () -> String
|
|
22
|
+
def descricao: () -> String?
|
|
23
|
+
def tipo_bruto: () -> String?
|
|
24
|
+
def enum: () -> untyped
|
|
25
|
+
def valores_enum: () -> Array[String]
|
|
26
|
+
def enum?: () -> bool
|
|
27
|
+
def tag: () -> String?
|
|
28
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
29
|
+
def obrigatorio?: () -> bool
|
|
30
|
+
def colecao?: () -> bool
|
|
31
|
+
def esquema_colecao: () -> FocusNfe::Esquemas::Esquema?
|
|
32
|
+
def validar_valor: (untyped valor) -> String?
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def parsear_tipo: () -> void
|
|
37
|
+
def tipo_nao_escalar: (String? bruto) -> Symbol
|
|
38
|
+
def parsear_escalar: (MatchData match) -> void
|
|
39
|
+
def validar_tipo: (untyped valor) -> String?
|
|
40
|
+
def validar_string: (untyped valor) -> String?
|
|
41
|
+
def validar_integer: (untyped valor) -> String?
|
|
42
|
+
def validar_decimal: (untyped valor) -> String?
|
|
43
|
+
def validar_data: (untyped valor, untyped classe) -> String?
|
|
44
|
+
def validar_enum: (untyped valor) -> String?
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Esquemas
|
|
3
|
+
class Decimal
|
|
4
|
+
ESPEC: Regexp
|
|
5
|
+
VALOR: Regexp
|
|
6
|
+
|
|
7
|
+
@inteiros: Integer
|
|
8
|
+
@casas_minimas: Integer
|
|
9
|
+
@casas_maximas: Integer
|
|
10
|
+
|
|
11
|
+
attr_reader inteiros: Integer
|
|
12
|
+
attr_reader casas_minimas: Integer
|
|
13
|
+
attr_reader casas_maximas: Integer
|
|
14
|
+
|
|
15
|
+
def self.parsear: (String? bruto) -> FocusNfe::Esquemas::Decimal?
|
|
16
|
+
def initialize: (MatchData match) -> void
|
|
17
|
+
def validar: (untyped valor) -> String?
|
|
18
|
+
def to_h: () -> Hash[Symbol, Integer]
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def erro_de_tamanho: (String inteira, String? fracionaria) -> String?
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Esquemas
|
|
3
|
+
class ErroDeValidacao < FocusNfe::Error
|
|
4
|
+
attr_reader erros: Array[String]
|
|
5
|
+
|
|
6
|
+
def initialize: (Array[String] erros) -> void
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class Esquema
|
|
10
|
+
DIRETORIO: String
|
|
11
|
+
|
|
12
|
+
NOME_VALIDO: Regexp
|
|
13
|
+
|
|
14
|
+
self.@cache: Hash[String?, FocusNfe::Esquemas::Esquema?]
|
|
15
|
+
|
|
16
|
+
def self.carregar: (String? nome) -> FocusNfe::Esquemas::Esquema?
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def self.cache: () -> Hash[String?, FocusNfe::Esquemas::Esquema?]
|
|
21
|
+
|
|
22
|
+
public
|
|
23
|
+
|
|
24
|
+
attr_reader campos: Array[FocusNfe::Esquemas::Campo]
|
|
25
|
+
|
|
26
|
+
def initialize: (Array[Hash[untyped, untyped]] definicoes) -> void
|
|
27
|
+
def descrever: () -> Array[Hash[Symbol, untyped]]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Esquemas
|
|
3
|
+
class Validador
|
|
4
|
+
@esquema: FocusNfe::Esquemas::Esquema
|
|
5
|
+
@aninhados: Hash[String, FocusNfe::Esquemas::Esquema]
|
|
6
|
+
|
|
7
|
+
def initialize: (FocusNfe::Esquemas::Esquema esquema, ?aninhados: Hash[String, FocusNfe::Esquemas::Esquema]) -> void
|
|
8
|
+
def validar: (Hash[untyped, untyped] dados) -> Array[String]
|
|
9
|
+
def validar!: (Hash[untyped, untyped] dados) -> void
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def validar_campos: (FocusNfe::Esquemas::Esquema esquema, Hash[untyped, untyped] dados) -> Array[String]
|
|
14
|
+
def validar_aninhados: (Hash[untyped, untyped] dados) -> Array[String]
|
|
15
|
+
def erros_para: (FocusNfe::Esquemas::Campo campo, Hash[untyped, untyped] dados) -> Array[String]
|
|
16
|
+
def validar_colecao: (FocusNfe::Esquemas::Campo campo, untyped valor) -> Array[String]
|
|
17
|
+
def normalizar: (Hash[untyped, untyped] dados) -> Hash[String, untyped]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module HTTP
|
|
3
|
+
module Adapters
|
|
4
|
+
class NetHttp < FocusNfe::HTTP::Adapter
|
|
5
|
+
MAX_REDIRECTS: Integer
|
|
6
|
+
VERBS: Hash[Symbol, singleton(Net::HTTPRequest)]
|
|
7
|
+
|
|
8
|
+
@timeout: Integer?
|
|
9
|
+
@open_timeout: Integer?
|
|
10
|
+
|
|
11
|
+
def initialize: (?timeout: Integer?, ?open_timeout: Integer?) -> void
|
|
12
|
+
def call: (Symbol method, String url, ?headers: Hash[untyped, untyped], ?body: String?) -> FocusNfe::HTTP::Response
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def dispatch: (Symbol method, URI::Generic uri, Hash[untyped, untyped] headers, String? body, Integer redirects_left) -> FocusNfe::HTTP::Response
|
|
17
|
+
def transport: (Symbol method, URI::Generic uri, Hash[untyped, untyped] headers, String? body) -> Net::HTTPResponse
|
|
18
|
+
def build_request: (Symbol method, URI::Generic uri, Hash[untyped, untyped] headers, String? body) -> Net::HTTPRequest
|
|
19
|
+
def http_for: (URI::Generic uri) -> Net::HTTP
|
|
20
|
+
def build_response: (Net::HTTPResponse raw) -> FocusNfe::HTTP::Response
|
|
21
|
+
def without_authorization: (Hash[untyped, untyped] headers) -> Hash[untyped, untyped]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module HTTP
|
|
3
|
+
class Connection
|
|
4
|
+
PREFIX: String
|
|
5
|
+
DEFAULT_HEADERS: Hash[String, String]
|
|
6
|
+
|
|
7
|
+
@adapter: FocusNfe::HTTP::Adapter?
|
|
8
|
+
@logging: FocusNfe::HTTP::Logging
|
|
9
|
+
|
|
10
|
+
def initialize: (FocusNfe::Configuration configuration, token: String) -> void
|
|
11
|
+
|
|
12
|
+
def get: (String? path, ?params: Hash[untyped, untyped]?, ?body: (Hash[untyped, untyped] | String)?, ?headers: Hash[untyped, untyped]) -> FocusNfe::HTTP::Response
|
|
13
|
+
def post: (String? path, ?params: Hash[untyped, untyped]?, ?body: (Hash[untyped, untyped] | String)?, ?headers: Hash[untyped, untyped]) -> FocusNfe::HTTP::Response
|
|
14
|
+
def put: (String? path, ?params: Hash[untyped, untyped]?, ?body: (Hash[untyped, untyped] | String)?, ?headers: Hash[untyped, untyped]) -> FocusNfe::HTTP::Response
|
|
15
|
+
def delete: (String? path, ?params: Hash[untyped, untyped]?, ?body: (Hash[untyped, untyped] | String)?, ?headers: Hash[untyped, untyped]) -> FocusNfe::HTTP::Response
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
attr_reader configuration: FocusNfe::Configuration
|
|
20
|
+
attr_reader token: String
|
|
21
|
+
|
|
22
|
+
def execute: (Symbol verb, String? path, params: Hash[untyped, untyped]?, body: (Hash[untyped, untyped] | String)?, headers: Hash[untyped, untyped]) -> FocusNfe::HTTP::Response
|
|
23
|
+
def call_adapter: (Symbol verb, String url, Hash[untyped, untyped] request_headers, (Hash[untyped, untyped] | String)? body, Float started) -> FocusNfe::HTTP::Response
|
|
24
|
+
def elapsed_since: (Float started) -> Float
|
|
25
|
+
def build_url: (String? path, Hash[untyped, untyped]? params) -> String
|
|
26
|
+
def build_headers: (Hash[untyped, untyped] call_headers) -> Hash[untyped, untyped]
|
|
27
|
+
def serialize: ((Hash[untyped, untyped] | String)? body) -> String?
|
|
28
|
+
def logging: () -> FocusNfe::HTTP::Logging
|
|
29
|
+
def adapter: () -> FocusNfe::HTTP::Adapter
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module HTTP
|
|
3
|
+
interface _Logger
|
|
4
|
+
def debug: (?untyped progname) ?{ () -> untyped } -> untyped
|
|
5
|
+
def info: (?untyped progname) ?{ () -> untyped } -> untyped
|
|
6
|
+
def warn: (?untyped progname) ?{ () -> untyped } -> untyped
|
|
7
|
+
def error: (?untyped progname) ?{ () -> untyped } -> untyped
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Logging
|
|
11
|
+
REDACTED: String
|
|
12
|
+
SENSITIVE_HEADERS: Array[String]
|
|
13
|
+
BODY_MAX: Integer
|
|
14
|
+
|
|
15
|
+
@logger: _Logger?
|
|
16
|
+
|
|
17
|
+
def initialize: (_Logger? logger) -> void
|
|
18
|
+
|
|
19
|
+
def request: (Symbol verb, String url, Hash[String, String] headers) -> void
|
|
20
|
+
def response: (Symbol verb, String url, Integer status, Float elapsed, String? body) -> void
|
|
21
|
+
def failure: (Symbol verb, String url, Exception error, Float elapsed) -> void
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def redact: (Hash[String, String] headers) -> Hash[String, String]
|
|
26
|
+
def truncate: (String? body) -> String
|
|
27
|
+
def ms: (Float elapsed) -> Integer
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module HTTP
|
|
3
|
+
class Response
|
|
4
|
+
class Headers
|
|
5
|
+
@data: Hash[String, untyped]
|
|
6
|
+
|
|
7
|
+
def initialize: (Hash[untyped, untyped] source) -> void
|
|
8
|
+
def []: (untyped key) -> String?
|
|
9
|
+
def to_h: () -> Hash[String, untyped]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
JSON_TYPE: Regexp
|
|
13
|
+
|
|
14
|
+
attr_reader status: Integer
|
|
15
|
+
attr_reader headers: FocusNfe::HTTP::Response::Headers
|
|
16
|
+
attr_reader body: untyped
|
|
17
|
+
attr_reader raw_body: String?
|
|
18
|
+
|
|
19
|
+
def initialize: (status: Integer, ?headers: Hash[untyped, untyped], ?body: String?) -> void
|
|
20
|
+
def success?: () -> bool
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def parse_body: () -> untyped
|
|
25
|
+
def json?: () -> bool
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Modelos
|
|
3
|
+
class Documento
|
|
4
|
+
attr_reader response: FocusNfe::HTTP::Response?
|
|
5
|
+
attr_reader ref: String?
|
|
6
|
+
attr_reader dados: Hash[untyped, untyped]
|
|
7
|
+
|
|
8
|
+
def self.from_response: (FocusNfe::HTTP::Response response, ?ref: String?) -> FocusNfe::Modelos::Documento
|
|
9
|
+
|
|
10
|
+
def self.from_payload: (untyped corpo, ?ref: String?) -> FocusNfe::Modelos::Documento
|
|
11
|
+
|
|
12
|
+
def initialize: (dados: untyped, ?ref: String?, ?response: FocusNfe::HTTP::Response?) -> void
|
|
13
|
+
|
|
14
|
+
def status: () -> untyped
|
|
15
|
+
def status_sefaz: () -> untyped
|
|
16
|
+
def mensagem_sefaz: () -> untyped
|
|
17
|
+
def chave_nfe: () -> untyped
|
|
18
|
+
def numero: () -> untyped
|
|
19
|
+
def serie: () -> untyped
|
|
20
|
+
def caminho_xml_nota_fiscal: () -> untyped
|
|
21
|
+
def caminho_danfe: () -> untyped
|
|
22
|
+
def caminho_xml_carta_correcao: () -> untyped
|
|
23
|
+
def caminho_pdf_carta_correcao: () -> untyped
|
|
24
|
+
def numero_carta_correcao: () -> untyped
|
|
25
|
+
|
|
26
|
+
def []: (untyped chave) -> untyped
|
|
27
|
+
def autorizado?: () -> bool
|
|
28
|
+
def cancelado?: () -> bool
|
|
29
|
+
def processando?: () -> bool
|
|
30
|
+
def erro?: () -> bool
|
|
31
|
+
def denegado?: () -> bool
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Modelos
|
|
3
|
+
class Inutilizacao
|
|
4
|
+
attr_reader response: FocusNfe::HTTP::Response?
|
|
5
|
+
attr_reader dados: Hash[untyped, untyped]
|
|
6
|
+
|
|
7
|
+
def self.from_response: (FocusNfe::HTTP::Response response) -> FocusNfe::Modelos::Inutilizacao
|
|
8
|
+
def self.from_item: (untyped item) -> FocusNfe::Modelos::Inutilizacao
|
|
9
|
+
|
|
10
|
+
def initialize: (dados: Hash[untyped, untyped], ?response: FocusNfe::HTTP::Response?) -> void
|
|
11
|
+
|
|
12
|
+
def status: () -> untyped
|
|
13
|
+
def status_sefaz: () -> untyped
|
|
14
|
+
def mensagem_sefaz: () -> untyped
|
|
15
|
+
def protocolo: () -> untyped
|
|
16
|
+
def serie: () -> untyped
|
|
17
|
+
def numero_inicial: () -> untyped
|
|
18
|
+
def numero_final: () -> untyped
|
|
19
|
+
|
|
20
|
+
def []: (untyped chave) -> untyped
|
|
21
|
+
def autorizado?: () -> bool
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Modelos
|
|
3
|
+
class Pagina
|
|
4
|
+
include Enumerable[untyped]
|
|
5
|
+
|
|
6
|
+
attr_reader response: FocusNfe::HTTP::Response
|
|
7
|
+
attr_reader itens: Array[untyped]
|
|
8
|
+
attr_reader total: Integer?
|
|
9
|
+
attr_reader versao_maxima: Integer?
|
|
10
|
+
|
|
11
|
+
def self.from_response: (FocusNfe::HTTP::Response response) -> FocusNfe::Modelos::Pagina
|
|
12
|
+
|
|
13
|
+
def initialize: (response: FocusNfe::HTTP::Response) -> void
|
|
14
|
+
|
|
15
|
+
def each: () { (untyped) -> void } -> self
|
|
16
|
+
| () -> ::Enumerator[untyped, untyped]
|
|
17
|
+
|
|
18
|
+
alias cada each
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Recursos
|
|
3
|
+
class Base
|
|
4
|
+
REFERENCIA: Regexp
|
|
5
|
+
|
|
6
|
+
self.@caminho_base: String?
|
|
7
|
+
self.@caminho_base_previa: String?
|
|
8
|
+
|
|
9
|
+
def self.caminho_base: (?String? valor) -> String?
|
|
10
|
+
def self.caminho_base_previa: (?String? valor) -> String?
|
|
11
|
+
|
|
12
|
+
def initialize: (FocusNfe::HTTP::Connection connection) -> void
|
|
13
|
+
def caminho_base: () -> String?
|
|
14
|
+
def caminho_base_previa: () -> String?
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
attr_reader connection: FocusNfe::HTTP::Connection
|
|
19
|
+
|
|
20
|
+
def caminho_referencia: (String | Integer ref) -> String
|
|
21
|
+
def validar_referencia!: (untyped ref) -> void
|
|
22
|
+
def esquemas_extras: (Hash[untyped, untyped] dados) -> Hash[String, String]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Recursos
|
|
3
|
+
module Concerns
|
|
4
|
+
module Baixavel : FocusNfe::Recursos::Base
|
|
5
|
+
def download: (String identificador, formato: (String | Symbol)) -> String?
|
|
6
|
+
def download_json: (String identificador) -> String?
|
|
7
|
+
def download_xml: (String identificador) -> String?
|
|
8
|
+
def download_pdf: (String identificador) -> String?
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Recursos
|
|
3
|
+
module Concerns
|
|
4
|
+
module BaixavelEventos : FocusNfe::Recursos::Base
|
|
5
|
+
def download_xml_cancelamento: (String chave) -> String?
|
|
6
|
+
def download_xml_carta_correcao: (String chave) -> String?
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def download_xml_evento: (String chave, evento: String) -> String?
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Recursos
|
|
3
|
+
module Concerns
|
|
4
|
+
module Conciliavel : FocusNfe::Recursos::Base
|
|
5
|
+
def registrar_econf: (String ref, detalhes_pagamento: untyped) -> FocusNfe::Modelos::Documento
|
|
6
|
+
def consultar_econf: (String ref, String numero_protocolo) -> FocusNfe::Modelos::Documento
|
|
7
|
+
def cancelar_econf: (String ref, String numero_protocolo) -> FocusNfe::Modelos::Documento
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def caminho_econf: (String ref, String numero_protocolo) -> String
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Recursos
|
|
3
|
+
module Concerns
|
|
4
|
+
module Corrigivel : FocusNfe::Recursos::Base
|
|
5
|
+
TAMANHO_CORRECAO: Range[Integer]
|
|
6
|
+
|
|
7
|
+
def corrigir: (String ref, correcao: String, ?data_evento: String?) -> FocusNfe::Modelos::Documento
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def validar_correcao!: (untyped correcao) -> void
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module FocusNfe
|
|
2
|
+
module Recursos
|
|
3
|
+
module Concerns
|
|
4
|
+
module CorrigivelCte : FocusNfe::Recursos::Base
|
|
5
|
+
def corrigir: (String ref, campo_corrigido: String, valor_corrigido: String,
|
|
6
|
+
?grupo_corrigido: String?, ?numero_item_grupo_corrigido: String?,
|
|
7
|
+
?campo_api: (Integer | String)?) -> FocusNfe::Modelos::Documento
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def validar_campos_correcao!: (untyped campo_corrigido, untyped valor_corrigido) -> void
|
|
12
|
+
|
|
13
|
+
def string_preenchida?: (untyped valor) -> bool
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|