Class: Shmac::Request
- Inherits:
-
Object
- Object
- Shmac::Request
- Defined in:
- lib/shmac/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #api_version ⇒ Object
- #authorization ⇒ Object
- #content_md5 ⇒ Object
-
#date(namespace = nil) ⇒ Object
Prefer the value of a namespaced date key if present.
-
#initialize(path:, method:, headers:, body: nil, content_type: nil) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(path:, method:, headers:, body: nil, content_type: nil) ⇒ Request
7 8 9 10 11 12 13 |
# File 'lib/shmac/request.rb', line 7 def initialize path:, method:, headers:, body: nil, content_type: nil @path = path @method = method self.headers = headers @body = body @content_type = content_type end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/shmac/request.rb', line 5 def body @body end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
5 6 7 |
# File 'lib/shmac/request.rb', line 5 def content_type @content_type end |
#headers ⇒ Object
Returns the value of attribute headers.
5 6 7 |
# File 'lib/shmac/request.rb', line 5 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
5 6 7 |
# File 'lib/shmac/request.rb', line 5 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/shmac/request.rb', line 5 def path @path end |
Instance Method Details
#api_version ⇒ Object
36 37 38 |
# File 'lib/shmac/request.rb', line 36 def api_version headers.fetch("x-authorization-version", 0).to_i end |
#authorization ⇒ Object
27 28 29 30 |
# File 'lib/shmac/request.rb', line 27 def # Test for x-authorization for clients that have issues with standard headers headers.fetch("x-authorization") { headers["authorization"] } end |
#content_md5 ⇒ Object
22 23 24 25 |
# File 'lib/shmac/request.rb', line 22 def content_md5 # Fallback to x-content-md5 for clients that have issues with standard headers headers.fetch("content-md5") { headers["x-content-md5"] } end |
#date(namespace = nil) ⇒ Object
Prefer the value of a namespaced date key if present
16 17 18 19 20 |
# File 'lib/shmac/request.rb', line 16 def date namespace = nil date_key = [namespace, "date"].compact.join("-").downcase headers.fetch(date_key) { headers["date"] } end |