Class: OpenMarket::SMS::Responses::SendMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/open_market/sms/responses/send_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (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

#headersObject (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_idObject (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
  @message_id
end

#statusObject (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_codeObject



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_messageObject



35
36
37
# File 'lib/open_market/sms/responses/send_message.rb', line 35

def error_message
  body.dig('error', 'description')
end

#fromObject



19
20
21
# File 'lib/open_market/sms/responses/send_message.rb', line 19

def from
  @request.from
end

#locationObject



27
28
29
# File 'lib/open_market/sms/responses/send_message.rb', line 27

def location
  @response.headers['location']
end

#request_idObject



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

Returns:

  • (Boolean)


15
16
17
# File 'lib/open_market/sms/responses/send_message.rb', line 15

def success?
  status == 202
end

#toObject



23
24
25
# File 'lib/open_market/sms/responses/send_message.rb', line 23

def to
  @request.to
end

#to_sObject



43
44
45
# File 'lib/open_market/sms/responses/send_message.rb', line 43

def to_s
  "Response: #{status}, #{error}"
end