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.



16
17
18
19
20
21
# File 'lib/drip/request.rb', line 16

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.



7
8
9
# File 'lib/drip/request.rb', line 7

def content_type
  @content_type
end

#http_verbObject (readonly)

Returns the value of attribute http_verb.



7
8
9
# File 'lib/drip/request.rb', line 7

def http_verb
  @http_verb
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/drip/request.rb', line 7

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/drip/request.rb', line 7

def url
  @url
end

Instance Method Details

#bodyObject



27
28
29
30
31
# File 'lib/drip/request.rb', line 27

def body
  return if http_verb == :get

  options.to_json
end

#verb_klassObject



23
24
25
# File 'lib/drip/request.rb', line 23

def verb_klass
  VERB_CLASS_MAPPING[http_verb]
end