Class: WaCloudApi::Message::Response
- Inherits:
-
Object
- Object
- WaCloudApi::Message::Response
- Defined in:
- lib/wa_cloud_api/message/response.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #contacts ⇒ Object
-
#initialize(status, response) ⇒ Response
constructor
A new instance of Response.
- #messages ⇒ Object
- #ok? ⇒ Boolean
Constructor Details
#initialize(status, response) ⇒ Response
Returns a new instance of Response.
13 14 15 16 |
# File 'lib/wa_cloud_api/message/response.rb', line 13 def initialize(status, response) @status = status.to_i @data = convert_keys_to_symbols(JSON.parse(response)) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
11 12 13 |
# File 'lib/wa_cloud_api/message/response.rb', line 11 def data @data end |
#status ⇒ Object
Returns the value of attribute status.
11 12 13 |
# File 'lib/wa_cloud_api/message/response.rb', line 11 def status @status end |
Instance Method Details
#contacts ⇒ Object
22 23 24 |
# File 'lib/wa_cloud_api/message/response.rb', line 22 def contacts data[:contacts]&.map(&Contact.method(:new)) || [] end |
#messages ⇒ Object
26 27 28 |
# File 'lib/wa_cloud_api/message/response.rb', line 26 def data[:messages]&.map(&Message.method(:new)) || [] end |
#ok? ⇒ Boolean
18 19 20 |
# File 'lib/wa_cloud_api/message/response.rb', line 18 def ok? status == 200 end |