Sha256: 7586eda4120b2311d881e9d40067ca83b4a3e602cea36888d69be481efc81c95

Contents?: true

Size: 1023 Bytes

Versions: 2

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, 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

2 entries across 2 versions & 1 rubygems

Version Path
maxipago-0.1.9 lib/maxipago/xml_builder/builder.rb
maxipago-0.1.8 lib/maxipago/xml_builder/builder.rb