Class: Zonomi::API::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/zonomi/api/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Client


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

def initialize(*args)
  # options = args.extract_options!
  options = args.last.is_a?(::Hash) ? args.pop : {}
  @api_key = ! args[0].nil? ? args[0] : options.delete(:api_key) || ''
  @api = Adapter.new(self)
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api


18
19
20
# File 'lib/zonomi/api/client.rb', line 18

def api
  @api
end

#api_keyObject

Returns the value of attribute api_key


17
18
19
# File 'lib/zonomi/api/client.rb', line 17

def api_key
  @api_key
end

Class Method Details

.server_base_uriObject


7
8
9
10
11
12
# File 'lib/zonomi/api/client.rb', line 7

def self.server_base_uri
  [
    SERVER[:domain],
    SERVER[:prefix]
  ].join
end

Instance Method Details

#api_request(params) ⇒ Object


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

def api_request(params)
  Request.new(params.merge(client: self))
end

#valid?Boolean


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

def valid?
  validate!
end