gandi_v5 0.1.0 → 0.2.0
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 +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +44 -2
- data/Guardfile +5 -6
- data/README.md +5 -5
- data/doc/GandiV5/Billing/Info/Prepaid.html +817 -0
- data/doc/GandiV5/Billing/Info.html +641 -0
- data/doc/GandiV5/Billing.html +293 -0
- data/doc/GandiV5/Data/ClassMethods.html +223 -0
- data/doc/GandiV5/Data/Converter/ArrayOf.html +413 -0
- data/doc/GandiV5/Data/Converter/Symbol.html +322 -0
- data/doc/GandiV5/Data/Converter/Time.html +330 -0
- data/doc/GandiV5/Data/Converter.html +433 -0
- data/doc/GandiV5/Data.html +785 -0
- data/doc/GandiV5/Domain/AutoRenew.html +1237 -0
- data/doc/GandiV5/Domain/Availability/Product/Period.html +220 -0
- data/doc/GandiV5/Domain/Availability/Product/Price.html +1031 -0
- data/doc/GandiV5/Domain/Availability/Product.html +988 -0
- data/doc/GandiV5/Domain/Availability/Tax.html +440 -0
- data/doc/GandiV5/Domain/Availability.html +1020 -0
- data/doc/GandiV5/Domain/Contact.html +4459 -0
- data/doc/GandiV5/Domain/Contract.html +520 -0
- data/doc/GandiV5/Domain/Dates.html +1313 -0
- data/doc/GandiV5/Domain/RenewalInformation.html +1147 -0
- data/doc/GandiV5/Domain/RestoreInformation.html +339 -0
- data/doc/GandiV5/Domain/SharingSpace.html +437 -0
- data/doc/GandiV5/Domain/TLD.html +1565 -0
- data/doc/GandiV5/Domain.html +16847 -0
- data/doc/GandiV5/Email/Mailbox/Responder.html +1560 -0
- data/doc/GandiV5/Email/Mailbox.html +6307 -0
- data/doc/GandiV5/Email/Offer.html +514 -0
- data/doc/GandiV5/Email/Slot.html +4244 -0
- data/doc/GandiV5/Email.html +144 -0
- data/doc/GandiV5/Error/GandiError.html +270 -0
- data/doc/GandiV5/Error.html +151 -0
- data/doc/GandiV5/LiveDNS/Domain.html +2984 -0
- data/doc/GandiV5/LiveDNS/RecordSet.html +1593 -0
- data/doc/GandiV5/LiveDNS/Zone/Snapshot.html +1556 -0
- data/doc/GandiV5/LiveDNS/Zone.html +8891 -0
- data/doc/GandiV5/LiveDNS.html +300 -0
- data/doc/GandiV5/Organization.html +2341 -0
- data/doc/GandiV5.html +1183 -0
- data/doc/_index.html +474 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +175 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +175 -0
- data/doc/js/app.js +303 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +2427 -0
- data/doc/top-level-namespace.html +110 -0
- data/gandi_v5.gemspec +1 -1
- data/lib/gandi_v5/billing.rb +2 -2
- data/lib/gandi_v5/data.rb +2 -0
- data/lib/gandi_v5/domain/auto_renew.rb +4 -4
- data/lib/gandi_v5/domain/availability/product/period.rb +24 -0
- data/lib/gandi_v5/domain/availability/product/price.rb +36 -0
- data/lib/gandi_v5/domain/availability/product.rb +52 -0
- data/lib/gandi_v5/domain/availability/tax.rb +20 -0
- data/lib/gandi_v5/domain/availability.rb +49 -0
- data/lib/gandi_v5/domain/tld.rb +57 -0
- data/lib/gandi_v5/domain.rb +41 -86
- data/lib/gandi_v5/email/mailbox/responder.rb +43 -2
- data/lib/gandi_v5/email/mailbox.rb +32 -21
- data/lib/gandi_v5/email/offer.rb +2 -2
- data/lib/gandi_v5/email/slot.rb +42 -16
- data/lib/gandi_v5/error/gandi_error.rb +2 -2
- data/lib/gandi_v5/live_dns/domain.rb +59 -45
- data/lib/gandi_v5/live_dns/zone/snapshot.rb +27 -8
- data/lib/gandi_v5/live_dns/zone.rb +63 -59
- data/lib/gandi_v5/live_dns.rb +20 -0
- data/lib/gandi_v5/organization.rb +2 -2
- data/lib/gandi_v5/version.rb +1 -1
- data/lib/gandi_v5.rb +25 -5
- data/spec/features/domain_spec.rb +1 -1
- data/spec/fixtures/bodies/{GandiV5_Domain/availability.yaml → GandiV5_Domain_Availability/fetch.yaml} +0 -0
- data/spec/fixtures/bodies/{GandiV5_Domain/tld.yaml → GandiV5_Domain_TLD/fetch.yaml} +0 -0
- data/spec/fixtures/bodies/{GandiV5_Domain/tlds.yaml → GandiV5_Domain_TLD/list.yaml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/{get.yaml → fetch.yaml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yaml +3 -0
- data/spec/units/gandi_v5/billing_spec.rb +2 -2
- data/spec/units/gandi_v5/domain/auto_renew_spec.rb +5 -5
- data/spec/units/gandi_v5/domain/availability/product/period_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability/product/price_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability/product_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability/tax_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability_spec.rb +43 -0
- data/spec/units/gandi_v5/domain/tld_spec.rb +29 -0
- data/spec/units/gandi_v5/domain_spec.rb +89 -81
- data/spec/units/gandi_v5/email/mailbox/responder_spec.rb +52 -0
- data/spec/units/gandi_v5/email/mailbox_spec.rb +56 -27
- data/spec/units/gandi_v5/email/offer_spec.rb +1 -1
- data/spec/units/gandi_v5/email/slot_spec.rb +101 -13
- data/spec/units/gandi_v5/live_dns/domain_spec.rb +70 -40
- data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +32 -3
- data/spec/units/gandi_v5/live_dns/zone_spec.rb +68 -50
- data/spec/units/gandi_v5/live_dns_spec.rb +24 -0
- data/spec/units/gandi_v5/organization_spec.rb +1 -1
- data/spec/units/gandi_v5_spec.rb +37 -12
- metadata +72 -9
- data/TODO.md +0 -29
@@ -63,7 +63,7 @@ class GandiV5
|
|
63
63
|
# @param name [String] the name to fetch records for.
|
64
64
|
# @param type [String] the record type to fetch.
|
65
65
|
# @return [Array<GandiV5::LiveDNS::RecordSet>]
|
66
|
-
# @raise [GandiV5::Error::GandiError
|
66
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
67
67
|
def fetch_records(name = nil, type = nil)
|
68
68
|
GandiV5::LiveDNS.require_valid_record_type type if type
|
69
69
|
|
@@ -71,7 +71,7 @@ class GandiV5
|
|
71
71
|
url_ += "/#{CGI.escape name}" if name
|
72
72
|
url_ += "/#{CGI.escape type}" if type
|
73
73
|
|
74
|
-
data = GandiV5.get url_
|
74
|
+
_response, data = GandiV5.get url_
|
75
75
|
data = [data] unless data.is_a?(Array)
|
76
76
|
data.map { |item| GandiV5::LiveDNS::RecordSet.from_gandi item }
|
77
77
|
end
|
@@ -86,7 +86,7 @@ class GandiV5
|
|
86
86
|
# @param name [String] the name to fetch records for.
|
87
87
|
# @param type [String] the record type to fetch.
|
88
88
|
# @return [String]
|
89
|
-
# @raise [GandiV5::Error::GandiError
|
89
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
90
90
|
def fetch_zone_lines(name = nil, type = nil)
|
91
91
|
GandiV5::LiveDNS.require_valid_record_type type if type
|
92
92
|
|
@@ -94,7 +94,7 @@ class GandiV5
|
|
94
94
|
url_ += "/#{CGI.escape name}" if name
|
95
95
|
url_ += "/#{CGI.escape type}" if type
|
96
96
|
|
97
|
-
GandiV5.get
|
97
|
+
GandiV5.get(url_, accept: 'text/plain').last
|
98
98
|
end
|
99
99
|
|
100
100
|
# Add record to this zone.
|
@@ -103,7 +103,7 @@ class GandiV5
|
|
103
103
|
# @param ttl [Integer]
|
104
104
|
# @param values [Array<String>]
|
105
105
|
# @return [String] The confirmation message from Gandi.
|
106
|
-
# @raise [GandiV5::Error::GandiError
|
106
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
107
107
|
def add_record(name, type, ttl, *values)
|
108
108
|
GandiV5::LiveDNS.require_valid_record_type type
|
109
109
|
fail ArgumentError, 'ttl must be positive and non-zero' unless ttl.positive?
|
@@ -115,7 +115,7 @@ class GandiV5
|
|
115
115
|
rrset_ttl: ttl,
|
116
116
|
rrset_values: values
|
117
117
|
}.to_json
|
118
|
-
data = GandiV5.post "#{url}/records", body
|
118
|
+
_response, data = GandiV5.post "#{url}/records", body
|
119
119
|
data['message']
|
120
120
|
end
|
121
121
|
|
@@ -129,14 +129,14 @@ class GandiV5
|
|
129
129
|
# @param name [String] the name to delete records for.
|
130
130
|
# @param type [String] the record type to delete.
|
131
131
|
# @return [nil]
|
132
|
-
# @raise [GandiV5::Error::GandiError
|
132
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
133
133
|
def delete_records(name = nil, type = nil)
|
134
134
|
GandiV5::LiveDNS.require_valid_record_type type if type
|
135
135
|
|
136
136
|
url_ = "#{url}/records"
|
137
137
|
url_ += "/#{CGI.escape name}" if name
|
138
138
|
url_ += "/#{CGI.escape type}" if type
|
139
|
-
GandiV5.delete
|
139
|
+
GandiV5.delete(url_).last
|
140
140
|
end
|
141
141
|
|
142
142
|
# Replace all records for this zone.
|
@@ -146,9 +146,9 @@ class GandiV5
|
|
146
146
|
# @param text [String] zone file lines to replace the records with.
|
147
147
|
# @return [String] The confirmation message from Gandi.
|
148
148
|
# @raise [ArgumentError] if neither/both of records & test are passed.
|
149
|
-
# @raise [GandiV5::Error::GandiError
|
149
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
150
150
|
def replace_records(records: nil, text: nil)
|
151
|
-
unless [records, text].
|
151
|
+
unless [records, text].one?(&:nil?)
|
152
152
|
fail ArgumentError, 'you must pass ONE of records: or text:'
|
153
153
|
end
|
154
154
|
|
@@ -156,47 +156,52 @@ class GandiV5
|
|
156
156
|
body = {
|
157
157
|
items: records.map { |r| r.transform_keys { |k| "rrset_#{k}" } }
|
158
158
|
}.to_json
|
159
|
-
data = GandiV5.put "#{url}/records", body
|
159
|
+
_response, data = GandiV5.put "#{url}/records", body
|
160
160
|
elsif text
|
161
|
-
data = GandiV5.put "#{url}/records", text, 'content-type': 'text/plain'
|
161
|
+
_response, data = GandiV5.put "#{url}/records", text, 'content-type': 'text/plain'
|
162
162
|
end
|
163
163
|
data['message']
|
164
164
|
end
|
165
165
|
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
166
|
+
# @override replace_records_for(name, records)
|
167
|
+
# Replace records for a name in this zone.
|
168
|
+
# @param name [String]
|
169
|
+
# @param records
|
170
|
+
# [Array<Hash<type: String, ttl: Integer, values: Array<String>>>]
|
171
|
+
# the records to add.
|
172
|
+
# @override replace_records_for(name, values, type: nil, ttl: nil)
|
173
|
+
# Replace records for a name in this zone.
|
174
|
+
# @param name [String]
|
175
|
+
# @param type [String] the record type.
|
176
|
+
# @param ttl [Integer] the TTL to set for the record.
|
177
|
+
# @param values [Array<String>] the values to set for the record.
|
178
|
+
# @raise [ArgumentError] if ttl is present and type is absent.
|
171
179
|
# @return [String] The confirmation message from Gandi.
|
172
|
-
# @raise [GandiV5::Error::GandiError
|
173
|
-
def replace_records_for(name,
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
181
|
+
def replace_records_for(name, records, type: nil, ttl: nil)
|
182
|
+
fail ArgumentError, 'missing keyword: type' if ttl && type.nil?
|
183
|
+
|
184
|
+
if type
|
185
|
+
GandiV5::LiveDNS.require_valid_record_type type
|
186
|
+
body = { rrset_values: records, rrset_ttl: ttl }
|
187
|
+
# body[:rrset_ttl] = ttl if ttl
|
188
|
+
_response, data = GandiV5.put "#{url}/records/#{name}/#{type}", body.to_json
|
180
189
|
|
181
|
-
|
182
|
-
# Replace records of a given type for a name in this zone.
|
183
|
-
# @return [String] The confirmation message from Gandi.
|
184
|
-
# @raise [GandiV5::Error::GandiError::GandiError] if Gandi returns an error.
|
185
|
-
define_method "replace_#{type.downcase}_records_for" do |name, ttl, *values|
|
190
|
+
else
|
186
191
|
body = {
|
187
|
-
|
188
|
-
|
189
|
-
}.to_json
|
190
|
-
data = GandiV5.put "#{url}/records/#{name}/#{type}", body
|
191
|
-
data['message']
|
192
|
+
items: records.map { |r| r.transform_keys { |k| "rrset_#{k}" } }
|
193
|
+
}
|
194
|
+
_response, data = GandiV5.put "#{url}/records/#{name}", body.to_json
|
192
195
|
end
|
196
|
+
|
197
|
+
data['message']
|
193
198
|
end
|
194
199
|
|
195
200
|
# List the domains that use this zone.
|
196
201
|
# @return [Array<String>] The FQDNs.
|
197
|
-
# @raise [GandiV5::Error::GandiError
|
202
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
198
203
|
def list_domains
|
199
|
-
data = GandiV5.get "#{url}/domains"
|
204
|
+
_response, data = GandiV5.get "#{url}/domains"
|
200
205
|
data.map { |item| item['fqdn'] }
|
201
206
|
end
|
202
207
|
|
@@ -204,50 +209,49 @@ class GandiV5
|
|
204
209
|
# @param fqdn [String, #fqdn, #to_s] the fully qualified domain name
|
205
210
|
# that should start using this zone.
|
206
211
|
# @return [String] The confirmation message from Gandi.
|
207
|
-
# @raise [GandiV5::Error::GandiError
|
212
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
208
213
|
def attach_domain(fqdn)
|
209
214
|
fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn)
|
210
|
-
data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json
|
215
|
+
_resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json
|
211
216
|
data['message']
|
212
217
|
end
|
213
218
|
|
214
|
-
# Get snapshot UUIDs for this zone from Gandi.
|
215
|
-
# @return [Hash{String => Time}] Mapping UUID to time made.
|
216
|
-
# @raise [GandiV5::Error::GandiError
|
219
|
+
# Get snapshot UUIDs for this zone from Gandi.
|
220
|
+
# @return [Hash{String => Time}] Mapping snapshot UUID to time made.
|
221
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
217
222
|
def snapshots
|
218
|
-
|
219
|
-
Hash[data.map { |snapshot| [snapshot['uuid'], Time.parse(snapshot['date_created'])] }]
|
223
|
+
GandiV5::LiveDNS::Zone::Snapshot.list uuid
|
220
224
|
end
|
221
225
|
|
222
226
|
# Get snapshot from Gandi.
|
223
227
|
# @param uuid [String] the UUID of the snapshot to fetch.
|
224
228
|
# @return [GandiV5::LiveDNS::Zone::Snapshot]
|
225
|
-
# @raise [GandiV5::Error::GandiError
|
229
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
226
230
|
def snapshot(uuid)
|
227
231
|
GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid
|
228
232
|
end
|
229
233
|
|
230
234
|
# Take a snapshot of this zone.
|
231
235
|
# @return [GandiV5::LiveDNS::Zone::Snapshot]
|
232
|
-
# @raise [GandiV5::Error::GandiError
|
236
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
233
237
|
def take_snapshot
|
234
|
-
data = GandiV5.post "#{url}/snapshots"
|
238
|
+
_response, data = GandiV5.post "#{url}/snapshots"
|
235
239
|
snapshot data['uuid']
|
236
240
|
end
|
237
241
|
|
238
242
|
# Update this zone.
|
239
243
|
# @param name [String, #to_s] new name for the zone.
|
240
244
|
# @return [String] The confirmation message from Gandi.
|
241
|
-
# @raise [GandiV5::Error::GandiError
|
245
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
242
246
|
def update(name:)
|
243
|
-
data = GandiV5.patch url, { name: name }.to_json
|
247
|
+
_response, data = GandiV5.patch url, { name: name }.to_json
|
244
248
|
self.name = name
|
245
249
|
data['message']
|
246
250
|
end
|
247
251
|
|
248
252
|
# Delete this zone from Gandi.
|
249
253
|
# @return [nil]
|
250
|
-
# @raise [GandiV5::Error::GandiError
|
254
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
251
255
|
def delete
|
252
256
|
GandiV5.delete url
|
253
257
|
end
|
@@ -255,34 +259,34 @@ class GandiV5
|
|
255
259
|
# Create a new zone.
|
256
260
|
# @param name [String] the name for the created zone.
|
257
261
|
# @param sharing_id [String] the UUID of the account to ceate the zone under.
|
258
|
-
# @return [
|
259
|
-
# @raise [GandiV5::Error::GandiError
|
260
|
-
# TODO: Fetch created zone
|
262
|
+
# @return [GandiV5::LiveDNS::Zone] The created zone.
|
263
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
261
264
|
def self.create(name, sharing_id: nil)
|
262
265
|
params = sharing_id ? { sharing_id: sharing_id } : {}
|
263
266
|
|
264
|
-
|
267
|
+
response, _data = GandiV5.post(
|
265
268
|
url,
|
266
269
|
{ name: name }.to_json,
|
267
270
|
params: params
|
268
271
|
)
|
269
|
-
|
272
|
+
|
273
|
+
fetch response.headers[:location].split('/').last
|
270
274
|
end
|
271
275
|
|
272
276
|
# List the zones.
|
273
277
|
# @return [Array<GandiV5::LiveDNS::Zone>]
|
274
|
-
# @raise [GandiV5::Error::GandiError
|
278
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
275
279
|
def self.list
|
276
|
-
data = GandiV5.get url
|
280
|
+
_response, data = GandiV5.get url
|
277
281
|
data.map { |item| from_gandi item }
|
278
282
|
end
|
279
283
|
|
280
284
|
# Get a zone from Gandi.
|
281
285
|
# @param uuid [String, #to_s] the UUID of the zone to fetch.
|
282
286
|
# @return [GandiV5::LiveDNS::Zone]
|
283
|
-
# @raise [GandiV5::Error::GandiError
|
287
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
284
288
|
def self.fetch(uuid)
|
285
|
-
data = GandiV5.get url(uuid)
|
289
|
+
_response, data = GandiV5.get url(uuid)
|
286
290
|
from_gandi data
|
287
291
|
end
|
288
292
|
|
data/lib/gandi_v5/live_dns.rb
CHANGED
@@ -11,6 +11,26 @@ class GandiV5
|
|
11
11
|
WKS SRV LOC SPF CAA DS SSHFP PTR KEY DNAME TLSA OPENPGPKEY CDS
|
12
12
|
].freeze
|
13
13
|
|
14
|
+
# @see GandiV5::LiveDNS::Domain.fetch
|
15
|
+
def self.domain(fqdn)
|
16
|
+
GandiV5::LiveDNS::Domain.fetch(fqdn)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @see GandiV5::LiveDNS::Domain.list
|
20
|
+
def self.domains
|
21
|
+
GandiV5::LiveDNS::Domain.list
|
22
|
+
end
|
23
|
+
|
24
|
+
# @see GandiV5::LiveDNS::Zone.fetch
|
25
|
+
def self.zone(uuid)
|
26
|
+
GandiV5::LiveDNS::Zone.fetch(uuid)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @see GandiV5::LiveDNS::Zone.list
|
30
|
+
def self.zones
|
31
|
+
GandiV5::LiveDNS::Zone.list
|
32
|
+
end
|
33
|
+
|
14
34
|
# Raise an error if passed type is invalid.
|
15
35
|
# @param type [String] the record type to check.
|
16
36
|
# @return [nil]
|
@@ -57,9 +57,9 @@ class GandiV5
|
|
57
57
|
# Get information about the current authenticated user.
|
58
58
|
# @see https://api.gandi.net/docs/organization#get-v5-organization-user-info
|
59
59
|
# @return [GandiV5::Organization]
|
60
|
-
# @raise [GandiV5::Error::GandiError
|
60
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
61
61
|
def self.fetch
|
62
|
-
data = GandiV5.get "#{BASE}organization/user-info"
|
62
|
+
_response, data = GandiV5.get "#{BASE}organization/user-info"
|
63
63
|
from_gandi data
|
64
64
|
end
|
65
65
|
end
|
data/lib/gandi_v5/version.rb
CHANGED
data/lib/gandi_v5.rb
CHANGED
@@ -26,6 +26,26 @@ require 'securerandom'
|
|
26
26
|
class GandiV5
|
27
27
|
BASE = 'https://api.gandi.net/v5/'
|
28
28
|
|
29
|
+
# @see GandiV5::Domain.fetch
|
30
|
+
def self.domain(fqdn)
|
31
|
+
GandiV5::Domain.fetch(fqdn)
|
32
|
+
end
|
33
|
+
|
34
|
+
# @see GandiV5::Domain.list
|
35
|
+
def self.domains(**params)
|
36
|
+
GandiV5::Domain.list(**params)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @see GandiV5::Email::Mailbox.list
|
40
|
+
def self.mailboxes(fqdn, **params)
|
41
|
+
GandiV5::Email::Mailbox.list(fqdn, **params)
|
42
|
+
end
|
43
|
+
|
44
|
+
# @see GandiV5::Email::Slot.list
|
45
|
+
def self.mailbox_slots(fqdn)
|
46
|
+
GandiV5::Email::Slot.list(fqdn)
|
47
|
+
end
|
48
|
+
|
29
49
|
class << self
|
30
50
|
attr_writer :api_key
|
31
51
|
|
@@ -41,7 +61,7 @@ class GandiV5
|
|
41
61
|
def get(url, **headers)
|
42
62
|
prepare_headers headers, url
|
43
63
|
response = RestClient.get url, **headers
|
44
|
-
parse_response
|
64
|
+
[response, parse_response(response)]
|
45
65
|
rescue RestClient::BadRequest => e
|
46
66
|
handle_bad_request(e)
|
47
67
|
end
|
@@ -59,7 +79,7 @@ class GandiV5
|
|
59
79
|
def delete(url, **headers)
|
60
80
|
prepare_headers headers, url
|
61
81
|
response = RestClient.delete url, **headers
|
62
|
-
parse_response
|
82
|
+
[response, parse_response(response)]
|
63
83
|
rescue RestClient::BadRequest => e
|
64
84
|
handle_bad_request(e)
|
65
85
|
end
|
@@ -79,7 +99,7 @@ class GandiV5
|
|
79
99
|
prepare_headers headers, url
|
80
100
|
headers[:'content-type'] ||= 'application/json'
|
81
101
|
response = RestClient.patch url, payload, **headers
|
82
|
-
parse_response
|
102
|
+
[response, parse_response(response)]
|
83
103
|
rescue RestClient::BadRequest => e
|
84
104
|
handle_bad_request(e)
|
85
105
|
end
|
@@ -99,7 +119,7 @@ class GandiV5
|
|
99
119
|
prepare_headers headers, url
|
100
120
|
headers[:'content-type'] ||= 'application/json'
|
101
121
|
response = RestClient.post url, payload, **headers
|
102
|
-
parse_response
|
122
|
+
[response, parse_response(response)]
|
103
123
|
rescue RestClient::BadRequest => e
|
104
124
|
handle_bad_request(e)
|
105
125
|
end
|
@@ -119,7 +139,7 @@ class GandiV5
|
|
119
139
|
prepare_headers headers, url
|
120
140
|
headers[:'content-type'] ||= 'application/json'
|
121
141
|
response = RestClient.put url, payload, **headers
|
122
|
-
parse_response
|
142
|
+
[response, parse_response(response)]
|
123
143
|
rescue RestClient::BadRequest => e
|
124
144
|
handle_bad_request(e)
|
125
145
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -6,7 +6,7 @@ describe GandiV5::Billing do
|
|
6
6
|
before :each do
|
7
7
|
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Billing', 'info.yaml'))
|
8
8
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/billing/info')
|
9
|
-
.and_return(YAML.load_file(body_fixture))
|
9
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
10
10
|
end
|
11
11
|
|
12
12
|
its('annual_balance') { should eq 123.45 }
|
@@ -25,7 +25,7 @@ describe GandiV5::Billing do
|
|
25
25
|
before :each do
|
26
26
|
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Billing', 'info.yaml'))
|
27
27
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/billing/info/sharing-id')
|
28
|
-
.and_return(YAML.load_file(body_fixture))
|
28
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
29
29
|
end
|
30
30
|
|
31
31
|
its('annual_balance') { should eq 123.45 }
|
@@ -6,7 +6,7 @@ describe GandiV5::Domain::AutoRenew do
|
|
6
6
|
|
7
7
|
it '#disable' do
|
8
8
|
expect(GandiV5).to receive(:patch).with(url, '{"enabled":false}')
|
9
|
-
.and_return('message' => 'Confirmation message.')
|
9
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
10
10
|
expect(subject.disable).to eq 'Confirmation message.'
|
11
11
|
expect(subject.enabled).to be false
|
12
12
|
end
|
@@ -14,7 +14,7 @@ describe GandiV5::Domain::AutoRenew do
|
|
14
14
|
describe '#enable' do
|
15
15
|
it 'Success' do
|
16
16
|
expect(GandiV5).to receive(:patch).with(url, '{"enabled":true,"duration":1,"org_id":"org-uuid"}')
|
17
|
-
.and_return('message' => 'Confirmation message.')
|
17
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
18
18
|
expect(subject.enable(org_id: 'org-uuid', duration: 1)).to eq 'Confirmation message.'
|
19
19
|
expect(subject.enabled).to be true
|
20
20
|
end
|
@@ -36,7 +36,7 @@ describe GandiV5::Domain::AutoRenew do
|
|
36
36
|
describe 'Missing duration' do
|
37
37
|
it 'Uses #duration if present' do
|
38
38
|
expect(GandiV5).to receive(:patch).with(url, '{"enabled":true,"duration":5,"org_id":"org-uuid"}')
|
39
|
-
.and_return('message' => 'Confirmation message.')
|
39
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
40
40
|
expect(subject).to receive(:duration).and_return(5)
|
41
41
|
expect(subject.enable(org_id: 'org-uuid')).to eq 'Confirmation message.'
|
42
42
|
expect(subject.enabled).to be true
|
@@ -44,7 +44,7 @@ describe GandiV5::Domain::AutoRenew do
|
|
44
44
|
|
45
45
|
it 'Uses 1 if #duration not present' do
|
46
46
|
expect(GandiV5).to receive(:patch).with(url, '{"enabled":true,"duration":1,"org_id":"org-uuid"}')
|
47
|
-
.and_return('message' => 'Confirmation message.')
|
47
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
48
48
|
expect(subject.enable(org_id: 'org-uuid')).to eq 'Confirmation message.'
|
49
49
|
expect(subject.enabled).to be true
|
50
50
|
end
|
@@ -53,7 +53,7 @@ describe GandiV5::Domain::AutoRenew do
|
|
53
53
|
describe 'Missing org_id' do
|
54
54
|
it 'Uses #org_id if present' do
|
55
55
|
expect(GandiV5).to receive(:patch).with(url, '{"enabled":true,"duration":1,"org_id":"org-uuid"}')
|
56
|
-
.and_return('message' => 'Confirmation message.')
|
56
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
57
57
|
expect(subject).to receive(:org_id).and_return('org-uuid')
|
58
58
|
expect(subject.enable).to eq 'Confirmation message.'
|
59
59
|
expect(subject.enabled).to be true
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Domain::Availability do
|
4
|
+
describe '.fetch' do
|
5
|
+
let(:body_fixture) do
|
6
|
+
File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_Availability', 'fetch.yaml'))
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'With default values' do
|
10
|
+
subject { described_class.fetch 'example.com' }
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/check', params: { name: 'example.com' })
|
14
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
15
|
+
end
|
16
|
+
|
17
|
+
its('currency') { should eq 'GBP' }
|
18
|
+
its('grid') { should eq 'A' }
|
19
|
+
its('products.size') { should eq 1 }
|
20
|
+
its('products.first.status') { should eq :unavailable }
|
21
|
+
its('products.first.name') { should eq 'example.com' }
|
22
|
+
its('products.first.process') { should eq :create }
|
23
|
+
its('products.first.taxes.size') { should eq 1 }
|
24
|
+
its('products.first.taxes.first.type') { should eq 'service' }
|
25
|
+
its('products.first.taxes.first.rate') { should eq 0 }
|
26
|
+
its('products.first.taxes.first.name') { should eq 'vat' }
|
27
|
+
its('taxes.size') { should eq 1 }
|
28
|
+
its('taxes.first.type') { should eq 'service' }
|
29
|
+
its('taxes.first.rate') { should eq 0 }
|
30
|
+
its('taxes.first.name') { should eq 'vat' }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'Passes optional query params' do
|
34
|
+
%i[country currency duration_unit extension grid lang max_duration period processes sharing_uuid].each do |param|
|
35
|
+
it param.to_s do
|
36
|
+
url = 'https://api.gandi.net/v5/domain/check'
|
37
|
+
expect(GandiV5).to receive(:get).with(url, params: { name: 'example.com', param => 5 }).and_return([nil, {}])
|
38
|
+
described_class.fetch('example.com', param => 5)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Domain::TLD do
|
4
|
+
it '.list' do
|
5
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_TLD', 'list.yaml'))
|
6
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/tlds')
|
7
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
8
|
+
expect(described_class.list.map(&:name)).to match_array %w[a b c]
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.fetch' do
|
12
|
+
subject { described_class.fetch 'name' }
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_TLD', 'fetch.yaml'))
|
16
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/tlds/name')
|
17
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
18
|
+
end
|
19
|
+
|
20
|
+
its('category') { should eq :ccTLD }
|
21
|
+
its('name') { should eq 'eu' }
|
22
|
+
its('lock') { should be false }
|
23
|
+
its('change_owner') { should be true }
|
24
|
+
its('authinfo_for_transfer') { should be true }
|
25
|
+
its('full_tld') { should eq 'eu' }
|
26
|
+
its('corporate') { should be false }
|
27
|
+
its('ext_trade') { should be true }
|
28
|
+
end
|
29
|
+
end
|