Class: GoogleApps::AppsRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/google_apps/apps_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verb, uri, headers) ⇒ AppsRequest

Returns a new instance of AppsRequest.



7
8
9
10
11
12
13
# File 'lib/google_apps/apps_request.rb', line 7

def initialize(verb, uri, headers)
  @uri = URI uri
  @ssl = (@uri.scheme == 'https')
  @http_request = initialize_http(verb)

  set_headers(headers)
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



5
6
7
# File 'lib/google_apps/apps_request.rb', line 5

def uri
  @uri
end

Instance Method Details

#add_body(content) ⇒ Object

add_body sets the body the provided content.

add_body ‘bob’

add_body returns the content added.



34
35
36
# File 'lib/google_apps/apps_request.rb', line 34

def add_body(content)
  @http_request.body = content
end

#send_requestObject

send_request does the actual work of sending @http_request as it is currently constructed.

send_request

send_request returns a Net::HTTPResponse object.



22
23
24
25
26
# File 'lib/google_apps/apps_request.rb', line 22

def send_request
  Net::HTTP.start(@uri.host, @uri.port, use_ssl: @ssl) do |http|
    http.request(@http_request)
  end
end