module ReamazeAPI

Constants

Config

Public: Configuration class

VERSION

Public Class Methods

config() { |config| ... } click to toggle source

Public: Optional default configuration used to authenticate with the Reamaze API.

Yields the Config instance if a block is given.

Returns a Config instance.

# File lib/reamaze_api.rb, line 22
def self.config
  @config ||= Config.new
  yield @config if block_given?
  @config
end
new(**credentials, &block) click to toggle source

Public: Initializes a new API Client instance.

**credentials - Credentials used with the Reamaze API (optional)

:brand - Brand name (subdomain from your Reamaze URL)
:login - Reamaze login
:token - Reamaze API token

block - Optional block that yields a Faraday::Connection instance

(for customizing middleware, headers, etc)

The credentials passed to the API can be configured globally via `ReamazeAPI.config` or passed to this method. Credentials passed directly to this method take precedence over those configured globally.

Raises ArgumentError if a brand, login or token cannot be found.

Returns a ReamazeAPI::Client instance.

# File lib/reamaze_api.rb, line 44
def self.new(**credentials, &block)
  params = {
    brand: credentials.fetch(:brand) { config.brand },
    login: credentials.fetch(:login) { config.login },
    token: credentials.fetch(:token) { config.token },
  }

  Client.new(**params, &block)
end