Sha256: a6f0901065dbfba18e85d36f48e42797920839a556f071fa39d53c4c2fe7e5a0

Contents?: true

Size: 680 Bytes

Versions: 3

Compression:

Stored size: 680 Bytes

Contents

module Namecheap
  class Api
    SANDBOX = 'https://api.sandbox.namecheap.com/xml.response'
    PRODUCTION = 'https://api.namecheap.com/xml.response'
    ENVIRONMENT = defined?(Rails) && Rails.respond_to?(:env) ? Rails.env : (ENV["RACK_ENV"] || 'development')
    ENDPOINT = (ENVIRONMENT == 'production' ? PRODUCTION : SANDBOX)

    def api_call(command, command_args)
      args = {}
      args['ApiUser'] = args['UserName'] = Namecheap.username
      args['ApiKey'] = Namecheap.key
      args['ClientIp'] = Namecheap.client_ip
      args['Command'] = command
      args.merge! command_args
      query = ENDPOINT + '?' + args.to_param
      HTTParty.get(query)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
namecheap-0.1.2 lib/namecheap/api.rb
namecheap-0.1.1 lib/namecheap/api.rb
namecheap-0.1.0 lib/namecheap/api.rb