Class: Namecheap::Api
- Inherits:
-
Object
show all
- Defined in:
- lib/namecheap/api.rb
Constant Summary
collapse
- SANDBOX =
"https://api.sandbox.namecheap.com/xml.response"
- PRODUCTION =
"https://api.namecheap.com/xml.response"
- ENVIRONMENT =
(Rails) && Rails.respond_to?(:env)) ? Rails.env.to_s : (ENV["RACK_ENV"] || "development")
- ENDPOINT =
(ENVIRONMENT == "production") ? PRODUCTION : SANDBOX
Instance Method Summary
collapse
Instance Method Details
#delete(command, options = {}) ⇒ Object
22
23
24
|
# File 'lib/namecheap/api.rb', line 22
def delete(command, options = {})
request "delete", command, options
end
|
#get(command, options = {}) ⇒ Object
10
11
12
|
# File 'lib/namecheap/api.rb', line 10
def get(command, options = {})
request "get", command, options
end
|
#post(command, options = {}) ⇒ Object
14
15
16
|
# File 'lib/namecheap/api.rb', line 14
def post(command, options = {})
request "post", command, options
end
|
#put(command, options = {}) ⇒ Object
18
19
20
|
# File 'lib/namecheap/api.rb', line 18
def put(command, options = {})
request "put", command, options
end
|
#request(method, command, options = {}) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# 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"
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
|