Class: FriendlyShipping::Request
- Inherits:
-
Object
- Object
- FriendlyShipping::Request
- Defined in:
- lib/friendly_shipping/request.rb
Overview
Represents an HTTP request sent to a carrier API.
Instance Attribute Summary collapse
-
#body ⇒ String
readonly
The HTTP request body.
-
#debug ⇒ Boolean
readonly
Whether to attach debugging information to the response.
-
#headers ⇒ String
readonly
Human-readable HTTP request body.
-
#http_method ⇒ String
readonly
The HTTP request method.
-
#url ⇒ String
readonly
The HTTP request URL.
Instance Method Summary collapse
-
#initialize(url:, http_method: nil, body: nil, readable_body: nil, headers: {}, debug: false) ⇒ Request
constructor
A new instance of Request.
-
#readable_body ⇒ String
Returns the HTTP request body.
Constructor Details
#initialize(url:, http_method: nil, body: nil, readable_body: nil, headers: {}, debug: false) ⇒ Request
Returns a new instance of Request.
27 28 29 30 31 32 33 34 |
# File 'lib/friendly_shipping/request.rb', line 27 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
#body ⇒ String (readonly)
Returns the HTTP request body.
13 14 15 |
# File 'lib/friendly_shipping/request.rb', line 13 def body @body end |
#debug ⇒ Boolean (readonly)
Returns whether to attach debugging information to the response.
19 20 21 |
# File 'lib/friendly_shipping/request.rb', line 19 def debug @debug end |
#headers ⇒ String (readonly)
Returns human-readable HTTP request body.
16 17 18 |
# File 'lib/friendly_shipping/request.rb', line 16 def headers @headers end |
#http_method ⇒ String (readonly)
Returns the HTTP request method.
10 11 12 |
# File 'lib/friendly_shipping/request.rb', line 10 def http_method @http_method end |
#url ⇒ String (readonly)
Returns the HTTP request URL.
7 8 9 |
# File 'lib/friendly_shipping/request.rb', line 7 def url @url end |
Instance Method Details
#readable_body ⇒ String
Returns the HTTP request body.
38 39 40 |
# File 'lib/friendly_shipping/request.rb', line 38 def readable_body @readable_body.presence || @body end |