Class: GData4Ruby::Request

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

Overview

The Request class holds all information needed to make a Request to a Google service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, url, content = nil, headers = nil, query_parameters = nil) ⇒ Request

Creates a new request object.



36
37
38
39
40
41
42
43
# File 'lib/gdata4ruby/request.rb', line 36

def initialize(type, url, content = nil, headers = nil, query_parameters = nil)
  @parameters = nil
  @headers = headers
  @content = content
  @type = type
  @url = URI.parse(url)
  self.parameters = query_parameters
end

Instance Attribute Details

#contentObject

The HTTP request content, only valid for :put and :post requests



27
28
29
# File 'lib/gdata4ruby/request.rb', line 27

def content
  @content
end

#headersObject

Optional. Additional headers to pass with the request.



30
31
32
# File 'lib/gdata4ruby/request.rb', line 30

def headers
  @headers
end

#parametersObject

Optional. Additional query parameters (i.e. “?param=value”) to append to the request url



33
34
35
# File 'lib/gdata4ruby/request.rb', line 33

def parameters
  @parameters
end

#typeObject

The HTTP request type, must be one of :get, :post, :put, :delete



24
25
26
# File 'lib/gdata4ruby/request.rb', line 24

def type
  @type
end

Instance Method Details

#urlObject

The HTTP url to send the request to



57
58
59
# File 'lib/gdata4ruby/request.rb', line 57

def url
  return URI.parse("#{@url+(@parameters ? @parameters : '')}")
end

#url=(new_url) ⇒ Object

The HTTP url to send the request to



46
47
48
# File 'lib/gdata4ruby/request.rb', line 46

def url=(new_url)
  @url = new_url
end