Class: HttpConnect::HttpRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/http_connect/http_request.rb

Overview

HttpRequest class

Direct Known Subclasses

HttpDelete, HttpGet, HttpPost, HttpPut

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, method, content_type = 'application/json', accept = 'application/json', content = {}) ⇒ HttpRequest

initialize()



11
12
13
14
15
16
17
18
19
20
# File 'lib/http_connect/http_request.rb', line 11

def initialize(path, method, content_type = 'application/json',
               accept = 'application/json', content = {})
  @path = path
  @http_method = method
  @accept = accept
  @content = content
  @content_type = content_type

  @path << "? #{URI.encode_www_form(@content)}" if %w[GET DELETE].include? @http_method
end

Instance Attribute Details

#acceptObject (readonly)

accept header for the response



6
7
8
# File 'lib/http_connect/http_request.rb', line 6

def accept
  @accept
end

#contentObject (readonly)

payload



7
8
9
# File 'lib/http_connect/http_request.rb', line 7

def content
  @content
end

#content_typeObject (readonly)

content type



8
9
10
# File 'lib/http_connect/http_request.rb', line 8

def content_type
  @content_type
end

#http_methodObject (readonly)

http verb



5
6
7
# File 'lib/http_connect/http_request.rb', line 5

def http_method
  @http_method
end

#pathObject (readonly)

resource path



4
5
6
# File 'lib/http_connect/http_request.rb', line 4

def path
  @path
end