Module: ApiAdaptor::Variables

Defined in:
lib/api_adaptor/variables.rb

Overview

Environment variable configuration for User-Agent metadata

These variables are used to construct the User-Agent header for HTTP requests, allowing API providers to identify and contact clients if needed.

Examples:

Setting environment variables

ENV["APP_NAME"] = "MyApiClient"
ENV["APP_VERSION"] = "2.1.0"
ENV["APP_CONTACT"] = "[email protected]"

User-Agent header format

# "MyApiClient/2.1.0 ([email protected])"

See Also:

  • JSONClient.default_request_headers

Class Method Summary collapse

Class Method Details

.app_contactString

Returns the application contact from environment variable

Should be an email address or URL where API providers can reach you.

Examples:

ENV["APP_CONTACT"] = "[email protected]"
Variables.app_contact  # => "[email protected]"

Returns:

  • Contact information (default: "Contact not stated")



50
51
52
# File 'lib/api_adaptor/variables.rb', line 50

def self.app_contact
  ENV["APP_CONTACT"] || "Contact not stated"
end

.app_nameString

Returns the application name from environment variable

Examples:

ENV["APP_NAME"] = "WikidataClient"
Variables.app_name  # => "WikidataClient"

Returns:

  • Application name (default: "Ruby ApiAdaptor App")



26
27
28
# File 'lib/api_adaptor/variables.rb', line 26

def self.app_name
  ENV["APP_NAME"] || "Ruby ApiAdaptor App"
end

.app_versionString

Returns the application version from environment variable

Examples:

ENV["APP_VERSION"] = "3.2.1"
Variables.app_version  # => "3.2.1"

Returns:

  • Application version (default: "Version not stated")



37
38
39
# File 'lib/api_adaptor/variables.rb', line 37

def self.app_version
  ENV["APP_VERSION"] || "Version not stated"
end