Class: Mblox::SmsReceipt
- Inherits:
-
Object
- Object
- Mblox::SmsReceipt
- Defined in:
- lib/mblox/sms_receipt.rb
Instance Attribute Summary collapse
-
#batch_id ⇒ Object
readonly
Returns the value of attribute batch_id.
-
#msg_reference ⇒ Object
readonly
Returns the value of attribute msg_reference.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#subscriber_number ⇒ Object
readonly
Returns the value of attribute subscriber_number.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(xml) ⇒ SmsReceipt
constructor
A new instance of SmsReceipt.
Constructor Details
#initialize(xml) ⇒ SmsReceipt
Returns a new instance of SmsReceipt.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mblox/sms_receipt.rb', line 6 def initialize(xml) data = Mblox.from_xml(xml)['NotificationService'] raise MissingExpectedXmlContentError, "Xml should have contained a 'NotificationService' node, but was #{xml}" if data.blank? data = data['NotificationList'] raise MissingExpectedXmlContentError, "Xml should have contained a 'NotificationService' -> 'NotificationList' node, but was #{xml}" if data.blank? data = data['Notification'] raise MissingExpectedXmlContentError, "Xml should have contained a 'NotificationService' -> 'NotificationList' -> 'Notification' node, but was #{xml}" if data.blank? @batch_id = data['BatchID'].to_i data = data['Subscriber'] raise MissingExpectedXmlContentError, "Xml should have contained a 'NotificationService' -> 'NotificationList' -> 'Notification' -> 'Subscriber' node, but was #{xml}" if data.blank? @subscriber_number = data['SubscriberNumber'] @subscriber_number = @subscriber_number[1..-1] if '1' == @subscriber_number[0] unless data['TimeStamp'].blank? = begin Time.strptime("#{data['TimeStamp']}+0000", '%Y%m%d%H%M%z') rescue ArgumentError nil end end = .to_datetime if @msg_reference = data['MsgReference'] @status = data['Status'] @reason = data['Reason'].blank? ? nil : data['Reason'].to_i end |
Instance Attribute Details
#batch_id ⇒ Object (readonly)
Returns the value of attribute batch_id.
5 6 7 |
# File 'lib/mblox/sms_receipt.rb', line 5 def batch_id @batch_id end |
#msg_reference ⇒ Object (readonly)
Returns the value of attribute msg_reference.
5 6 7 |
# File 'lib/mblox/sms_receipt.rb', line 5 def msg_reference @msg_reference end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
5 6 7 |
# File 'lib/mblox/sms_receipt.rb', line 5 def reason @reason end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/mblox/sms_receipt.rb', line 5 def status @status end |
#subscriber_number ⇒ Object (readonly)
Returns the value of attribute subscriber_number.
5 6 7 |
# File 'lib/mblox/sms_receipt.rb', line 5 def subscriber_number @subscriber_number end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
5 6 7 |
# File 'lib/mblox/sms_receipt.rb', line 5 def end |