Class: FocusNfe::HTTP::Connection
- Inherits:
-
Object
- Object
- FocusNfe::HTTP::Connection
- Defined in:
- lib/focus_nfe/http/connection.rb
Overview
Ponto único de transporte: monta a URL com o prefixo /v2, injeta os
cabeçalhos padrão (JSON, User-Agent, Basic Auth) mais os extras da
Configuration, serializa o corpo Hash para JSON e despacha ao adaptador.
Devolve a Response em 2xx e levanta a exceção tipada em não-2xx — assim
cada recurso futuro vira uma camada fina sobre esta classe.
Constant Summary collapse
- PREFIX =
Returns prefixo de versão da API, inserido em toda URL.
"v2"- DEFAULT_HEADERS =
Returns cabeçalhos enviados em toda requisição.
{ "Content-Type" => "application/json", "Accept" => "application/json", "User-Agent" => "focus_nfe/#{FocusNfe::VERSION}" }.freeze
Instance Method Summary collapse
-
#delete(path, params: {}, body: nil, headers: {}) ⇒ FocusNfe::HTTP::Response
Em respostas 2xx.
-
#get(path, params: {}, body: nil, headers: {}) ⇒ FocusNfe::HTTP::Response
Em respostas 2xx.
-
#initialize(configuration, token:) ⇒ Connection
constructor
A new instance of Connection.
-
#post(path, params: {}, body: nil, headers: {}) ⇒ FocusNfe::HTTP::Response
Em respostas 2xx.
-
#put(path, params: {}, body: nil, headers: {}) ⇒ FocusNfe::HTTP::Response
Em respostas 2xx.
Constructor Details
#initialize(configuration, token:) ⇒ Connection
Returns a new instance of Connection.
26 27 28 29 |
# File 'lib/focus_nfe/http/connection.rb', line 26 def initialize(configuration, token:) @configuration = configuration @token = token end |
Instance Method Details
#delete(path, params: {}, body: nil, headers: {}) ⇒ FocusNfe::HTTP::Response
Returns em respostas 2xx.
52 53 54 |
# File 'lib/focus_nfe/http/connection.rb', line 52 def delete(path, params: {}, body: nil, headers: {}) execute(:delete, path, params: params, body: body, headers: headers) end |
#get(path, params: {}, body: nil, headers: {}) ⇒ FocusNfe::HTTP::Response
Returns em respostas 2xx.
37 38 39 |
# File 'lib/focus_nfe/http/connection.rb', line 37 def get(path, params: {}, body: nil, headers: {}) execute(:get, path, params: params, body: body, headers: headers) end |
#post(path, params: {}, body: nil, headers: {}) ⇒ FocusNfe::HTTP::Response
Returns em respostas 2xx.
42 43 44 |
# File 'lib/focus_nfe/http/connection.rb', line 42 def post(path, params: {}, body: nil, headers: {}) execute(:post, path, params: params, body: body, headers: headers) end |
#put(path, params: {}, body: nil, headers: {}) ⇒ FocusNfe::HTTP::Response
Returns em respostas 2xx.
47 48 49 |
# File 'lib/focus_nfe/http/connection.rb', line 47 def put(path, params: {}, body: nil, headers: {}) execute(:put, path, params: params, body: body, headers: headers) end |