Class: GoDaddy23::Domains

Inherits:
Object
  • Object
show all
Defined in:
lib/godaddy23.rb

Instance Method Summary collapse

Constructor Details

#initialize(apikey, secret, url: 'https://api.godaddy.com') ⇒ Domains

Returns a new instance of Domains.



22
23
24
25
26
# File 'lib/godaddy23.rb', line 22

def initialize(apikey, secret, url: 'https://api.godaddy.com')

  @apikey, @secret, @url = apikey, secret, url

end

Instance Method Details

#details(domain) ⇒ Object

Retrieve details for the specified Domain

curl -X ‘GET’ \

'https://api.godaddy.com/v1/domains/[MYDOMAIN]' \
-H 'accept: application/json' \
-H 'Authorization: sso-key [APIKEY]:[SECRET]'


36
37
38
# File 'lib/godaddy23.rb', line 36

def details(domain)
  submit(domain)
end

#submit(s) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/godaddy23.rb', line 40

def submit(s)

  uri = URI.parse(@url + "/v1/domains/" + s)
  request = Net::HTTP::Get.new(uri)
  request["Accept"] = "application/json"
  request["Authorization"] = "sso-key %s:%s" % [@apikey, @secret]

  req_options = {
    use_ssl: uri.scheme == "https",
  }

  response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
    http.request(request)
  end

  JSON.parse(response.body, symbolize_names: true)

end