Module: Nfe::Http::Transport

Defined in:
lib/nfe/http/transport.rb,
sig/nfe/http/transport.rbs

Overview

Transport contract: any object that turns a Request into a Response.

The SDK routes every HTTP call through an object responding to call(request). The default implementation is NetHttp (zero external dependencies), but any duck-typed object satisfying this contract may be substituted — a logging decorator, a retrying decorator, or an in-memory fake for tests.

Contract

An implementation of call(request):

  • SHALL accept a Request and return a Response.
  • SHALL return HTTP 4xx and 5xx outcomes as a Response carrying that status — it SHALL NOT raise for them. The retry decorator and ErrorFactory act on the status code.
  • SHALL raise ONLY ApiConnectionError (or its subclass TimeoutError) on network failures — connection refused, DNS, TLS, read/connect timeouts.
  • SHALL NOT follow HTTP 202 responses or redirects automatically; it SHALL preserve the raw status and the Location header so the caller can implement the async Pending/Issued contract.
  • SHALL normalize response header keys to lowercase strings and return a binary-safe (ASCII-8BIT) body.

Mix this module in to inherit the NotImplementedError default, or simply define call on any object (duck typing).

Instance Method Summary collapse

Instance Method Details

#call(request) ⇒ Nfe::Http::Response

Perform the request.

Parameters:

Returns:

Raises:

  • (NotImplementedError)

    unless overridden.



39
40
41
# File 'lib/nfe/http/transport.rb', line 39

def call(request)
  raise NotImplementedError, "#{self.class} must implement #call(request)"
end