godaddy23 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afb0f7096b018e115f6cd9569ffb5f921199b289cf70eb7797c453706c9b25ac
4
- data.tar.gz: ffed7ba33007967d6cf8cbb4cb2b71f033a85b71971b8922a5a8a1d871a2c825
3
+ metadata.gz: fba08155664b36e309d922e162c92f16431c5a12132ecff5e746b1dbf0a6ae0b
4
+ data.tar.gz: 6c5102a68816d1bc31cb5a78aa569aa836ab9dc0778d2bbcda8a52682777daa2
5
5
  SHA512:
6
- metadata.gz: 5234d45d9634003f6654f6ac68efc8424f088ccc30bb48a4baeb5ca64b577778ebedef4b56a6fad6d4d5f67a6f9a0437cbac307982621c1c3a27c173994bb2aa
7
- data.tar.gz: d85765dca0dadf9edcebd5c977578d714acc6f99253c974e60820f4f3251c9ac87b8a770e7e81f5e0a42478a4004f170985394434ef1868a34757383ab54e7d2
6
+ metadata.gz: 76d8011e3135644b5745b0c016770f91e8c0c8f4f41926a66fd46a950e861e976d141fdac396de3ded5f0aca1accecc06505d463857ed2655c52bf0afaf76e3e
7
+ data.tar.gz: 45fa4264607265b379eb059d940e48393ea7bf1537bdc9dc4f49ac26b8a5fd8f4456a33c45c425cba1e9816ea95b210d55a1b66a547faefce99f1f5cf8138541
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/godaddy23.rb CHANGED
@@ -10,6 +10,32 @@
10
10
 
11
11
  # By default this gem is set for the production environment
12
12
 
13
+ # API reference for domains
14
+
15
+ # available # GET # /v1/domains/available # Determine whether or not the specified domain is available for purchase
16
+ # availables # POST # /v1/domains/available # Determine whether or not the specified domains are available for purchase
17
+ # n/a # POST # /v1/domains/contacts/validate # Validate the request body using the Domain Contact Validation Schema for specified domains.
18
+ # n/a # POST # /v1/domains/purchase # Purchase and register the specified Domain
19
+ # n/a # GET # /v1/domains/purchase/schema/{tld} # Retrieve the schema to be submitted when registering a Domain for the specified TLD
20
+ # n/a # POST # /v1/domains/purchase/validate # Validate the request body using the Domain Purchase Schema for the # specified TLD
21
+ # n/a # GET # /v1/domains/suggest # Suggest alternate Domain names based on a seed Domain, a set of keywords, or the # shopper's purchase history
22
+ # n/a # GET # /v1/domains/tlds # Retrieves a list of TLDs supported and enabled for sale
23
+ # n/a # DELETE # /v1/domains/{domain} # Cancel a purchased domain
24
+ # details # GET # /v1/domains/{domain} # Retrieve details for the specified Domain
25
+ # n/a # PATCH # /v1/domains/{domain} # Update details for the specified Domain
26
+ # n/a # PATCH # /v1/domains/{domain}/contacts # Update domain
27
+ # n/a # DELETE # /v1/domains/{domain}/privacy # Submit a privacy cancellation request for the given domain
28
+ # n/a # POST # /v1/domains/{domain}/privacy/purchase # Purchase privacy for a specified domain
29
+ # n/a # PATCH # /v1/domains/{domain}/records # Add the specified DNS Records to the specified Domain
30
+ # replace_records # PUT # /v1/domains/{domain}/records # Replace all DNS Records for the specified Domain
31
+ # list_records # GET # /v1/domains/{domain}/records/{type}/{name} # Retrieve DNS Records for the specified Domain, optionally with the specified Type and/or Name
32
+ # replace_records # PUT # /v1/domains/{domain}/records/{type}/{name} # Replace all DNS Records for the specified Domain with the specified Type and Name
33
+ # n/a # DELETE # /v1/domains/{domain}/records/{type}/{name} # Delete all DNS Records for the specified Domain with the specified Type and Name
34
+ # replace_records # PUT # /v1/domains/{domain}/records/{type} # Replace all DNS Records for the specified Domain with the specified Type
35
+ # n/a # POST # /v1/domains/{domain}/renew # Renew the specified Domain
36
+ # n/a # POST # /v1/domains/{domain}/transfer # Purchase and start or restart transfer process
37
+ # n/a # POST # /v1/domains/{domain}/verifyRegistrantEmail # Re-send Contact E-mail Verification for specified Domain
38
+
13
39
 
14
40
  require 'net/http'
15
41
  require 'uri'
@@ -35,7 +61,7 @@ module GoDaddy23
35
61
  #
36
62
  #
37
63
  def details(domain)
38
- submit(domain)
64
+ get(domain)
39
65
  end
40
66
 
41
67
  # Retrieve DNS Records for the specified Domain, optionally with the
@@ -45,7 +71,7 @@ module GoDaddy23
45
71
  # name: e.g. www
46
72
  #
47
73
  # curl -X 'GET' \
48
- # 'https://api.godaddy.com/v1/domains/[MYDOMAIN]' \
74
+ # 'https://api.godaddy.com/v1/domains/[MYDOMAIN]/records/[TYPE]/[NAME]' \
49
75
  # -H 'accept: application/json' \
50
76
  # -H 'Authorization: sso-key [APIKEY]:[SECRET]
51
77
  #
@@ -60,16 +86,67 @@ module GoDaddy23
60
86
  uri += '/' + name
61
87
  end
62
88
 
63
- submit(uri)
89
+ get(uri)
90
+
91
+ end
92
+
93
+ # Replace all DNS Records for the specified Domain with the specified Type and Name
94
+ #
95
+ # type: e.g. A
96
+ # name: e.g. www
97
+ #
98
+ # warning: be careful if you don't supply a type and name as you may
99
+ # accidentally remove existing records if they are not being
100
+ # updated using the *records* keyword parameter
101
+ #
102
+ # curl -X 'PUT' \
103
+ # 'https://api.godaddy.com/v1/domains/[DOMAIN]/records/[TYPE]/[NAME]' \
104
+ # -H 'accept: application/json' \
105
+ # -H 'Content-Type: application/json' \
106
+ # -H 'Authorization: sso-key [APIKEY]:[SECRET]' \
107
+ # -d '[
108
+ # {"data":"[NEW_IP]","ttl":600}
109
+ # ]'
110
+ #
111
+ def replace_records(domain, type: nil, name: nil, records: [])
112
+
113
+ uri = domain
114
+ uri += '/records'
115
+ uri += '/' + type if type
116
+
117
+ if name then
118
+ uri += '/A' if type.nil?
119
+ uri += '/' + name
120
+ end
64
121
 
122
+ put(uri, records)
65
123
  end
66
124
 
67
125
  private
126
+
127
+ def get(uri_part)
128
+ r = submit(uri_part) do |uri|
129
+ Net::HTTP::Get.new(uri)
130
+ end
131
+ JSON.parse(r.body, symbolize_names: true)
132
+ end
133
+
134
+ def put(uri_part, payload)
135
+
136
+ r = submit(uri_part) do |uri|
137
+ request = Net::HTTP::Put.new(uri)
138
+ request.content_type = "application/json"
139
+ request.body = JSON.dump(payload)
140
+ request
141
+ end
142
+
143
+ end
68
144
 
69
145
  def submit(s)
70
146
 
71
147
  uri = URI.parse(@url + "/v1/domains/" + s)
72
- request = Net::HTTP::Get.new(uri)
148
+
149
+ request = yield(uri) if block_given?
73
150
  request["Accept"] = "application/json"
74
151
  request["Authorization"] = "sso-key %s:%s" % [@apikey, @secret]
75
152
 
@@ -81,7 +158,6 @@ module GoDaddy23
81
158
  http.request(request)
82
159
  end
83
160
 
84
- JSON.parse(response.body, symbolize_names: true)
85
161
 
86
162
  end
87
163
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: godaddy23
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -36,7 +36,7 @@ cert_chain:
36
36
  Yg9iNn+HpSpcgFFNYkD9AkRV4P3F0m3lGd5T/u5I61G8igHUOocGsbItrIsMUv5k
37
37
  tlXmn35NPgEcJF/WY5HMzywKhA3Vj/dVyxo=
38
38
  -----END CERTIFICATE-----
39
- date: 2023-03-19 00:00:00.000000000 Z
39
+ date: 2023-03-21 00:00:00.000000000 Z
40
40
  dependencies: []
41
41
  description:
42
42
  email: digital.robertson@gmail.com
metadata.gz.sig CHANGED
Binary file