Class: Gaah::ApiClient
- Inherits:
-
Object
- Object
- Gaah::ApiClient
- Defined in:
- lib/gaah/api_client.rb
Class Attribute Summary collapse
-
.consumer_key ⇒ Object
Returns the value of attribute consumer_key.
-
.consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
-
.instance ⇒ Object
Returns the value of attribute instance.
Class Method Summary collapse
Instance Method Summary collapse
- #get(base, query_params = {}) ⇒ Object
-
#initialize ⇒ ApiClient
constructor
A new instance of ApiClient.
- #post(base, query_params = {}, body = {}) ⇒ Object
Constructor Details
#initialize ⇒ ApiClient
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_key ⇒ Object
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_secret ⇒ Object
Returns the value of attribute consumer_secret.
4 5 6 |
# File 'lib/gaah/api_client.rb', line 4 def consumer_secret @consumer_secret end |
.instance ⇒ Object
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
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
#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
31 32 33 |
# File 'lib/gaah/api_client.rb', line 31 def post(base, query_params = {}, body = {}) make_request(:post, base, query_params, body) end |