class Namecheap::Api
Constants
- ENDPOINT
- ENVIRONMENT
- PRODUCTION
- SANDBOX
Public Instance Methods
delete(command, options = {})
click to toggle source
# File lib/namecheap/api.rb, line 22 def delete(command, options = {}) request 'post', command, options end
get(command, options = {})
click to toggle source
# File lib/namecheap/api.rb, line 10 def get(command, options = {}) request 'get', command, options end
init_args()
click to toggle source
# File lib/namecheap/api.rb, line 46 def init_args %w(username key client_ip).each do |key| if Namecheap.config.key.nil? raise Namecheap::Config::RequiredOptionMissing, "Configuration parameter missing: #{key}, " + "please add it to the Namecheap.configure block" end end options = { api_user: Namecheap.config.username, user_name: Namecheap.config.username, api_key: Namecheap.config.key, client_ip: Namecheap.config.client_ip } end
post(command, options = {})
click to toggle source
# File lib/namecheap/api.rb, line 14 def post(command, options = {}) request 'post', command, options end
put(command, options = {})
click to toggle source
# File lib/namecheap/api.rb, line 18 def put(command, options = {}) request 'post', command, options end
request(method, command, options = {})
click to toggle source
# File lib/namecheap/api.rb, line 26 def request(method, command, options = {}) command = 'namecheap.' + command options = init_args.merge(options).merge({:command => command}) options.keys.each do |key| options[key.to_s.camelize] = options.delete(key) end case method when 'get' #raise options.inspect HTTParty.get(ENDPOINT, { :query => options}) when 'post' HTTParty.post(ENDPOINT, { :query => options}) when 'put' HTTParty.put(ENDPOINT, { :query => options}) when 'delete' HTTParty.delete(ENDPOINT, { :query => options}) end end