Class: GData4Ruby::Request
- Inherits:
-
Object
- Object
- GData4Ruby::Request
- 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
-
#content ⇒ Object
The HTTP request content, only valid for :put and :post requests.
-
#headers ⇒ Object
Optional.
-
#parameters ⇒ Object
Optional.
-
#type ⇒ Object
The HTTP request type, must be one of :get, :post, :put, :delete.
Instance Method Summary collapse
-
#initialize(type, url, content = '', headers = {}, query_parameters = {}) ⇒ Request
constructor
Creates a new request object.
-
#url ⇒ Object
The HTTP url to send the request to.
-
#url=(new_url) ⇒ Object
The HTTP url to send the request to.
Constructor Details
#initialize(type, url, content = '', headers = {}, query_parameters = {}) ⇒ 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 = '', headers = {}, query_parameters = {}) @parameters = nil @headers = headers @content = content @type = type @url = URI.parse(url) self.parameters = query_parameters end |
Instance Attribute Details
#content ⇒ Object
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 |
#headers ⇒ Object
Optional. Additional headers to pass with the request.
30 31 32 |
# File 'lib/gdata4ruby/request.rb', line 30 def headers @headers end |
#parameters ⇒ Object
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 |
#type ⇒ Object
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
#url ⇒ Object
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 |