Class: Twitter::Headers
- Inherits:
-
Object
- Object
- Twitter::Headers
- Defined in:
- lib/twitter/headers.rb
Instance Method Summary collapse
- #bearer_token_request? ⇒ Boolean
-
#initialize(client, request_method, url, options = {}) ⇒ Headers
constructor
A new instance of Headers.
- #oauth_auth_header ⇒ Object
- #request_headers ⇒ Object
Constructor Details
#initialize(client, request_method, url, options = {}) ⇒ Headers
Returns a new instance of Headers.
7 8 9 10 11 12 13 |
# File 'lib/twitter/headers.rb', line 7 def initialize(client, request_method, url, = {}) @client = client @request_method = request_method.to_sym @uri = Addressable::URI.parse(url) @bearer_token_request = .delete(:bearer_token_request) @options = end |
Instance Method Details
#bearer_token_request? ⇒ Boolean
15 16 17 |
# File 'lib/twitter/headers.rb', line 15 def bearer_token_request? !!@bearer_token_request end |
#oauth_auth_header ⇒ Object
19 20 21 |
# File 'lib/twitter/headers.rb', line 19 def oauth_auth_header SimpleOAuth::Header.new(@request_method, @uri, @options, @client.credentials.merge(ignore_extra_keys: true)) end |
#request_headers ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/twitter/headers.rb', line 23 def request_headers headers = {} headers[:user_agent] = @client.user_agent if bearer_token_request? headers[:accept] = "*/*" headers[:authorization] = bearer_token_credentials_auth_header else headers[:authorization] = auth_header end headers end |