Class: SmsTraffic::Client::StatusReply
- Inherits:
-
Reply
- Object
- Reply
- SmsTraffic::Client::StatusReply
show all
- Defined in:
- lib/sms_traffic/client/status_reply.rb
Instance Attribute Summary
Attributes inherited from Reply
#hash, #xml
Instance Method Summary
collapse
Methods inherited from Reply
#initialize
Instance Method Details
#error(sms_id = nil) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/sms_traffic/client/status_reply.rb', line 29
def error(sms_id = nil)
return fetch_value(sms_array.first, :error) if sms_array.size == 1
raise ArgumentError, 'sms_id is required' if sms_id.nil?
errors[sms_id.to_s]
end
|
#errors ⇒ Object
37
38
39
40
41
|
# File 'lib/sms_traffic/client/status_reply.rb', line 37
def errors
sms_array.each_with_object({}) do |sms, hash|
hash[fetch_value(sms, :sms_id)] = fetch_value(sms, :error)&.strip
end.compact
end
|
#sms_array ⇒ Object
4
5
6
|
# File 'lib/sms_traffic/client/status_reply.rb', line 4
def sms_array
fetch_value(hash, :sms).is_a?(Array) ? fetch_value(hash, :sms) : [hash]
end
|
#status(sms_id = nil) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/sms_traffic/client/status_reply.rb', line 8
def status(sms_id = nil)
return fetch_value(sms_array.first, :status) if sms_array.size == 1
raise ArgumentError, 'sms_id is required' if sms_id.nil?
statuses[sms_id.to_s]
end
|
#statuses ⇒ Hash
Returns statuses hash (key: sms_id, value: status).
23
24
25
26
27
|
# File 'lib/sms_traffic/client/status_reply.rb', line 23
def statuses
sms_array.each_with_object({}) do |sms, hash|
hash[fetch_value(sms, :sms_id)] = fetch_value(sms, :status)
end.compact
end
|