Class: TumblrWrapper::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token


2
3
4
# File 'lib/tumblr_wrapper/client.rb', line 2

def access_token
  @access_token
end

#request_tokenObject (readonly)

Returns the value of attribute request_token


2
3
4
# File 'lib/tumblr_wrapper/client.rb', line 2

def request_token
  @request_token
end

Instance Method Details

#authorize_urlObject


4
5
6
7
# File 'lib/tumblr_wrapper/client.rb', line 4

def authorize_url
  @request_token = consumer.get_request_token({:exclude_callback => true})
  @request_token.authorize_url
end

#build_access_token(token, secret) ⇒ Object


23
24
25
26
27
28
29
# File 'lib/tumblr_wrapper/client.rb', line 23

def build_access_token(token, secret)
  @access_token = {
    consumer_key: TumblrWrapper.consumer_key,
    consumer_secret: TumblrWrapper.consumer_secret,
    token: token,
    token_secret: secret }
end

#build_request_token(token, secret) ⇒ Object


19
20
21
# File 'lib/tumblr_wrapper/client.rb', line 19

def build_request_token(token, secret)
  @request_token = OAuth::RequestToken.new(consumer, token, secret)
end

#consumerObject


31
32
33
34
35
36
37
# File 'lib/tumblr_wrapper/client.rb', line 31

def consumer
  @consumer ||= OAuth::Consumer.new(
    TumblrWrapper.consumer_key,
    TumblrWrapper.consumer_secret,
    site: 'http://www.tumblr.com'
  )
end

#request_access_token(oauth_verifier) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/tumblr_wrapper/client.rb', line 9

def request_access_token(oauth_verifier)
  token = request_token.get_access_token({:oauth_verifier => oauth_verifier})
  @access_token = {
    consumer_key: TumblrWrapper.consumer_key,
    consumer_secret: TumblrWrapper.consumer_secret,
    token: token.token,
    token_secret: token.secret
  }
end