Class: Drip::Request

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

Constant Summary collapse

VERB_CLASS_MAPPING =
{
  get: Net::HTTP::Get,
  post: Net::HTTP::Post,
  put: Net::HTTP::Put,
  delete: Net::HTTP::Delete
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_verb, url, options = {}, content_type = nil) ⇒ Request

Returns a new instance of Request.



14
15
16
17
18
19
# File 'lib/drip/request.rb', line 14

def initialize(http_verb, url, options = {}, content_type = nil)
  @http_verb = http_verb
  @url = url
  @options = options
  @content_type = content_type
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



5
6
7
# File 'lib/drip/request.rb', line 5

def content_type
  @content_type
end

#http_verbObject (readonly)

Returns the value of attribute http_verb.



5
6
7
# File 'lib/drip/request.rb', line 5

def http_verb
  @http_verb
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/drip/request.rb', line 5

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/drip/request.rb', line 5

def url
  @url
end

Instance Method Details

#bodyObject



25
26
27
28
29
# File 'lib/drip/request.rb', line 25

def body
  return if http_verb == :get

  options.to_json
end

#verb_klassObject



21
22
23
# File 'lib/drip/request.rb', line 21

def verb_klass
  VERB_CLASS_MAPPING[http_verb]
end