Class: DNSApp::Domain
Instance Attribute Summary collapse
-
#auth_id ⇒ Object
The AUTHID for the domain.
-
#authoritative ⇒ Object
Whether DNSApp.net is authoritative for the domain If
false
the domain doesn’t point to the DNSApp.net nameservers. -
#created_at ⇒ Object
When the domain was created.
-
#handle ⇒ Object
The domain handle.
-
#id ⇒ Object
id for the domain.
-
#locked ⇒ Object
Whether the domain is locked.
-
#name ⇒ Object
The domain name.
-
#status ⇒ Object
The status of the domain.
-
#updated_at ⇒ Object
When the domain was updated.
-
#user_id ⇒ Object
The user_id for the domain.
Class Method Summary collapse
-
.all ⇒ Object
Retrives all domains.
-
.create(name) ⇒ Object
Creates a new domain
name
must be without www or similar. -
.find(id_or_name) ⇒ Object
Find domain by
id
orname
== Example DNSApp::Domain.find(10) DNSApp::Domain.find(“example.org”). -
.find_by_id(id) ⇒ Object
Find domain by
id
. -
.find_by_name(name) ⇒ Object
Find domain by
name
.
Instance Method Summary collapse
-
#destroy ⇒ Object
Deletes the domain.
-
#records ⇒ Object
Get records on the domain.
Methods inherited from Object
check_required_keys, delete, get, #initialize, #parent_id, #parent_id=, post, put
Constructor Details
This class inherits a constructor from DNSApp::Object
Instance Attribute Details
#auth_id ⇒ Object
The AUTHID for the domain. Used for transfers.
23 24 25 |
# File 'lib/dnsapp/domain.rb', line 23 def auth_id @auth_id end |
#authoritative ⇒ Object
Whether DNSApp.net is authoritative for the domain If false
the domain doesn’t point to the DNSApp.net nameservers
19 20 21 |
# File 'lib/dnsapp/domain.rb', line 19 def @authoritative end |
#created_at ⇒ Object
When the domain was created
12 13 14 |
# File 'lib/dnsapp/domain.rb', line 12 def created_at @created_at end |
#handle ⇒ Object
The domain handle
14 15 16 |
# File 'lib/dnsapp/domain.rb', line 14 def handle @handle end |
#locked ⇒ Object
Whether the domain is locked. Must be false if you wish to transfer.
27 28 29 |
# File 'lib/dnsapp/domain.rb', line 27 def locked @locked end |
#status ⇒ Object
The status of the domain
25 26 27 |
# File 'lib/dnsapp/domain.rb', line 25 def status @status end |
#updated_at ⇒ Object
When the domain was updated
16 17 18 |
# File 'lib/dnsapp/domain.rb', line 16 def updated_at @updated_at end |
#user_id ⇒ Object
The user_id for the domain
21 22 23 |
# File 'lib/dnsapp/domain.rb', line 21 def user_id @user_id end |
Class Method Details
.all ⇒ Object
Retrives all domains
31 32 33 34 |
# File 'lib/dnsapp/domain.rb', line 31 def all response = get("/domains")["domains"] response.collect { |attributes| Domain.new attributes } end |
.create(name) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dnsapp/domain.rb', line 65 def create(name) name.is_a? String or raise TypeError, "name must be string" r = post("/domains", :query => {"domain[name]" => name}) r["errors"] and raise StandardError, r["errors"]["error"].to_a.join(", ") if r.code == 201 Domain.new r["domain"] else raise StandardError, 'Could not create the domain' end end |
.find(id_or_name) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/dnsapp/domain.rb', line 40 def find(id_or_name) if id_or_name.is_a?(Integer) find_by_id(id_or_name) else find_by_name(id_or_name) end end |
.find_by_id(id) ⇒ Object
Find domain by id
49 50 51 52 53 |
# File 'lib/dnsapp/domain.rb', line 49 def find_by_id(id) response = get("/domains/#{id}")["domain"] response or return nil Domain.new response end |
.find_by_name(name) ⇒ Object
Find domain by name
56 57 58 59 |
# File 'lib/dnsapp/domain.rb', line 56 def find_by_name(name) domain = self.all.select { |d| d.name == name } return domain.blank? ? nil : domain.first end |
Instance Method Details
#destroy ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/dnsapp/domain.rb', line 82 def destroy r = self.class.delete("/domains/#{self.id}") if r.code == 200 self else raise StandardError, 'Could not delete the domain' end end |