Sha256: afbeb04a1b38869ffb77971c924e021b540554a7ea5d20e20ab9d002c2043b98

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'logger'
require 'open_pay_resource_factory'
require 'base64'
require 'rest-client'
require 'uri'
require 'errors/open_pay_exception'


LOG= Logger.new(STDOUT)

#change to Logger::DEBUG if need trace information
#due the nature of the information, we recommend to never use a log file when in debug
LOG.level=Logger::DEBUG


class OpenpayApi


  #API Endpoints
  API_DEV='https://sandbox-api.openpay.mx/v1/'
  API_PROD='https://api.openpay.mx'


  #by default the testing environment is used
  def initialize(merchant_id, private_key,production=false)
    @merchant_id=merchant_id
    @private_key=private_key
    @production=production
  end


  # @return [nil]
  def create(resource)
    klass=OpenPayResourceFactory::create(resource, @merchant_id,@private_key,@production)
    #attach api hook to be able to refere to same API instance from created resources
    #TODO we may move it to the initialize method
    klass.api_hook=self
    klass
  end


  def OpenpayApi::base_url(production)
    if production
      API_PROD
    else
      API_DEV
    end
  end


  def  env
    if @production
      :production
    else
      :test
    end
  end





end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openpay-0.9.8 lib/OpenPay/openpay_api.rb