Class: OAuth1::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/oauth1/helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, url, params, options) ⇒ Helper

Returns a new instance of Helper.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/oauth1/helper.rb', line 12

def initialize(method, url, params, options)
  options.reverse_update({
    version: "1.0",
    signature_method: 'HMAC-SHA1',
    timestamp: Time.now.to_i.to_s,
    nonce: SecureRandom.uuid
  })

  @consumer_secret = options.delete(:consumer_secret)
  @token_secret = options.delete(:token_secret)
  @url_params = params.merge(prepend_oauth_to_key(options))
  @method = method.to_s.upcase
  @url = Addressable::URI.parse(url)
end

Instance Attribute Details

#url_paramsObject (readonly)

Returns the value of attribute url_params.



10
11
12
# File 'lib/oauth1/helper.rb', line 10

def url_params
  @url_params
end

Instance Method Details

#full_urlObject



33
34
35
36
# File 'lib/oauth1/helper.rb', line 33

def full_url
  append_signature_to_params
  url_with_params.to_s
end

#signature_baseObject



27
28
29
30
# File 'lib/oauth1/helper.rb', line 27

def signature_base
  @url_params.delete(:oauth_signature)
  [@method, @url.to_s, url_with_params.query].map{|v| CGI.escape(v) }.join('&')
end