Sha256: 6ed5cb16b7de61a832467f9a816c564b1db473d507ff7ee1d367d26350e5dbf4

Contents?: true

Size: 1023 Bytes

Versions: 21

Compression:

Stored size: 1023 Bytes

Contents

require 'nokogiri'

module Maxipago
  module XmlBuilder
    class Builder
      attr_reader :maxipagoId, :apiKey, :apiVersion, :command, :options

      MAXIPAGO_COMMANDS = %w(add_consumer delete_consumer update_consumer add_card_onfile delete_card_onfile sale void reversal recurring cancel_recurring bank_bill online_debit save_on_file one_transaction_report list_transactions_report transaction_paginate authorization authentication capture)
    
      def initialize(maxipagoId, apiKey, apiVersion, opts)
        @maxipagoId = maxipagoId
        @apiKey = apiKey
        @apiVersion = apiVersion
        @command = opts[:command].downcase
        @options = opts
      end

      def get_xml_data
        if command_defined?
          build_xml_data
        else
          raise "Command not defined!"
        end
      end

      private

      def command_defined?
        MAXIPAGO_COMMANDS.include?(self.command)
      end
      
      def build_xml_data
        method(self.command).call
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
maxipago-0.1.30 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.29 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.28 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.27 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.26 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.25 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.24 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.23 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.22 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.21 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.20 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.19 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.18 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.17 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.16 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.15 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.14 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.13 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.12 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.11 lib/maxipago/xml_builder/builder.rb