Class: Twttr::Client::OAuthRequest

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

Overview

 OAuth helper methods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, config) ⇒ OAuthRequest

Returns a new instance of OAuthRequest.



9
10
11
12
13
14
15
# File 'lib/twttr/client/oauth_request.rb', line 9

def initialize(uri, config)
  @uri = uri
  @config = config
  @request = Net::HTTP::Get.new(uri)
  @request['Authorization'] = authorization_header
  @response = nil
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



7
8
9
# File 'lib/twttr/client/oauth_request.rb', line 7

def response
  @response
end

Class Method Details

.get(uri, config) ⇒ Object



17
18
19
# File 'lib/twttr/client/oauth_request.rb', line 17

def self.get(uri, config)
  new(uri, config).perform
end

Instance Method Details

#performObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/twttr/client/oauth_request.rb', line 21

def perform
  Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
    # :nocov:
    self.response = http.request request
    # :nocov:
  end

  raise Error::HTTPError, response.message unless response.instance_of?(Net::HTTPOK)

  response
end