Class: OAuthClient::Adapters::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/oauth_client/adapters/json.rb

Overview

Json Adapter for OAuthClient

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject

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