Sha256: 3af0ddaf748f284857cbbc0e5b0a9d49f1ca783647d6fe49325b5aa4c7f32c18

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

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 def initialize(maxipagoId, apiKey, apiVersion, apts)
        @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

5 entries across 5 versions & 1 rubygems

Version Path
maxipago-0.1.7 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.6 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.5 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.4 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.3 lib/maxipago/xml_builder/builder.rb