Class: OpenMarket::SMS::Responses::SendMessage
- Inherits:
-
Object
- Object
- OpenMarket::SMS::Responses::SendMessage
- Defined in:
- lib/open_market/sms/responses/send_message.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #error_code ⇒ Object
- #error_message ⇒ Object
- #from ⇒ Object
-
#initialize(request, service_response) ⇒ SendMessage
constructor
A new instance of SendMessage.
- #location ⇒ Object
- #request_id ⇒ Object
- #success? ⇒ Boolean
- #to ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(request, service_response) ⇒ SendMessage
Returns a new instance of SendMessage.
8 9 10 11 12 13 |
# File 'lib/open_market/sms/responses/send_message.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/send_message.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/send_message.rb', line 6 def headers @headers end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
6 7 8 |
# File 'lib/open_market/sms/responses/send_message.rb', line 6 def @message_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/open_market/sms/responses/send_message.rb', line 6 def status @status end |
Instance Method Details
#error_code ⇒ Object
39 40 41 |
# File 'lib/open_market/sms/responses/send_message.rb', line 39 def error_code body.dig('error', 'code')&.to_i end |
#error_message ⇒ Object
35 36 37 |
# File 'lib/open_market/sms/responses/send_message.rb', line 35 def body.dig('error', 'description') end |
#from ⇒ Object
19 20 21 |
# File 'lib/open_market/sms/responses/send_message.rb', line 19 def from @request.from end |
#location ⇒ Object
27 28 29 |
# File 'lib/open_market/sms/responses/send_message.rb', line 27 def location @response.headers['location'] end |
#request_id ⇒ Object
31 32 33 |
# File 'lib/open_market/sms/responses/send_message.rb', line 31 def request_id @response.headers['x-request-id'] end |
#success? ⇒ Boolean
15 16 17 |
# File 'lib/open_market/sms/responses/send_message.rb', line 15 def success? status == 202 end |
#to ⇒ Object
23 24 25 |
# File 'lib/open_market/sms/responses/send_message.rb', line 23 def to @request.to end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/open_market/sms/responses/send_message.rb', line 43 def to_s "Response: #{status}, #{error}" end |