Class: Cryptopay::Request
- Inherits:
-
Object
- Object
- Cryptopay::Request
- Defined in:
- lib/cryptopay/request.rb
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'Accept' => 'application/json', 'User-Agent' => "Cryptopay Ruby v#{VERSION}" }.freeze
- CONTENT_TYPE =
'application/json'
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#headers ⇒ Object
readonly
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
- #add_header(key, value) ⇒ Object
-
#initialize(method:, path:, query_params: {}, body_params: {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(method:, path:, query_params: {}, body_params: {}) ⇒ Request
Returns a new instance of Request.
14 15 16 17 18 19 20 21 |
# File 'lib/cryptopay/request.rb', line 14 def initialize(method:, path:, query_params: {}, body_params: {}) @method = method @path = prepare_query(path, query_params) @body = prepare_body(body_params.to_hash) @date = Time.now.httpdate @content_type = CONTENT_TYPE @headers = DEFAULT_HEADERS.merge(Date: date, 'Content-Type': @content_type) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/cryptopay/request.rb', line 5 def body @body end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
5 6 7 |
# File 'lib/cryptopay/request.rb', line 5 def content_type @content_type end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
5 6 7 |
# File 'lib/cryptopay/request.rb', line 5 def date @date end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/cryptopay/request.rb', line 5 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
5 6 7 |
# File 'lib/cryptopay/request.rb', line 5 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/cryptopay/request.rb', line 5 def path @path end |
Instance Method Details
#add_header(key, value) ⇒ Object
23 24 25 |
# File 'lib/cryptopay/request.rb', line 23 def add_header(key, value) @headers = headers.merge(key => value) end |