Class: FriendlyShipping::Request

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, http_method: nil, body: nil, readable_body: nil, headers: {}, debug: false) ⇒ Request

Returns a new instance of Request.

Parameters:

  • url (String)

    The HTTP request URL

  • http_method (String) (defaults to: nil)

    The HTTP request method

  • body (String) (defaults to: nil)

    The HTTP request body

  • readable_body (String) (defaults to: nil)

    Human-readable HTTP request body

  • headers (Hash) (defaults to: {})

    The HTTP request headers

  • debug (Boolean) (defaults to: false)

    Whether to debug the request



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

def initialize(url:, http_method: nil, body: nil, readable_body: nil, headers: {}, debug: false)
  @url = url
  @http_method = http_method
  @body = body
  @readable_body = readable_body
  @headers = headers
  @debug = debug
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#debugObject (readonly)

Returns the value of attribute debug.



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

def debug
  @debug
end

#headersObject (readonly)

Returns the value of attribute headers.



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

def headers
  @headers
end

#http_methodObject (readonly)

Returns the value of attribute http_method.



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

def http_method
  @http_method
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#readable_bodyObject



22
23
24
# File 'lib/friendly_shipping/request.rb', line 22

def readable_body
  @readable_body.presence || @body
end