Class: Listmonk::Response
- Inherits:
-
Object
- Object
- Listmonk::Response
- Defined in:
- lib/listmonk/response.rb,
sig/listmonk.rbs
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Hash[String, String]
readonly
Returns the value of attribute headers.
-
#status ⇒ Integer
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(status:, headers:, body:) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(status:, headers:, body:) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 |
# File 'lib/listmonk/response.rb', line 7 def initialize(status:, headers:, body:) @status = status @headers = headers.freeze @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/listmonk/response.rb', line 5 def body @body end |
#headers ⇒ Hash[String, String] (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/listmonk/response.rb', line 5 def headers @headers end |
#status ⇒ Integer (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/listmonk/response.rb', line 5 def status @status end |
Instance Method Details
#data ⇒ Object
17 18 19 20 21 |
# File 'lib/listmonk/response.rb', line 17 def data return body unless body.is_a?(Hash) body.key?("data") ? body["data"] : body end |
#success? ⇒ Boolean
13 14 15 |
# File 'lib/listmonk/response.rb', line 13 def success? status.between?(200, 299) end |