require 'nokogiri' # # {guid-of-push-notification} # {guid-of-inbound-message} # {guid-of-esendex-account-for-message} # # {the UTC DateTime (yyyy-MM-ddThh:mm:ss) the message was delivered} # # module Esendex class MessageDeliveredEvent include HashSerialisation attr_accessor :id, :message_id, :account_id, :occurred_at def self.from_xml(source) doc = Nokogiri::XML source event = MessageDeliveredEvent.new event.id = doc.at_xpath("/MessageDelivered/Id").content event.message_id = doc.at_xpath("/MessageDelivered/MessageId").content event.account_id = doc.at_xpath("/MessageDelivered/AccountId").content occurred_at_s = doc.at_xpath("/MessageDelivered/OccurredAt").content event.occurred_at = DateTime.strptime(occurred_at_s, "%Y-%m-%dT%H:%M:%S").to_time event end end end