Class: TwitterRequestHeaders
- Inherits:
-
Object
- Object
- TwitterRequestHeaders
- Defined in:
- lib/twitter_request_headers.rb
Constant Summary collapse
- OAUTH_VERSION =
'1.0'- OAUTH_CIPHER =
'HMAC-SHA1'- TWITTER_API =
'https://api.twitter.com/1.1'
Class Attribute Summary collapse
-
.consumer_key ⇒ Object
readonly
Returns the value of attribute consumer_key.
-
.consumer_secret ⇒ Object
readonly
Returns the value of attribute consumer_secret.
-
.oauth_cipher ⇒ Object
readonly
Returns the value of attribute oauth_cipher.
-
.oauth_version ⇒ Object
readonly
Returns the value of attribute oauth_version.
-
.twitter_api ⇒ Object
readonly
Returns the value of attribute twitter_api.
Class Method Summary collapse
Instance Method Summary collapse
- #header ⇒ Object
-
#initialize(oauth_token, oauth_secret, request_verb, request_path, request_params = nil) ⇒ TwitterRequestHeaders
constructor
A new instance of TwitterRequestHeaders.
Constructor Details
#initialize(oauth_token, oauth_secret, request_verb, request_path, request_params = nil) ⇒ TwitterRequestHeaders
Returns a new instance of TwitterRequestHeaders.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/twitter_request_headers.rb', line 25 def initialize(oauth_token, oauth_secret, request_verb, request_path, request_params = nil) unless @@configured fail StandardError, "Call #{self.class}.configure first!" end @oauth_token = oauth_token @oauth_secret = oauth_secret @request_verb = request_verb @request_path = request_path @request_params = request_params || {} @nonce = nonce @epochtime = epochtime end |
Class Attribute Details
.consumer_key ⇒ Object (readonly)
Returns the value of attribute consumer_key.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def consumer_key @consumer_key end |
.consumer_secret ⇒ Object (readonly)
Returns the value of attribute consumer_secret.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def consumer_secret @consumer_secret end |
.oauth_cipher ⇒ Object (readonly)
Returns the value of attribute oauth_cipher.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def oauth_cipher @oauth_cipher end |
.oauth_version ⇒ Object (readonly)
Returns the value of attribute oauth_version.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def oauth_version @oauth_version end |
.twitter_api ⇒ Object (readonly)
Returns the value of attribute twitter_api.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def twitter_api @twitter_api end |
Class Method Details
.configure(consumer_key, consumer_secret, oauth_version = nil, oauth_cipher = nil, twitter_api = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/twitter_request_headers.rb', line 12 def configure(consumer_key, consumer_secret, oauth_version = nil, oauth_cipher = nil, twitter_api = nil) @consumer_key = consumer_key @consumer_secret = consumer_secret @oauth_version = oauth_version || OAUTH_VERSION @oauth_cipher = oauth_cipher || OAUTH_CIPHER @twitter_api = twitter_api || TWITTER_API @@configured = true end |
Instance Method Details
#header ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/twitter_request_headers.rb', line 41 def header signature = Signature.new( @oauth_token, @oauth_secret, @request_verb, @request_path, @request_params, @nonce, @epochtime ).digest { Header.key => Header.new(@oauth_token, signature, @nonce, @epochtime).value } end |