Class: HyvesOAuth::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/hyves_oauth/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



3
4
5
6
7
8
9
# File 'lib/hyves_oauth/client.rb', line 3

def initialize(options = {})
  @consumer_key = options[:consumer_key]
  @consumer_secret = options[:consumer_secret]
  @token = options[:token]
  @secret = options[:secret]

end

Instance Method Details

#authorize(token, secret, options = {}) ⇒ Object



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

def authorize(token, secret, options = {})
  request_token = OAuth::RequestToken.new(consumer, token, secret)
  @access_token = request_token.get_access_token(options, {"strict_oauth_spec_response" => "true", "ha_method" => "auth.accesstoken"})
  @token = @access_token.token
  @secret = @access_token.secret
  @access_token
end

#authorize_urlObject



15
16
17
# File 'lib/hyves_oauth/client.rb', line 15

def authorize_url
  @request_token.authorize_url.gsub("http://data.hyves-api.nl/oauth/", "http://www.hyves.nl/api/")
end

#get_logged_inObject



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

def get_logged_in
  post "/", {"ha_method" => "users.getLoggedin"}
end

#request_token(options = {}) ⇒ Object



11
12
13
# File 'lib/hyves_oauth/client.rb', line 11

def request_token(options = {})
  @request_token = consumer.get_request_token(options, {"strict_oauth_spec_response" => "true", "ha_method" => "auth.requesttoken", "methods" => "wwws.create,users.getLoggedin"})
end

#update(message, options = {}) ⇒ Object



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

def update(message, options = {})
  post("/", {"ha_method" => "wwws.create", "emotion" => message, "visibility" => "default"}.merge(options))
end