Class: Wowzer::Client

Inherits:
Object
  • Object
show all
Includes:
Hyperclient
Defined in:
lib/wowzer/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/wowzer/client.rb', line 19

def method_missing(method, *args, &block)
  if api.respond_to?(method)
    api.send(method, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



6
7
8
# File 'lib/wowzer/client.rb', line 6

def api
  @api
end

Instance Method Details

#api_endpoint(api_endpoint) ⇒ Object



35
36
37
# File 'lib/wowzer/client.rb', line 35

def api_endpoint(api_endpoint)
  @api_endpoint = api_endpoint
end

#api_key(api_key) ⇒ Object



31
32
33
# File 'lib/wowzer/client.rb', line 31

def api_key(api_key)
  @api_key = api_key
end

#app_id(app_id) ⇒ Object



27
28
29
# File 'lib/wowzer/client.rb', line 27

def app_id(app_id)
  @app_id = app_id
end

#connectObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/wowzer/client.rb', line 8

def connect
  api_endpoint = @api_endpoint
  app_id = @app_id
  api_key = @api_key

  self.api ||= Hyperclient.new(api_endpoint).tap do |api|
    api.basic_auth(app_id, api_key)
    api.headers.merge({'accept' => 'application/hal+json', 'content-type' => 'application/json'})
  end
end