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.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +44 -2
  5. data/Guardfile +5 -6
  6. data/README.md +5 -5
  7. data/doc/GandiV5/Billing/Info/Prepaid.html +817 -0
  8. data/doc/GandiV5/Billing/Info.html +641 -0
  9. data/doc/GandiV5/Billing.html +293 -0
  10. data/doc/GandiV5/Data/ClassMethods.html +223 -0
  11. data/doc/GandiV5/Data/Converter/ArrayOf.html +413 -0
  12. data/doc/GandiV5/Data/Converter/Symbol.html +322 -0
  13. data/doc/GandiV5/Data/Converter/Time.html +330 -0
  14. data/doc/GandiV5/Data/Converter.html +433 -0
  15. data/doc/GandiV5/Data.html +785 -0
  16. data/doc/GandiV5/Domain/AutoRenew.html +1237 -0
  17. data/doc/GandiV5/Domain/Availability/Product/Period.html +220 -0
  18. data/doc/GandiV5/Domain/Availability/Product/Price.html +1031 -0
  19. data/doc/GandiV5/Domain/Availability/Product.html +988 -0
  20. data/doc/GandiV5/Domain/Availability/Tax.html +440 -0
  21. data/doc/GandiV5/Domain/Availability.html +1020 -0
  22. data/doc/GandiV5/Domain/Contact.html +4459 -0
  23. data/doc/GandiV5/Domain/Contract.html +520 -0
  24. data/doc/GandiV5/Domain/Dates.html +1313 -0
  25. data/doc/GandiV5/Domain/RenewalInformation.html +1147 -0
  26. data/doc/GandiV5/Domain/RestoreInformation.html +339 -0
  27. data/doc/GandiV5/Domain/SharingSpace.html +437 -0
  28. data/doc/GandiV5/Domain/TLD.html +1565 -0
  29. data/doc/GandiV5/Domain.html +16847 -0
  30. data/doc/GandiV5/Email/Mailbox/Responder.html +1560 -0
  31. data/doc/GandiV5/Email/Mailbox.html +6307 -0
  32. data/doc/GandiV5/Email/Offer.html +514 -0
  33. data/doc/GandiV5/Email/Slot.html +4244 -0
  34. data/doc/GandiV5/Email.html +144 -0
  35. data/doc/GandiV5/Error/GandiError.html +270 -0
  36. data/doc/GandiV5/Error.html +151 -0
  37. data/doc/GandiV5/LiveDNS/Domain.html +2984 -0
  38. data/doc/GandiV5/LiveDNS/RecordSet.html +1593 -0
  39. data/doc/GandiV5/LiveDNS/Zone/Snapshot.html +1556 -0
  40. data/doc/GandiV5/LiveDNS/Zone.html +8891 -0
  41. data/doc/GandiV5/LiveDNS.html +300 -0
  42. data/doc/GandiV5/Organization.html +2341 -0
  43. data/doc/GandiV5.html +1183 -0
  44. data/doc/_index.html +474 -0
  45. data/doc/class_list.html +51 -0
  46. data/doc/css/common.css +1 -0
  47. data/doc/css/full_list.css +58 -0
  48. data/doc/css/style.css +496 -0
  49. data/doc/file.README.html +175 -0
  50. data/doc/file_list.html +56 -0
  51. data/doc/frames.html +17 -0
  52. data/doc/index.html +175 -0
  53. data/doc/js/app.js +303 -0
  54. data/doc/js/full_list.js +216 -0
  55. data/doc/js/jquery.js +4 -0
  56. data/doc/method_list.html +2427 -0
  57. data/doc/top-level-namespace.html +110 -0
  58. data/gandi_v5.gemspec +1 -1
  59. data/lib/gandi_v5/billing.rb +2 -2
  60. data/lib/gandi_v5/data.rb +2 -0
  61. data/lib/gandi_v5/domain/auto_renew.rb +4 -4
  62. data/lib/gandi_v5/domain/availability/product/period.rb +24 -0
  63. data/lib/gandi_v5/domain/availability/product/price.rb +36 -0
  64. data/lib/gandi_v5/domain/availability/product.rb +52 -0
  65. data/lib/gandi_v5/domain/availability/tax.rb +20 -0
  66. data/lib/gandi_v5/domain/availability.rb +49 -0
  67. data/lib/gandi_v5/domain/tld.rb +57 -0
  68. data/lib/gandi_v5/domain.rb +41 -86
  69. data/lib/gandi_v5/email/mailbox/responder.rb +43 -2
  70. data/lib/gandi_v5/email/mailbox.rb +32 -21
  71. data/lib/gandi_v5/email/offer.rb +2 -2
  72. data/lib/gandi_v5/email/slot.rb +42 -16
  73. data/lib/gandi_v5/error/gandi_error.rb +2 -2
  74. data/lib/gandi_v5/live_dns/domain.rb +59 -45
  75. data/lib/gandi_v5/live_dns/zone/snapshot.rb +27 -8
  76. data/lib/gandi_v5/live_dns/zone.rb +63 -59
  77. data/lib/gandi_v5/live_dns.rb +20 -0
  78. data/lib/gandi_v5/organization.rb +2 -2
  79. data/lib/gandi_v5/version.rb +1 -1
  80. data/lib/gandi_v5.rb +25 -5
  81. data/spec/features/domain_spec.rb +1 -1
  82. data/spec/fixtures/bodies/{GandiV5_Domain/availability.yaml → GandiV5_Domain_Availability/fetch.yaml} +0 -0
  83. data/spec/fixtures/bodies/{GandiV5_Domain/tld.yaml → GandiV5_Domain_TLD/fetch.yaml} +0 -0
  84. data/spec/fixtures/bodies/{GandiV5_Domain/tlds.yaml → GandiV5_Domain_TLD/list.yaml} +0 -0
  85. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/{get.yaml → fetch.yaml} +0 -0
  86. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yaml +3 -0
  87. data/spec/units/gandi_v5/billing_spec.rb +2 -2
  88. data/spec/units/gandi_v5/domain/auto_renew_spec.rb +5 -5
  89. data/spec/units/gandi_v5/domain/availability/product/period_spec.rb +4 -0
  90. data/spec/units/gandi_v5/domain/availability/product/price_spec.rb +4 -0
  91. data/spec/units/gandi_v5/domain/availability/product_spec.rb +4 -0
  92. data/spec/units/gandi_v5/domain/availability/tax_spec.rb +4 -0
  93. data/spec/units/gandi_v5/domain/availability_spec.rb +43 -0
  94. data/spec/units/gandi_v5/domain/tld_spec.rb +29 -0
  95. data/spec/units/gandi_v5/domain_spec.rb +89 -81
  96. data/spec/units/gandi_v5/email/mailbox/responder_spec.rb +52 -0
  97. data/spec/units/gandi_v5/email/mailbox_spec.rb +56 -27
  98. data/spec/units/gandi_v5/email/offer_spec.rb +1 -1
  99. data/spec/units/gandi_v5/email/slot_spec.rb +101 -13
  100. data/spec/units/gandi_v5/live_dns/domain_spec.rb +70 -40
  101. data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +32 -3
  102. data/spec/units/gandi_v5/live_dns/zone_spec.rb +68 -50
  103. data/spec/units/gandi_v5/live_dns_spec.rb +24 -0
  104. data/spec/units/gandi_v5/organization_spec.rb +1 -1
  105. data/spec/units/gandi_v5_spec.rb +37 -12
  106. metadata +72 -9
  107. data/TODO.md +0 -29
@@ -30,14 +30,14 @@ describe GandiV5::LiveDNS::Zone do
30
30
  describe '#fetch_records' do
31
31
  it 'All of them' do
32
32
  expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records')
33
- .and_return([])
33
+ .and_return([nil, []])
34
34
 
35
35
  expect(subject.fetch_records).to eq []
36
36
  end
37
37
 
38
38
  it 'All for a name' do
39
39
  expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name')
40
- .and_return([])
40
+ .and_return([nil, []])
41
41
 
42
42
  expect(subject.fetch_records('name')).to eq []
43
43
  end
@@ -46,12 +46,15 @@ describe GandiV5::LiveDNS::Zone do
46
46
  expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT')
47
47
  .and_return(
48
48
  [
49
- {
50
- 'rrset_type' => 'TXT',
51
- 'rrset_name' => 'name',
52
- 'rrset_ttl' => 600,
53
- 'rrset_values' => %w[a b]
54
- }
49
+ nil,
50
+ [
51
+ {
52
+ 'rrset_type' => 'TXT',
53
+ 'rrset_name' => 'name',
54
+ 'rrset_ttl' => 600,
55
+ 'rrset_values' => %w[a b]
56
+ }
57
+ ]
55
58
  ]
56
59
  )
57
60
 
@@ -71,19 +74,19 @@ describe GandiV5::LiveDNS::Zone do
71
74
  describe '#fetch_zone_lines' do
72
75
  it 'All of them' do
73
76
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
74
- expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return('returned')
77
+ expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
75
78
  expect(subject.fetch_zone_lines).to eq 'returned'
76
79
  end
77
80
 
78
81
  it 'All for a name' do
79
82
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
80
- expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return('returned')
83
+ expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
81
84
  expect(subject.fetch_zone_lines('name')).to eq 'returned'
82
85
  end
83
86
 
84
87
  it 'A type for a name' do
85
88
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
86
- expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return('returned')
89
+ expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
87
90
  expect(subject.fetch_zone_lines('name', 'TXT')).to eq 'returned'
88
91
  end
89
92
 
@@ -96,7 +99,7 @@ describe GandiV5::LiveDNS::Zone do
96
99
  it 'Success' do
97
100
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
98
101
  body = '{"rrset_name":"name","rrset_type":"TXT","rrset_ttl":900,"rrset_values":["a","b"]}'
99
- expect(GandiV5).to receive(:post).with(url, body).and_return('message' => 'Confirmation message.')
102
+ expect(GandiV5).to receive(:post).with(url, body).and_return([nil, { 'message' => 'Confirmation message.' }])
100
103
  expect(subject.add_record('name', 'TXT', 900, 'a', 'b')).to eq 'Confirmation message.'
101
104
  end
102
105
 
@@ -122,19 +125,19 @@ describe GandiV5::LiveDNS::Zone do
122
125
  describe '#delete_records' do
123
126
  it 'All of them' do
124
127
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
125
- expect(GandiV5).to receive(:delete).with(url)
128
+ expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
126
129
  subject.delete_records
127
130
  end
128
131
 
129
132
  it 'All for a name' do
130
133
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
131
- expect(GandiV5).to receive(:delete).with(url)
134
+ expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
132
135
  subject.delete_records 'name'
133
136
  end
134
137
 
135
138
  it 'A type for a name' do
136
139
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
137
- expect(GandiV5).to receive(:delete).with(url)
140
+ expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
138
141
  subject.delete_records 'name', 'TXT'
139
142
  end
140
143
 
@@ -152,7 +155,7 @@ describe GandiV5::LiveDNS::Zone do
152
155
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
153
156
  body = '{"items":[{"rrset_name":"name","rrset_ttl":600,"rrset_type":"TXT","rrset_values":["a"]}]}'
154
157
  expect(GandiV5).to receive(:put).with(url, body)
155
- .and_return('message' => 'Confirmation message.')
158
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
156
159
  expect(subject.replace_records(records: records)).to eq 'Confirmation message.'
157
160
  end
158
161
 
@@ -164,7 +167,7 @@ describe GandiV5::LiveDNS::Zone do
164
167
 
165
168
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
166
169
  expect(GandiV5).to receive(:put).with(url, records, 'content-type': 'text/plain')
167
- .and_return('message' => 'Confirmation message.')
170
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
168
171
  expect(subject.replace_records(text: records)).to eq 'Confirmation message.'
169
172
  end
170
173
 
@@ -180,36 +183,41 @@ describe GandiV5::LiveDNS::Zone do
180
183
  end
181
184
  end
182
185
 
183
- it '#replace_records_for' do
184
- url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
185
- body = '{"items":[{"rrset_type":"TXT","rrset_values":["a"]}]}'
186
- expect(GandiV5).to receive(:put).with(url, body)
187
- .and_return('message' => 'Confirmation message.')
188
- records = { type: 'TXT', values: ['a'] }
189
- expect(subject.replace_records_for('name', records)).to eq 'Confirmation message.'
190
- end
186
+ describe '#replace_records_for' do
187
+ it 'Given no type or ttl' do
188
+ url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
189
+ body = '{"items":[{"rrset_type":"TXT","rrset_values":["a"]}]}'
190
+ expect(GandiV5).to receive(:put).with(url, body)
191
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
192
+ records = [{ type: 'TXT', values: ['a'] }]
193
+ expect(subject.replace_records_for('name', records)).to eq 'Confirmation message.'
194
+ end
191
195
 
192
- describe '#replace_??_records_for' do
193
- it '#replace_a_records_for' do
194
- url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/A'
195
- body = '{"rrset_ttl":600,"rrset_values":["192.168.0.1","192.168.0.2"]}'
196
+ it 'Given type and ttl' do
197
+ url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
198
+ body = '{"rrset_values":["a"],"rrset_ttl":600}'
196
199
  expect(GandiV5).to receive(:put).with(url, body)
197
- .and_return('message' => 'Confirmation message.')
198
- expect(subject.replace_a_records_for('name', 600, '192.168.0.1', '192.168.0.2')).to eq 'Confirmation message.'
200
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
201
+ expect(subject.replace_records_for('name', ['a'], type: 'TXT', ttl: 600)).to eq 'Confirmation message.'
199
202
  end
200
203
 
201
- it '#replace_txt_records_for' do
204
+ it 'Given type but no ttl' do
202
205
  url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
203
- body = '{"rrset_ttl":600,"rrset_values":["a","b"]}'
206
+ body = '{"rrset_values":["a"],"rrset_ttl":null}'
204
207
  expect(GandiV5).to receive(:put).with(url, body)
205
- .and_return('message' => 'Confirmation message.')
206
- expect(subject.replace_txt_records_for('name', 600, 'a', 'b')).to eq 'Confirmation message.'
208
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
209
+ expect(subject.replace_records_for('name', ['a'], type: 'TXT')).to eq 'Confirmation message.'
210
+ end
211
+
212
+ it 'Given ttl but no type' do
213
+ expect(GandiV5).to_not receive(:put)
214
+ expect { subject.replace_records_for 'name', 'a', ttl: 600 }.to raise_error ArgumentError, 'missing keyword: type'
207
215
  end
208
216
  end
209
217
 
210
218
  it '#list_domains' do
211
219
  expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/domains')
212
- .and_return([{ 'fqdn' => 'example.com' }])
220
+ .and_return([nil, [{ 'fqdn' => 'example.com' }]])
213
221
  expect(subject.list_domains).to match_array ['example.com']
214
222
  end
215
223
 
@@ -218,7 +226,7 @@ describe GandiV5::LiveDNS::Zone do
218
226
  url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
219
227
  body = '{"zone_uuid":"zone-uuid"}'
220
228
  expect(GandiV5).to receive(:patch).with(url, body)
221
- .and_return('message' => 'Confirmation message.')
229
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
222
230
  expect(subject.attach_domain('example.com')).to eq 'Confirmation message.'
223
231
  end
224
232
 
@@ -226,17 +234,17 @@ describe GandiV5::LiveDNS::Zone do
226
234
  url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
227
235
  body = '{"zone_uuid":"zone-uuid"}'
228
236
  expect(GandiV5).to receive(:patch).with(url, body)
229
- .and_return('message' => 'Confirmation message.')
237
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
230
238
  domain = double GandiV5::LiveDNS::Domain, fqdn: 'example.com'
231
239
  expect(subject.attach_domain(domain)).to eq 'Confirmation message.'
232
240
  end
233
241
  end
234
242
 
235
243
  it '#snapshots' do
236
- returns = [{ 'uuid' => 'snapshot-uuid', 'date_created' => '2016-12-16T16:51:26Z' }]
237
- expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots')
238
- .and_return(returns)
239
- expect(subject.snapshots).to eq('snapshot-uuid' => Time.new(2016, 12, 16, 16, 51, 26, 0))
244
+ returns = double Hash
245
+ expect(GandiV5::LiveDNS::Zone::Snapshot).to receive(:list).with('zone-uuid')
246
+ .and_return(returns)
247
+ expect(subject.snapshots).to be returns
240
248
  end
241
249
 
242
250
  it '#snapshot' do
@@ -249,7 +257,7 @@ describe GandiV5::LiveDNS::Zone do
249
257
  it '#take_snapshot' do
250
258
  returns = double GandiV5::LiveDNS::Zone::Snapshot
251
259
  expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots')
252
- .and_return('message' => 'Confirmation message.', 'uuid' => 'snapshot-uuid')
260
+ .and_return([nil, { 'message' => 'Confirmation message.', 'uuid' => 'snapshot-uuid' }])
253
261
  expect(GandiV5::LiveDNS::Zone::Snapshot).to receive(:fetch).with('zone-uuid', 'snapshot-uuid')
254
262
  .and_return(returns)
255
263
  expect(subject.take_snapshot).to be returns
@@ -258,7 +266,7 @@ describe GandiV5::LiveDNS::Zone do
258
266
  it '#update' do
259
267
  body = '{"name":"new-name"}'
260
268
  expect(GandiV5).to receive(:patch).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid', body)
261
- .and_return('message' => 'Confirmation message.')
269
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
262
270
  expect(subject.update(name: 'new-name')).to eq 'Confirmation message.'
263
271
  end
264
272
 
@@ -268,19 +276,29 @@ describe GandiV5::LiveDNS::Zone do
268
276
  end
269
277
 
270
278
  describe '.create' do
279
+ let(:created_response) do
280
+ double(
281
+ RestClient::Response,
282
+ headers: { location: 'https://dns.api.gandi.net/v5/zones/created-zone-uuid' }
283
+ )
284
+ end
285
+ let(:created_zone) { double GandiV5::LiveDNS::Zone }
286
+
271
287
  it 'With sharing-id' do
272
288
  body = '{"name":"Name"}'
273
289
  params = { sharing_id: 'sharing-id' }
274
290
  expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones', body, params: params)
275
- .and_return('message' => 'Confirmation message.')
276
- expect(described_class.create('Name', sharing_id: 'sharing-id')).to eq 'Confirmation message.'
291
+ .and_return([created_response, { 'message' => 'Confirmation message.' }])
292
+ expect(described_class).to receive(:fetch).with('created-zone-uuid').and_return(created_zone)
293
+ expect(described_class.create('Name', sharing_id: 'sharing-id')).to be created_zone
277
294
  end
278
295
 
279
296
  it 'Without sharing-id' do
280
297
  body = '{"name":"Name"}'
281
298
  expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones', body, params: {})
282
- .and_return('message' => 'Confirmation message.')
283
- expect(described_class.create('Name')).to eq 'Confirmation message.'
299
+ .and_return([created_response, { 'message' => 'Confirmation message.' }])
300
+ expect(described_class).to receive(:fetch).with('created-zone-uuid').and_return(created_zone)
301
+ expect(described_class.create('Name')).to be created_zone
284
302
  end
285
303
  end
286
304
 
@@ -290,7 +308,7 @@ describe GandiV5::LiveDNS::Zone do
290
308
  before :each do
291
309
  body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', 'list.yaml'))
292
310
  expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones')
293
- .and_return(YAML.load_file(body_fixture))
311
+ .and_return([nil, YAML.load_file(body_fixture)])
294
312
  end
295
313
 
296
314
  its('count') { should eq 1 }
@@ -312,7 +330,7 @@ describe GandiV5::LiveDNS::Zone do
312
330
  before :each do
313
331
  body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', 'get.yaml'))
314
332
  expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid')
315
- .and_return(YAML.load_file(body_fixture))
333
+ .and_return([nil, YAML.load_file(body_fixture)])
316
334
  end
317
335
 
318
336
  its('uuid') { should eq 'zone-uuid' }
@@ -1,6 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe GandiV5::LiveDNS do
4
+ it '.domain' do
5
+ returns = double GandiV5::LiveDNS::Domain
6
+ expect(GandiV5::LiveDNS::Domain).to receive(:fetch).with('example.com').and_return(returns)
7
+ expect(described_class.domain('example.com')).to be returns
8
+ end
9
+
10
+ it '.domains' do
11
+ returns = double Array
12
+ expect(GandiV5::LiveDNS::Domain).to receive(:list).and_return(returns)
13
+ expect(described_class.domains).to be returns
14
+ end
15
+
16
+ it '.zone' do
17
+ returns = double GandiV5::LiveDNS::Zone
18
+ expect(GandiV5::LiveDNS::Zone).to receive(:fetch).with('zone-uuid').and_return(returns)
19
+ expect(described_class.zone('zone-uuid')).to be returns
20
+ end
21
+
22
+ it '.zones' do
23
+ returns = double Array
24
+ expect(GandiV5::LiveDNS::Zone).to receive(:list).and_return(returns)
25
+ expect(described_class.zones).to be returns
26
+ end
27
+
4
28
  describe '.require_valid_record_type' do
5
29
  it 'Does nothing for valid type' do
6
30
  expect { described_class.require_valid_record_type 'A' }.to_not raise_error
@@ -7,7 +7,7 @@ describe GandiV5::Organization do
7
7
  subject { described_class.fetch }
8
8
  before :each do
9
9
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/organization/user-info')
10
- .and_return(YAML.load_file(File.join(body_fixtures, 'get.yaml')))
10
+ .and_return([nil, YAML.load_file(File.join(body_fixtures, 'get.yaml'))])
11
11
  end
12
12
 
13
13
  its('uuid') { should eq 'organization-uuid' }
@@ -3,6 +3,30 @@
3
3
  describe GandiV5 do
4
4
  let(:api_key) { ENV['GANDI_API_KEY'] }
5
5
 
6
+ it '.domain' do
7
+ returns = double GandiV5::Domain
8
+ expect(GandiV5::Domain).to receive(:fetch).with('example.com').and_return(returns)
9
+ expect(described_class.domain('example.com')).to be returns
10
+ end
11
+
12
+ it '.domains' do
13
+ returns = double Array
14
+ expect(GandiV5::Domain).to receive(:list).with(param: :value).and_return(returns)
15
+ expect(described_class.domains(param: :value)).to be returns
16
+ end
17
+
18
+ it '.mailboxes' do
19
+ returns = double Array
20
+ expect(GandiV5::Email::Mailbox).to receive(:list).with('example.com', param: :value).and_return(returns)
21
+ expect(described_class.mailboxes('example.com', param: :value)).to be returns
22
+ end
23
+
24
+ it '.mailbox_slots' do
25
+ returns = double Array
26
+ expect(GandiV5::Email::Slot).to receive(:list).with('example.com').and_return(returns)
27
+ expect(described_class.mailbox_slots('example.com')).to be returns
28
+ end
29
+
6
30
  it 'Has a version' do
7
31
  expect(defined?(GandiV5::VERSION)).to eq 'constant'
8
32
  expect(GandiV5::VERSION).to_not be_empty
@@ -30,7 +54,7 @@ describe GandiV5 do
30
54
  response = double RestClient::Response, body: response_data.to_json, headers: { content_type: 'application/json' }
31
55
  expect(described_class).to receive(:prepare_headers)
32
56
  expect(RestClient).to receive(method).with('url', hash_including(accept: 'application/json')).and_return(response)
33
- expect(described_class.send(method, 'url', accept: 'application/json')).to eq response_data
57
+ expect(described_class.send(method, 'url', accept: 'application/json')).to match_array [response, response_data]
34
58
  end
35
59
 
36
60
  it 'As text' do
@@ -38,26 +62,26 @@ describe GandiV5 do
38
62
  response = double RestClient::Response, body: response_data, headers: { content_type: 'text/plain' }
39
63
  expect(described_class).to receive(:prepare_headers)
40
64
  expect(RestClient).to receive(method).with('url', hash_including(accept: 'text/plain')).and_return(response)
41
- expect(described_class.send(method, 'url', accept: 'text/plain')).to eq response_data
65
+ expect(described_class.send(method, 'url', accept: 'text/plain')).to match_array [response, response_data]
42
66
  end
43
67
 
44
68
  it 'Passes request headers' do
45
69
  expect(described_class).to receive(:prepare_headers)
46
70
  expect(described_class).to receive(:parse_response)
47
71
  expect(RestClient).to receive(method).with(anything, header: 'value')
48
- expect(described_class.send(method, 'url', header: 'value')).to be_nil
72
+ expect(described_class.send(method, 'url', header: 'value')).to match_array [nil, nil]
49
73
  end
50
74
 
51
75
  it 'Adds authentication header' do
52
76
  expect(RestClient).to receive(method).with(anything, hash_including(Authorization: 'Apikey abdce12345'))
53
77
  expect(described_class).to receive(:parse_response)
54
- expect(described_class.send(method, 'https://api.gandi.net/v5/')).to be_nil
78
+ expect(described_class.send(method, 'https://api.gandi.net/v5/')).to match_array [nil, nil]
55
79
  end
56
80
 
57
81
  it 'Default accept header' do
58
82
  expect(RestClient).to receive(method).with(any_args, hash_including(accept: 'application/json'))
59
83
  expect(described_class).to receive(:parse_response)
60
- expect(described_class.send(method, 'https://api.gandi.net/v5/')).to be_nil
84
+ expect(described_class.send(method, 'https://api.gandi.net/v5/')).to match_array [nil, nil]
61
85
  end
62
86
 
63
87
  it 'Converts a 406 (bad request) exception' do
@@ -78,7 +102,8 @@ describe GandiV5 do
78
102
  expect(described_class).to receive(:prepare_headers)
79
103
  expect(RestClient).to receive(method).with('url', payload, hash_including(accept: 'application/json'))
80
104
  .and_return(response)
81
- expect(described_class.send(method, 'url', payload, accept: 'application/json')).to eq response_data
105
+ expect(described_class.send(method, 'url', payload, accept: 'application/json'))
106
+ .to match_array [response, response_data]
82
107
  end
83
108
 
84
109
  it 'As text' do
@@ -87,39 +112,39 @@ describe GandiV5 do
87
112
  expect(described_class).to receive(:prepare_headers)
88
113
  expect(RestClient).to receive(method).with('url', payload, hash_including(accept: 'text/plain'))
89
114
  .and_return(response)
90
- expect(described_class.send(method, 'url', payload, accept: 'text/plain')).to eq response_data
115
+ expect(described_class.send(method, 'url', payload, accept: 'text/plain')).to match_array [response, response_data]
91
116
  end
92
117
 
93
118
  it 'Passes payload' do
94
119
  expect(described_class).to receive(:prepare_headers)
95
120
  expect(described_class).to receive(:parse_response)
96
121
  expect(RestClient).to receive(method).with(anything, payload, any_args)
97
- expect(described_class.send(method, 'url', payload)).to be_nil
122
+ expect(described_class.send(method, 'url', payload)).to match_array [nil, nil]
98
123
  end
99
124
 
100
125
  it 'Passes request headers' do
101
126
  expect(described_class).to receive(:prepare_headers)
102
127
  expect(described_class).to receive(:parse_response)
103
128
  expect(RestClient).to receive(method).with(any_args, hash_including(header: 'value'))
104
- expect(described_class.send(method, 'url', payload, header: 'value')).to be_nil
129
+ expect(described_class.send(method, 'url', payload, header: 'value')).to match_array [nil, nil]
105
130
  end
106
131
 
107
132
  it 'Adds content type header' do
108
133
  expect(RestClient).to receive(method).with(any_args, hash_including('content-type': 'application/json'))
109
134
  expect(described_class).to receive(:parse_response)
110
- expect(described_class.send(method, 'https://api.gandi.net/v5/', payload)).to be_nil
135
+ expect(described_class.send(method, 'https://api.gandi.net/v5/', payload)).to match_array [nil, nil]
111
136
  end
112
137
 
113
138
  it 'Adds authentication header' do
114
139
  expect(RestClient).to receive(method).with(any_args, hash_including(Authorization: 'Apikey abdce12345'))
115
140
  expect(described_class).to receive(:parse_response)
116
- expect(described_class.send(method, 'https://api.gandi.net/v5/', payload)).to be_nil
141
+ expect(described_class.send(method, 'https://api.gandi.net/v5/', payload)).to match_array [nil, nil]
117
142
  end
118
143
 
119
144
  it 'Default accept header' do
120
145
  expect(RestClient).to receive(method).with(any_args, hash_including(accept: 'application/json'))
121
146
  expect(described_class).to receive(:parse_response)
122
- expect(described_class.send(method, 'https://api.gandi.net/v5/', payload)).to be_nil
147
+ expect(described_class.send(method, 'https://api.gandi.net/v5/', payload)).to match_array [nil, nil]
123
148
  end
124
149
 
125
150
  it 'Converts a 406 (bad request) exception' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gandi_v5
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gauld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-10 00:00:00.000000000 Z
11
+ date: 2019-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -188,14 +188,14 @@ dependencies:
188
188
  requirements:
189
189
  - - "~>"
190
190
  - !ruby/object:Gem::Version
191
- version: '0.67'
191
+ version: '0.73'
192
192
  type: :development
193
193
  prerelease: false
194
194
  version_requirements: !ruby/object:Gem::Requirement
195
195
  requirements:
196
196
  - - "~>"
197
197
  - !ruby/object:Gem::Version
198
- version: '0.67'
198
+ version: '0.73'
199
199
  - !ruby/object:Gem::Dependency
200
200
  name: rubocop-performance
201
201
  requirement: !ruby/object:Gem::Requirement
@@ -284,8 +284,58 @@ files:
284
284
  - LICENSE.md
285
285
  - README.md
286
286
  - Rakefile
287
- - TODO.md
288
287
  - bin/console
288
+ - doc/GandiV5.html
289
+ - doc/GandiV5/Billing.html
290
+ - doc/GandiV5/Billing/Info.html
291
+ - doc/GandiV5/Billing/Info/Prepaid.html
292
+ - doc/GandiV5/Data.html
293
+ - doc/GandiV5/Data/ClassMethods.html
294
+ - doc/GandiV5/Data/Converter.html
295
+ - doc/GandiV5/Data/Converter/ArrayOf.html
296
+ - doc/GandiV5/Data/Converter/Symbol.html
297
+ - doc/GandiV5/Data/Converter/Time.html
298
+ - doc/GandiV5/Domain.html
299
+ - doc/GandiV5/Domain/AutoRenew.html
300
+ - doc/GandiV5/Domain/Availability.html
301
+ - doc/GandiV5/Domain/Availability/Product.html
302
+ - doc/GandiV5/Domain/Availability/Product/Period.html
303
+ - doc/GandiV5/Domain/Availability/Product/Price.html
304
+ - doc/GandiV5/Domain/Availability/Tax.html
305
+ - doc/GandiV5/Domain/Contact.html
306
+ - doc/GandiV5/Domain/Contract.html
307
+ - doc/GandiV5/Domain/Dates.html
308
+ - doc/GandiV5/Domain/RenewalInformation.html
309
+ - doc/GandiV5/Domain/RestoreInformation.html
310
+ - doc/GandiV5/Domain/SharingSpace.html
311
+ - doc/GandiV5/Domain/TLD.html
312
+ - doc/GandiV5/Email.html
313
+ - doc/GandiV5/Email/Mailbox.html
314
+ - doc/GandiV5/Email/Mailbox/Responder.html
315
+ - doc/GandiV5/Email/Offer.html
316
+ - doc/GandiV5/Email/Slot.html
317
+ - doc/GandiV5/Error.html
318
+ - doc/GandiV5/Error/GandiError.html
319
+ - doc/GandiV5/LiveDNS.html
320
+ - doc/GandiV5/LiveDNS/Domain.html
321
+ - doc/GandiV5/LiveDNS/RecordSet.html
322
+ - doc/GandiV5/LiveDNS/Zone.html
323
+ - doc/GandiV5/LiveDNS/Zone/Snapshot.html
324
+ - doc/GandiV5/Organization.html
325
+ - doc/_index.html
326
+ - doc/class_list.html
327
+ - doc/css/common.css
328
+ - doc/css/full_list.css
329
+ - doc/css/style.css
330
+ - doc/file.README.html
331
+ - doc/file_list.html
332
+ - doc/frames.html
333
+ - doc/index.html
334
+ - doc/js/app.js
335
+ - doc/js/full_list.js
336
+ - doc/js/jquery.js
337
+ - doc/method_list.html
338
+ - doc/top-level-namespace.html
289
339
  - gandi_v5.gemspec
290
340
  - lib/gandi_v5.rb
291
341
  - lib/gandi_v5/billing.rb
@@ -298,12 +348,18 @@ files:
298
348
  - lib/gandi_v5/data/converter/time.rb
299
349
  - lib/gandi_v5/domain.rb
300
350
  - lib/gandi_v5/domain/auto_renew.rb
351
+ - lib/gandi_v5/domain/availability.rb
352
+ - lib/gandi_v5/domain/availability/product.rb
353
+ - lib/gandi_v5/domain/availability/product/period.rb
354
+ - lib/gandi_v5/domain/availability/product/price.rb
355
+ - lib/gandi_v5/domain/availability/tax.rb
301
356
  - lib/gandi_v5/domain/contact.rb
302
357
  - lib/gandi_v5/domain/contract.rb
303
358
  - lib/gandi_v5/domain/dates.rb
304
359
  - lib/gandi_v5/domain/renewal_information.rb
305
360
  - lib/gandi_v5/domain/restore_information.rb
306
361
  - lib/gandi_v5/domain/sharing_space.rb
362
+ - lib/gandi_v5/domain/tld.rb
307
363
  - lib/gandi_v5/email.rb
308
364
  - lib/gandi_v5/email/mailbox.rb
309
365
  - lib/gandi_v5/email/mailbox/responder.rb
@@ -324,14 +380,14 @@ files:
324
380
  - spec/features/livedns_zone_spec.rb
325
381
  - spec/features/mailbox_spec.rb
326
382
  - spec/fixtures/bodies/GandiV5_Billing/info.yaml
327
- - spec/fixtures/bodies/GandiV5_Domain/availability.yaml
328
383
  - spec/fixtures/bodies/GandiV5_Domain/fetch_contacts.yaml
329
384
  - spec/fixtures/bodies/GandiV5_Domain/get.yaml
330
385
  - spec/fixtures/bodies/GandiV5_Domain/list.yaml
331
386
  - spec/fixtures/bodies/GandiV5_Domain/renewal_info.yaml
332
387
  - spec/fixtures/bodies/GandiV5_Domain/restore_info.yaml
333
- - spec/fixtures/bodies/GandiV5_Domain/tld.yaml
334
- - spec/fixtures/bodies/GandiV5_Domain/tlds.yaml
388
+ - spec/fixtures/bodies/GandiV5_Domain_Availability/fetch.yaml
389
+ - spec/fixtures/bodies/GandiV5_Domain_TLD/fetch.yaml
390
+ - spec/fixtures/bodies/GandiV5_Domain_TLD/list.yaml
335
391
  - spec/fixtures/bodies/GandiV5_Email_Mailbox/get.yaml
336
392
  - spec/fixtures/bodies/GandiV5_Email_Mailbox/list.yaml
337
393
  - spec/fixtures/bodies/GandiV5_Email_Slot/get.yaml
@@ -340,7 +396,8 @@ files:
340
396
  - spec/fixtures/bodies/GandiV5_LiveDNS_Domain/list.yaml
341
397
  - spec/fixtures/bodies/GandiV5_LiveDNS_Zone/get.yaml
342
398
  - spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yaml
343
- - spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/get.yaml
399
+ - spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/fetch.yaml
400
+ - spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yaml
344
401
  - spec/fixtures/bodies/GandiV5_Organization/get.yaml
345
402
  - spec/fixtures/vcr/Domain_features/List_domains.yml
346
403
  - spec/fixtures/vcr/Domain_features/Renew_domain.yml
@@ -360,12 +417,18 @@ files:
360
417
  - spec/units/gandi_v5/data/converter_spec.rb
361
418
  - spec/units/gandi_v5/data_spec.rb
362
419
  - spec/units/gandi_v5/domain/auto_renew_spec.rb
420
+ - spec/units/gandi_v5/domain/availability/product/period_spec.rb
421
+ - spec/units/gandi_v5/domain/availability/product/price_spec.rb
422
+ - spec/units/gandi_v5/domain/availability/product_spec.rb
423
+ - spec/units/gandi_v5/domain/availability/tax_spec.rb
424
+ - spec/units/gandi_v5/domain/availability_spec.rb
363
425
  - spec/units/gandi_v5/domain/contact_spec.rb
364
426
  - spec/units/gandi_v5/domain/contract_spec.rb
365
427
  - spec/units/gandi_v5/domain/dates_spec.rb
366
428
  - spec/units/gandi_v5/domain/renewal_information_spec.rb
367
429
  - spec/units/gandi_v5/domain/restore_information_spec.rb
368
430
  - spec/units/gandi_v5/domain/sharing_space_spec.rb
431
+ - spec/units/gandi_v5/domain/tld_spec.rb
369
432
  - spec/units/gandi_v5/domain_spec.rb
370
433
  - spec/units/gandi_v5/email/mailbox/responder_spec.rb
371
434
  - spec/units/gandi_v5/email/mailbox_spec.rb
data/TODO.md DELETED
@@ -1,29 +0,0 @@
1
- # To Do List
2
-
3
- * Domain:
4
- * [ ] .restore_information - test when I have a restorable domain
5
- * [ ] .create - return created domain
6
- * [ ] .availability - return a new type of object
7
- * [ ] .tld * return a new type of object
8
- * Email Mailbox:
9
- * [ ] .create - check type is valid
10
- * [ ] .create - check a slot is available
11
- * [ ] .create - fetch created mailbox
12
- * Email Slot:
13
- * [ ] #delete - check for inactiveness
14
- * [ ] #delete - check for refundableness
15
- * [ ] .create - fetch created slot
16
- * LiveDNS Domain:
17
- * [ ] #replace_??_records_for - incorporate into #replace_records_for
18
- * [ ] Make record type a symbol
19
- * [ ] Add #zone method
20
- * LiveDNS Zone:
21
- * [ ] .create - fetch created zone
22
- * [ ] #replace_??_records_for - incorporate into #replace_records_for
23
- * [ ] Make record type a symbol
24
- * [ ] Add #zone method
25
- * LiveDNS Zone Snapshot:
26
- * [ ] Move method for getting listing to here
27
- * Gandi updates from 2019-05-23:
28
- * [ ] Domain API: Domain hosts (glue records)
29
- * [ ] Domain API: Domain nameservers