Class: Instapaper::HTTP::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/instapaper/http/request.rb

Constant Summary collapse

BASE_URL =
'https://www.instapaper.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, request_method, path, options = {}) ⇒ Instapaper::HTTP::Request

Parameters:

  • client (Instapaper::Client)
  • request_method (String, Symbol)
  • path (String)
  • options (Hash) (defaults to: {})


17
18
19
20
21
22
23
# File 'lib/instapaper/http/request.rb', line 17

def initialize(client, request_method, path, options = {})
  @client = client
  @request_method = request_method
  @uri = Addressable::URI.parse(path.start_with?('http') ? path : BASE_URL + path)
  @path = uri.path
  @options = options
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



10
11
12
# File 'lib/instapaper/http/request.rb', line 10

def client
  @client
end

#headersObject

Returns the value of attribute headers.



10
11
12
# File 'lib/instapaper/http/request.rb', line 10

def headers
  @headers
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/instapaper/http/request.rb', line 10

def options
  @options
end

#pathObject

Returns the value of attribute path.



10
11
12
# File 'lib/instapaper/http/request.rb', line 10

def path
  @path
end

#request_methodObject

Returns the value of attribute request_method.



10
11
12
# File 'lib/instapaper/http/request.rb', line 10

def request_method
  @request_method
end

#uriObject

Returns the value of attribute uri.



10
11
12
# File 'lib/instapaper/http/request.rb', line 10

def uri
  @uri
end

Instance Method Details

#performArray, Hash

Returns:

  • (Array, Hash)


26
27
28
29
30
# File 'lib/instapaper/http/request.rb', line 26

def perform
  raw = @options.delete(:raw)
  response = Instapaper::HTTP::Response.new(perform_request, path, raw)
  response.valid? && response.body
end