Class: Hotchoc::Client

Inherits:
Object
  • Object
show all
Includes:
API
Defined in:
lib/hotchoc/client.rb,
lib/hotchoc/client/api.rb,
lib/hotchoc/client/fetcher.rb,
lib/hotchoc/client/version.rb,
lib/hotchoc/client/configuration.rb

Defined Under Namespace

Modules: API, Configuration Classes: Fetcher, HotchocError, RequestError

Constant Summary collapse

VERSION =
'0.6.0'

Instance Method Summary collapse

Methods included from API

#get_albums, #get_pages, #get_posts, #get_topics

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hotchoc/client.rb', line 17

def initialize(opts = {})
  options = Hotchoc.options.merge(opts) { |_key, oldval, newval| newval.nil? ? oldval : newval }

  fail ArgumentError, 'API key is required' unless options[:api_key]
  fail ArgumentError, 'Site name is required' unless options[:site]

  #
  # Copy the merged values to this client and ignore those
  # not part of the configuration.
  #
  Configuration::VALID_CONFIG_KEYS.each do |key|
    send("#{key}=", options[key])
  end
end