Class: OpenMarket::SMS::Responses::MessageStatus
- Inherits:
-
Object
- Object
- OpenMarket::SMS::Responses::MessageStatus
- Defined in:
- lib/open_market/sms/responses/message_status.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #delivery_date ⇒ Object
- #destination ⇒ Object
- #error_code ⇒ Object
- #error_message ⇒ Object
-
#initialize(request, service_response) ⇒ MessageStatus
constructor
A new instance of MessageStatus.
- #message_status ⇒ Object
- #message_status_code ⇒ Object
- #success? ⇒ Boolean
- #ticket_id ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(request, service_response) ⇒ MessageStatus
Returns a new instance of MessageStatus.
8 9 10 11 12 13 |
# File 'lib/open_market/sms/responses/message_status.rb', line 8 def initialize(request, service_response) @request = request @response = service_response parse_response end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/open_market/sms/responses/message_status.rb', line 6 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/open_market/sms/responses/message_status.rb', line 6 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/open_market/sms/responses/message_status.rb', line 6 def status @status end |
Instance Method Details
#delivery_date ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/open_market/sms/responses/message_status.rb', line 35 def delivery_date delivery_date = @delivery_status.dig('deliveryDate') return if delivery_date.nil? || delivery_date.empty? DateTime.parse(delivery_date) end |
#destination ⇒ Object
31 32 33 |
# File 'lib/open_market/sms/responses/message_status.rb', line 31 def destination @delivery_status.dig('destination', 'address') end |
#error_code ⇒ Object
51 52 53 |
# File 'lib/open_market/sms/responses/message_status.rb', line 51 def error_code body.dig('error', 'code')&.to_i end |
#error_message ⇒ Object
47 48 49 |
# File 'lib/open_market/sms/responses/message_status.rb', line 47 def body.dig('error', 'description') end |
#message_status ⇒ Object
27 28 29 |
# File 'lib/open_market/sms/responses/message_status.rb', line 27 def @delivery_status.dig('description') end |
#message_status_code ⇒ Object
23 24 25 |
# File 'lib/open_market/sms/responses/message_status.rb', line 23 def @delivery_status.dig('code')&.to_i end |
#success? ⇒ Boolean
15 16 17 |
# File 'lib/open_market/sms/responses/message_status.rb', line 15 def success? status == 200 end |
#ticket_id ⇒ Object
19 20 21 |
# File 'lib/open_market/sms/responses/message_status.rb', line 19 def ticket_id @request.ticket_id end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/open_market/sms/responses/message_status.rb', line 43 def to_s "Response: #{status}, #{error}" end |