Module: Nfe::Http::UserAgent

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

Overview

Builds the User-Agent string sent with every outgoing request.

The format is NFE.io Ruby Client v ruby/ (), optionally followed by a caller-supplied suffix (e.g. the host application's name configured via Nfe::Configuration#user_agent_suffix).

Injection of the resulting header onto a request is performed by the +Client+/+AbstractResource+ layer (see the add-client-core change); the transport itself only transmits whatever User-Agent the Request carries.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(suffix = nil) ⇒ Object

Returns the User-Agent string. When suffix is a non-empty string it is appended after a single space.



20
21
22
23
24
25
# File 'lib/nfe/http/user_agent.rb', line 20

def build(suffix = nil)
  base = "NFE.io Ruby Client v#{Nfe::VERSION} ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM})"
  return base if suffix.nil? || suffix.to_s.empty?

  "#{base} #{suffix}"
end

Instance Method Details

#self?.buildString

Parameters:

  • suffix (String, nil)

Returns:

  • (String)


4
# File 'sig/nfe/http/user_agent.rbs', line 4

def self?.build: (?String? suffix) -> String