Sha256: c2f498c3b94e7eacbe1cad6b2e42a731b9279bdcf6605fb0935858b3da9ae513

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require "moiper/version"
require "moiper/payment"
require "moiper/request"
require "moiper/response"
require "moiper/notification"
require "moiper/railtie" if defined? Rails

module Moiper
  API_ENTRYPOINTS = {
    :sandbox    => "https://desenvolvedor.moip.com.br/sandbox/",
    :production => "https://www.moip.com.br/"
  }

  class << self
    # Set Moip's API token
    attr_accessor :token

    # Set Moip's API key
    attr_accessor :key

    # Define if requests should be made against Moip's sandbox
    # environment. This is specially usefull when running
    # on development or test mode. Default is false.
    #
    #  Moiper.sandbox = true
    #
    attr_accessor :sandbox

    # Configure Moiper options.
    #
    #  Moiper.configure do |config|
    #    config.sandbox = true
    #  end
    #
    def configure(&block)
      yield self
    end

    # Inform if in sandbox mode
    def sandbox?
      sandbox == true
    end

    # Returns the Moip API entrypoint based on the current environment
    def api_entrypoint
      sandbox? ? API_ENTRYPOINTS[:sandbox] : API_ENTRYPOINTS[:production]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
moiper-0.1.1 lib/moiper.rb
moiper-0.1.0 lib/moiper.rb