Class: DME
- Inherits:
-
Object
- Object
- DME
- Defined in:
- lib/dme-api.rb
Instance Method Summary collapse
- #create(record) ⇒ Object
- #delete(id) ⇒ Object
- #get(name) ⇒ Object
-
#initialize(api_key, secret_key, domain) ⇒ DME
constructor
A new instance of DME.
Constructor Details
#initialize(api_key, secret_key, domain) ⇒ DME
Returns a new instance of DME.
12 13 14 15 16 17 18 19 |
# File 'lib/dme-api.rb', line 12 def initialize(api_key, secret_key, domain) @@dme_rest_url = "http://api.dnsmadeeasy.com/V1.2/domains/" @api_key = api_key @secret_key = secret_key @domain = domain end |
Instance Method Details
#create(record) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/dme-api.rb', line 28 def create(record) response = RestClient.post get_url(), record.to_json, get_headers(:"content-type" => :json) JSON.parse(response) end |
#delete(id) ⇒ Object
35 36 37 |
# File 'lib/dme-api.rb', line 35 def delete(id) response = RestClient.delete get_url(id), get_headers() end |
#get(name) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/dme-api.rb', line 21 def get(name) response = RestClient.get(get_url(), get_headers()) # find the record we want JSON.parse(response.to_str).select { |x| x["name"] == name }.first end |