Class: Gaah::ApiClient

Inherits:
Object
  • Object
show all
Defined in:
lib/gaah/api_client.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApiClient

Returns a new instance of ApiClient.



21
22
23
24
25
# File 'lib/gaah/api_client.rb', line 21

def initialize
  raise 'consumer_key and consumer_secret not set' if ApiClient.not_setup?
  oauth_consumer = OAuth::Consumer.new(@@consumer_key, @@consumer_secret)
  @token = OAuth::AccessToken.new(oauth_consumer)
end

Class Attribute Details

.consumer_keyObject

Returns the value of attribute consumer_key.



4
5
6
# File 'lib/gaah/api_client.rb', line 4

def consumer_key
  @consumer_key
end

.consumer_secretObject

Returns the value of attribute consumer_secret.



4
5
6
# File 'lib/gaah/api_client.rb', line 4

def consumer_secret
  @consumer_secret
end

.instanceObject

Returns the value of attribute instance.



4
5
6
# File 'lib/gaah/api_client.rb', line 4

def instance
  @instance
end

Class Method Details

.not_setup?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/gaah/api_client.rb', line 12

def not_setup?
  @@consumer_key.nil? || @@consumer_secret.nil?
end

.setup_oauth(key, secret) ⇒ Object



6
7
8
9
10
# File 'lib/gaah/api_client.rb', line 6

def setup_oauth(key, secret)
  @@consumer_key = key
  @@consumer_secret = secret
  true
end

Instance Method Details

#delete(base, query_params = {}) ⇒ Object



31
32
33
# File 'lib/gaah/api_client.rb', line 31

def delete(base, query_params = {})
  make_request(:delete, base, query_params)
end

#get(base, query_params = {}) ⇒ Object



27
28
29
# File 'lib/gaah/api_client.rb', line 27

def get(base, query_params = {})
  make_request(:get, base, query_params)
end

#post(base, query_params = {}, body = {}) ⇒ Object



35
36
37
# File 'lib/gaah/api_client.rb', line 35

def post(base, query_params = {}, body = {})
  make_request(:post, base, query_params, body)
end