Class: Fabulous::Resources::Domain

Inherits:
Base
  • Object
show all
Defined in:
lib/fabulous/resources/domain.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Fabulous::Resources::Base

Instance Method Details

#allObject



15
16
17
# File 'lib/fabulous/resources/domain.rb', line 15

def all
  paginate("listDomains")
end

#check(domain_name) ⇒ Object



19
20
21
22
# File 'lib/fabulous/resources/domain.rb', line 19

def check(domain_name)
  response = request("checkDomain", domain: domain_name)
  response.data[:available]
end

#disable_whois_privacy(domain_name) ⇒ Object



91
92
93
94
# File 'lib/fabulous/resources/domain.rb', line 91

def disable_whois_privacy(domain_name)
  response = request("disableWhoisPrivacy", domain: domain_name)
  response.success?
end

#enable_whois_privacy(domain_name) ⇒ Object



86
87
88
89
# File 'lib/fabulous/resources/domain.rb', line 86

def enable_whois_privacy(domain_name)
  response = request("enableWhoisPrivacy", domain: domain_name)
  response.success?
end

#get_nameservers(domain_name) ⇒ Object



66
67
68
69
# File 'lib/fabulous/resources/domain.rb', line 66

def get_nameservers(domain_name)
  info = info(domain_name)
  info[:nameservers] if info
end

#info(domain_name) ⇒ Object



24
25
26
27
# File 'lib/fabulous/resources/domain.rb', line 24

def info(domain_name)
  response = request("domainInfo", domain: domain_name)
  response.data[:domain_info]
end

#list(page: nil, &block) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fabulous/resources/domain.rb', line 6

def list(page: nil, &block)
  if page
    response = request("listDomains", page: page)
    block_given? ? yield(response) : response.data[:domains]
  else
    paginate("listDomains", &block)
  end
end

#lock(domain_name) ⇒ Object



71
72
73
74
# File 'lib/fabulous/resources/domain.rb', line 71

def lock(domain_name)
  response = request("lockDomain", domain: domain_name)
  response.success?
end

#register(domain_name, years: 1, nameservers: [], whois_privacy: false, auto_renew: false) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fabulous/resources/domain.rb', line 29

def register(domain_name, years: 1, nameservers: [], whois_privacy: false, auto_renew: false)
  params = {
    domain: domain_name,
    years: years,
    whoisPrivacy: whois_privacy,
    autoRenew: auto_renew
  }
  
  nameservers.each_with_index do |ns, index|
    params["ns#{index + 1}"] = ns
  end
  
  response = request("registerDomain", params)
  response.success?
end

#renew(domain_name, years: 1) ⇒ Object



45
46
47
48
# File 'lib/fabulous/resources/domain.rb', line 45

def renew(domain_name, years: 1)
  response = request("renewDomain", domain: domain_name, years: years)
  response.success?
end

#set_auto_renew(domain_name, enabled: true) ⇒ Object



81
82
83
84
# File 'lib/fabulous/resources/domain.rb', line 81

def set_auto_renew(domain_name, enabled: true)
  response = request("setAutoRenew", domain: domain_name, autoRenew: enabled)
  response.success?
end

#set_nameservers(domain_name, nameservers) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/fabulous/resources/domain.rb', line 55

def set_nameservers(domain_name, nameservers)
  params = { domain: domain_name }
  
  nameservers.each_with_index do |ns, index|
    params["ns#{index + 1}"] = ns
  end
  
  response = request("setNameServers", params)
  response.success?
end

#transfer_in(domain_name, auth_code) ⇒ Object



50
51
52
53
# File 'lib/fabulous/resources/domain.rb', line 50

def transfer_in(domain_name, auth_code)
  response = request("transferIn", domain: domain_name, authCode: auth_code)
  response.success?
end

#unlock(domain_name) ⇒ Object



76
77
78
79
# File 'lib/fabulous/resources/domain.rb', line 76

def unlock(domain_name)
  response = request("unlockDomain", domain: domain_name)
  response.success?
end