Class: Untappd::API

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/untappd-api/api.rb

Direct Known Subclasses

Client

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ API

Create a new API



21
22
23
24
25
26
27
28
29
30
# File 'lib/untappd-api/api.rb', line 21

def initialize(options={})
  @klass = self.class
  options = Untappd.options.merge(options)
  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key]) 
  end

  # Set HTTParty class configurations
  @klass.format(:json)
end

Instance Method Details

#application_key=(val) ⇒ Object



15
16
17
18
# File 'lib/untappd-api/api.rb', line 15

def application_key=(val)
  @application_key = val
  @klass.default_params(:key => application_key)
end

#endpoint=(val) ⇒ Object

Override these setters so that HTTParty class methods get updated as well



10
11
12
13
# File 'lib/untappd-api/api.rb', line 10

def endpoint=(val)
  @endpoint = val
  @klass.base_uri(endpoint)
end