Class: OAuthClient::Adapters::Json
- Inherits:
-
Object
- Object
- OAuthClient::Adapters::Json
- Defined in:
- lib/oauth_client/adapters/json.rb
Overview
Json Adapter for OAuthClient
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#get(url) ⇒ Object
make a GET request and parse JSON response.
-
#initialize(client) ⇒ Json
constructor
on creation, the adapter must be supplied with the client.
-
#post(url, params = {}) ⇒ Object
make a GET request and parse JSON response.
Constructor Details
#initialize(client) ⇒ Json
on creation, the adapter must be supplied with the client
9 10 11 |
# File 'lib/oauth_client/adapters/json.rb', line 9 def initialize(client) self.client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/oauth_client/adapters/json.rb', line 6 def client @client end |
Instance Method Details
#get(url) ⇒ Object
make a GET request and parse JSON response
14 15 16 17 |
# File 'lib/oauth_client/adapters/json.rb', line 14 def get(url) oauth_response = self.client.get(url) JSON.parse(oauth_response.body) end |
#post(url, params = {}) ⇒ Object
make a GET request and parse JSON response
20 21 22 23 |
# File 'lib/oauth_client/adapters/json.rb', line 20 def post(url, params = {}) oauth_response = self.client.post(url, params) JSON.parse(oauth_response.body) end |