Sha256: 4468a8263a017950503d1b28c19f3eff1e358a52b27aa974eb923d4703fd5f55

Contents?: true

Size: 922 Bytes

Versions: 2

Compression:

Stored size: 922 Bytes

Contents

require 'xmlsimple'
module Dineromail
  class Notification
    
    attr_reader :transaction_id, :tipo
    
    def initialize(transaction_id, tipo = nil)
      @transaction_id = transaction_id
      @tipo = tipo
    end
    
    def status_report
      unless @status_report
        @status_report = StatusReport.new(transaction_id)
      end
      @status_report
    end
    
    def self.from_xml(notification_xml)
      notifications = []
      notificaction_data = XmlSimple.xml_in(notification_xml,'KeyToSymbol' => true)
      operations = notificaction_data[:operaciones].first[:operacion]
      operations.each do |operation|
        tipo = operation[:tipo].first
        transaction_id = operation[:id].first
        notifications << self.new(transaction_id, tipo)
      end
      notifications
    end
    
    def self.method_missing(symbol, *args)
      status_report.send(symbol, *args)
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dineromail-0.0.4 lib/dineromail/notification.rb
dineromail-0.0.3 lib/dineromail/notification.rb