Sha256: a35533dc06511289a8392c0493947ea1cd235a1e5e95be7de01a9dcad0ee423e

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

module Asaas
  module Configuration

    ENDPOINT_PRODUCTION = {
      v2: 'https://www.asaas.com/api/v2',
      v3: 'https://www.asaas.com/api/v3',
    }

    ENDPOINT_HOMOLOG = {
      v2: 'https://sandbox.asaas.com/api/v2',
      v3: 'https://sandbox.asaas.com/api/v3',
    }

    mattr_accessor :production do
      false
    end

    mattr_accessor :webhook_url do
      nil
    end

    mattr_accessor :webhook_email do
      nil
    end

    mattr_accessor :api_version do
      3
    end

    mattr_accessor :token

    mattr_accessor :debug do
      false
    end

    class << self

      def setup(&block)
        yield self if block_given?
        self
      end

      def get_endpoint(api_version = nil)
        api_version ||= Asaas::Configuration.api_version
        if production
          ENDPOINT_PRODUCTION[:"v#{api_version}"]
        else
          ENDPOINT_HOMOLOG[:"v#{api_version}"]
        end
      end

      def get_environment
        if production
          :production
        else
          :homolog
        end
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
asaas-ruby-0.2.27 lib/asaas/configuration.rb
asaas-ruby-0.2.26 lib/asaas/configuration.rb
asaas-ruby-0.2.25 lib/asaas/configuration.rb
asaas-ruby-0.2.18 lib/asaas/configuration.rb