Module: ReamazeAPI

Defined in:
lib/reamaze_api.rb,
lib/reamaze_api/error.rb,
lib/reamaze_api/utils.rb,
lib/reamaze_api/client.rb,
lib/reamaze_api/article.rb,
lib/reamaze_api/channel.rb,
lib/reamaze_api/contact.rb,
lib/reamaze_api/message.rb,
lib/reamaze_api/version.rb,
lib/reamaze_api/resource.rb,
lib/reamaze_api/conversation.rb,
lib/reamaze_api/utils/hash_keys.rb

Defined Under Namespace

Modules: Utils Classes: Article, Channel, Client, ClientError, Config, Contact, Conversation, Error, Forbidden, Message, NotFound, Resource, ServerError, TooManyRequests, UnprocessableEntity

Constant Summary collapse

VERSION =
"0.8.0"

Class Method Summary collapse

Class Method Details

.config {|@config| ... } ⇒ Object

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

Yields the Config instance if a block is given.

Returns a Config instance.

Yields:



22
23
24
25
26
# File 'lib/reamaze_api.rb', line 22

def self.config
  @config ||= Config.new
  yield @config if block_given?
  @config
end

.new(**credentials, &block) ⇒ Object

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.



44
45
46
47
48
49
50
51
52
# File 'lib/reamaze_api.rb', line 44

def self.new(**credentials, &block)
  params = {
    brand: credentials.fetch(:brand) { config.brand },
    login: credentials.fetch(:login) { config. },
    token: credentials.fetch(:token) { config.token },
  }

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