Sha256: 9568bedd50f865ab2274628410cd76fdef5c25ced67876ff8ffa790b027c318d

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'nokogiri'

# <InboundMessage>
#  <Id>{guid-of-push-notification}</Id>
#  <MessageId>{guid-of-inbound-message}</MessageId>
#  <AccountId>{guid-of-esendex-account-for-message}</AccountId>
#  <MessageText>{Message text of inbound message}</MessageText>
#  <From>{phone number of sender of the message}</From>
#  <To>{phone number for the Virtual Mobile Number of your Account}</To>
# </InboundMessage>

module Esendex
  class InboundMessage
    include HashSerialisation
    
    attr_accessor :id, :message_id, :account_id, :message_text, :from, :to

    def self.from_xml(source)
      doc = Nokogiri::XML source
      event = InboundMessage.new
      event.id = doc.at_xpath("/InboundMessage/Id").content
      event.message_id = doc.at_xpath("/InboundMessage/MessageId").content
      event.account_id = doc.at_xpath("/InboundMessage/AccountId").content
      event.message_text = doc.at_xpath("/InboundMessage/MessageText").content
      event.from = doc.at_xpath("/InboundMessage/From").content
      event.to = doc.at_xpath("/InboundMessage/To").content
      event
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
esendex-0.4.0 lib/esendex/inbound_message.rb
esendex-0.3.2 lib/esendex/inbound_message.rb
esendex-0.3.1 lib/esendex/inbound_message.rb
esendex-0.3.0 lib/esendex/inbound_message.rb