gandi_v5 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +1 -1
  4. data/.travis.yml +9 -0
  5. data/CHANGELOG.md +15 -0
  6. data/FUNDING.yml +10 -0
  7. data/README.md +7 -17
  8. data/gandi_v5.gemspec +3 -2
  9. data/lib/gandi_v5.rb +24 -10
  10. data/lib/gandi_v5/billing.rb +0 -2
  11. data/lib/gandi_v5/billing/info.rb +0 -2
  12. data/lib/gandi_v5/data.rb +0 -2
  13. data/lib/gandi_v5/data/converter.rb +0 -4
  14. data/lib/gandi_v5/domain.rb +159 -17
  15. data/lib/gandi_v5/domain/availability.rb +0 -3
  16. data/lib/gandi_v5/domain/availability/product.rb +0 -3
  17. data/lib/gandi_v5/domain/live_dns.rb +42 -0
  18. data/lib/gandi_v5/domain/renewal_information.rb +0 -3
  19. data/lib/gandi_v5/email.rb +0 -4
  20. data/lib/gandi_v5/email/forward.rb +108 -0
  21. data/lib/gandi_v5/email/mailbox.rb +0 -2
  22. data/lib/gandi_v5/error.rb +0 -2
  23. data/lib/gandi_v5/live_dns.rb +0 -4
  24. data/lib/gandi_v5/live_dns/domain.rb +1 -144
  25. data/lib/gandi_v5/live_dns/has_zone_records.rb +153 -0
  26. data/lib/gandi_v5/live_dns/zone.rb +1 -146
  27. data/lib/gandi_v5/organization.rb +28 -5
  28. data/lib/gandi_v5/version.rb +1 -1
  29. data/spec/.rubocop.yml +1 -1
  30. data/spec/features/domain_spec.rb +1 -1
  31. data/spec/fixtures/bodies/GandiV5_Billing/{info.yaml → info.yml} +0 -0
  32. data/spec/fixtures/bodies/GandiV5_Domain/{get.yaml → fetch.yml} +0 -0
  33. data/spec/fixtures/bodies/GandiV5_Domain/{fetch_contacts.yaml → fetch_contacts.yml} +0 -0
  34. data/spec/fixtures/bodies/GandiV5_Domain/fetch_glue_records.yml +7 -0
  35. data/spec/fixtures/bodies/GandiV5_Domain/fetch_livedns.yml +6 -0
  36. data/spec/fixtures/bodies/GandiV5_Domain/fetch_name_servers.yml +2 -0
  37. data/spec/fixtures/bodies/GandiV5_Domain/{renewal_info.yaml → fetch_renewal_info.yml} +0 -3
  38. data/spec/fixtures/bodies/GandiV5_Domain/{restore_info.yaml → fetch_restore_info.yml} +0 -0
  39. data/spec/fixtures/bodies/GandiV5_Domain/{list.yaml → list.yml} +1 -0
  40. data/spec/fixtures/bodies/GandiV5_Domain_Availability/{fetch.yaml → fetch.yml} +0 -0
  41. data/spec/fixtures/bodies/GandiV5_Domain_TLD/{fetch.yaml → fetch.yml} +0 -0
  42. data/spec/fixtures/bodies/GandiV5_Domain_TLD/{list.yaml → list.yml} +0 -0
  43. data/spec/fixtures/bodies/GandiV5_Email_Forward/list.yml +6 -0
  44. data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{get.yaml → fetch.yml} +0 -0
  45. data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{list.yaml → list.yml} +0 -0
  46. data/spec/fixtures/bodies/GandiV5_Email_Slot/{get.yaml → fetch.yml} +0 -0
  47. data/spec/fixtures/bodies/GandiV5_Email_Slot/{list.yaml → list.yml} +0 -0
  48. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{get.yaml → fetch.yml} +0 -0
  49. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{list.yaml → list.yml} +0 -0
  50. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/{get.yaml → fetch.yml} +0 -0
  51. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/{list.yaml → list.yml} +0 -0
  52. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/{fetch.yaml → fetch.yml} +0 -0
  53. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/{list.yaml → list.yml} +0 -0
  54. data/spec/fixtures/bodies/GandiV5_Organization/{get.yaml → fetch.yml} +0 -0
  55. data/spec/fixtures/bodies/GandiV5_Organization/list.yml +7 -0
  56. data/spec/fixtures/vcr/Domain_features/List_domains.yml +2 -1
  57. data/spec/spec_helper.rb +2 -2
  58. data/spec/units/gandi_v5/billing_spec.rb +2 -2
  59. data/spec/units/gandi_v5/domain/availability_spec.rb +1 -1
  60. data/spec/units/gandi_v5/domain/live_dns_spec.rb +45 -0
  61. data/spec/units/gandi_v5/domain/tld_spec.rb +2 -2
  62. data/spec/units/gandi_v5/domain_spec.rb +241 -22
  63. data/spec/units/gandi_v5/email/forward_spec.rb +121 -0
  64. data/spec/units/gandi_v5/email/mailbox_spec.rb +3 -3
  65. data/spec/units/gandi_v5/email/slot_spec.rb +3 -3
  66. data/spec/units/gandi_v5/live_dns/domain_spec.rb +3 -3
  67. data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +2 -2
  68. data/spec/units/gandi_v5/live_dns/zone_spec.rb +2 -2
  69. data/spec/units/gandi_v5/organization_spec.rb +38 -1
  70. metadata +51 -77
  71. data/doc/GandiV5.html +0 -1183
  72. data/doc/GandiV5/Billing.html +0 -293
  73. data/doc/GandiV5/Billing/Info.html +0 -641
  74. data/doc/GandiV5/Billing/Info/Prepaid.html +0 -817
  75. data/doc/GandiV5/Data.html +0 -785
  76. data/doc/GandiV5/Data/ClassMethods.html +0 -223
  77. data/doc/GandiV5/Data/Converter.html +0 -433
  78. data/doc/GandiV5/Data/Converter/ArrayOf.html +0 -413
  79. data/doc/GandiV5/Data/Converter/Symbol.html +0 -322
  80. data/doc/GandiV5/Data/Converter/Time.html +0 -330
  81. data/doc/GandiV5/Domain.html +0 -16847
  82. data/doc/GandiV5/Domain/AutoRenew.html +0 -1237
  83. data/doc/GandiV5/Domain/Availability.html +0 -1020
  84. data/doc/GandiV5/Domain/Availability/Product.html +0 -988
  85. data/doc/GandiV5/Domain/Availability/Product/Period.html +0 -220
  86. data/doc/GandiV5/Domain/Availability/Product/Price.html +0 -1031
  87. data/doc/GandiV5/Domain/Availability/Tax.html +0 -440
  88. data/doc/GandiV5/Domain/Contact.html +0 -4459
  89. data/doc/GandiV5/Domain/Contract.html +0 -520
  90. data/doc/GandiV5/Domain/Dates.html +0 -1313
  91. data/doc/GandiV5/Domain/RenewalInformation.html +0 -1147
  92. data/doc/GandiV5/Domain/RestoreInformation.html +0 -339
  93. data/doc/GandiV5/Domain/SharingSpace.html +0 -437
  94. data/doc/GandiV5/Domain/TLD.html +0 -1565
  95. data/doc/GandiV5/Email.html +0 -144
  96. data/doc/GandiV5/Email/Mailbox.html +0 -6307
  97. data/doc/GandiV5/Email/Mailbox/Responder.html +0 -1560
  98. data/doc/GandiV5/Email/Offer.html +0 -514
  99. data/doc/GandiV5/Email/Slot.html +0 -4244
  100. data/doc/GandiV5/Error.html +0 -151
  101. data/doc/GandiV5/Error/GandiError.html +0 -270
  102. data/doc/GandiV5/LiveDNS.html +0 -300
  103. data/doc/GandiV5/LiveDNS/Domain.html +0 -2984
  104. data/doc/GandiV5/LiveDNS/RecordSet.html +0 -1593
  105. data/doc/GandiV5/LiveDNS/Zone.html +0 -8891
  106. data/doc/GandiV5/LiveDNS/Zone/Snapshot.html +0 -1556
  107. data/doc/GandiV5/Organization.html +0 -2341
  108. data/doc/_index.html +0 -474
  109. data/doc/class_list.html +0 -51
  110. data/doc/css/common.css +0 -1
  111. data/doc/css/full_list.css +0 -58
  112. data/doc/css/style.css +0 -496
  113. data/doc/file.README.html +0 -175
  114. data/doc/file_list.html +0 -56
  115. data/doc/frames.html +0 -17
  116. data/doc/index.html +0 -175
  117. data/doc/js/app.js +0 -303
  118. data/doc/js/full_list.js +0 -216
  119. data/doc/js/jquery.js +0 -4
  120. data/doc/method_list.html +0 -2427
  121. data/doc/top-level-namespace.html +0 -110
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d77e35cfcd8e9488848bc9a988b8b2e79dea364fc014f0ae6e07335adb0e0b95
4
- data.tar.gz: aa3a9b67338ccd330286db829bd593b77a423372175495e30c8098da95713495
3
+ metadata.gz: ef84fa55ae8d79f2d6fa178db059e4130ff8ae9ba2eb5f5886a57b9f965d8b48
4
+ data.tar.gz: b5bc9448754bf08ab28c1e3235d01929a6edf3b82f00dbdf935b58d863035de1
5
5
  SHA512:
6
- metadata.gz: ca79e34d1c4ca0b1cc2b54c58c27b6b7326d5a0568f201229270a89487d641221f4b26deac15494a22869ef91e9e5efe00d50b7652db6249febd31f5abf78514
7
- data.tar.gz: 4e87456cd5fde75b7ba2c9fc4076da647c311cfa25ed35e8f85d5406e3766fdd2197210d86e5f81d323c9364cfe79e856e0c7f562a550ff8e8684513ef9f73f8
6
+ metadata.gz: 90083b929123d60702880dc1fbaa7500c972f38ce1134dbb031d1e5585cad63fbe7265ee38075e5329e2e125f4b441ef0bc02da79137444df4ea27c999c1fa26
7
+ data.tar.gz: 536d1dae15301728cfda7df6c556913e75025d90f801c5748da598716b887bd0e8c4d25c2f0226ea25d9bab02fa9a3f185d64a5cf9a31694cb21a1ea5f8ac264
data/.gitignore CHANGED
@@ -16,6 +16,7 @@ InstalledFiles
16
16
  lib/bundler/man
17
17
  pkg
18
18
  rdoc
19
+ doc
19
20
  spec/reports
20
21
  test/tmp
21
22
  test/version_tmp
@@ -7,7 +7,7 @@ Gemspec/RequiredRubyVersion:
7
7
  Metrics/AbcSize:
8
8
  Max: 20
9
9
  Metrics/ClassLength:
10
- Max: 200
10
+ Max: 250
11
11
  Metrics/LineLength:
12
12
  Max: 100
13
13
  Metrics/MethodLength:
@@ -4,6 +4,7 @@ rvm:
4
4
  - 2.6.1
5
5
  - 2.6.2
6
6
  - 2.6.3
7
+ - 2.6.4
7
8
  gemfile:
8
9
  - Gemfile
9
10
  branches:
@@ -12,10 +13,18 @@ branches:
12
13
  - staging
13
14
  - /gh(?:\d)+(?:-.+)?/
14
15
  - /dev_ver_\d+\.\d+/
16
+ env:
17
+ global:
18
+ # CC_TEST_REPORTER_ID for reporting test coverage to code climate
19
+ - secure: "C3AcK+/2A4h2+ZayJXc89EQp76o8/2RL03PdtVjWPI6cfBSwN174ImWSdIcs6+Bjv8GH+bADsM4epkTjI7H24wh80If/4jAZJMB6LsAxVC3rZVx2UfDghp1Lwcy6BkNx4VVXMQJUR4rA8fXNd1l6n2a72RbPhTaGYxggw+yiKYNjj5m/u3HWPzTQ9wIx/rLzb2shQU1P9tDX4eRqJixYsd8LvStvXewUKlTQSaxNczzfcSOmeJrrytJGuPQxgBx67hlN40cs84oEbhndjlekZRwYepsRcan9umJEDHnE+k0wLlz/vb2cshYp5tdcfkqspaEhUSV7Vr7ZQNIppI3XyY1hs/pTYc2Vytp3OiY0EXBjKRmiHcnmA8EIkrV9i4OSt6Af3EQJaYU56a0BCaEqzRoQJWOZDS8bVowuO4rY8/xINQBwTojIYAplI/vqX/7xvlRbzIgeWdpvQipPC01d2JtmI/5D1FdGWtzYcDCTRTbHyWmjhr7Jt8qEDMFkbpkcAQiS61baEQ0p4CxaLYm/lpPco1U3e/gMOb/EXDhOrF1I8lSBmVJE/Uz2/3kfOa1DQSxDSRmV1nU3pSd7PUi25Pdx0rezJjRl1UC2gnsNZrCLbplk+VkImXTt3iirV/RuHDo+YVT0efaws7TVH7Uf87jqWf4VZEw/KI3tzfF43CE="
15
20
  before_install: gem update bundler
21
+ before_script:
22
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && chmod +x ./cc-test-reporter && ./cc-test-reporter before-build
16
23
  script:
17
24
  - bundle exec rubocop
18
25
  - bundle exec rspec
26
+ after_script:
27
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
19
28
  notifications:
20
29
  slack:
21
30
  on_success: always
@@ -1,5 +1,20 @@
1
1
  # Gandi V5 API Gem Changelog
2
2
 
3
+ ## Version 0.3.0
4
+
5
+ * Additions to GandiV5::Domain
6
+ * Glue record management
7
+ * LiveDNS management
8
+ * Name server management
9
+ * Update GandiV5::Domain.create to allow purchasing as a reseller and billing to a different organization
10
+ * Add forwarding address management to GandiV5::Email::Forwarding
11
+ * Add GandiV5::Organization.list
12
+ * Uses Zeitwerk for auto loading
13
+ * Add aliasing methods:
14
+ * GandiV5::Domain.mailboxes -> GandiV5::Email::Mailbox.list
15
+ * GandiV5::Domain.mailbox_slots -> GandiV5::Email::Slot.list
16
+ * GandiV5::Domain.email_forwards -> GandiV5::Email::Forward.list
17
+
3
18
  ## Version 0.2.0
4
19
 
5
20
  * Enhancements to GandiV5::Domain
@@ -0,0 +1,10 @@
1
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
2
+ patreon: robertgauld
3
+ open_collective: # Replace with a single Open Collective username
4
+ ko_fi: # Replace with a single Ko-fi username
5
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
6
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
7
+ liberapay: # Replace with a single Liberapay username
8
+ issuehunt: # Replace with a single IssueHunt username
9
+ otechie: # Replace with a single Otechie username
10
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
data/README.md CHANGED
@@ -1,29 +1,17 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/gandi_v5.png)](http://badge.fury.io/rb/gandi_v5)
2
-
3
- Master branch:
4
2
  [![Build Status](https://secure.travis-ci.org/robertgauld/gandi_v5.png?branch=master)](http://travis-ci.org/robertgauld/gandi_v5)
5
3
  [![Coveralls Status](https://coveralls.io/repos/robertgauld/gandi_v5/badge.png?branch=master)](https://coveralls.io/r/robertgauld/gandi_v5)
6
4
  [![Code Climate](https://codeclimate.com/github/robertgauld/gandi_v5.png?branch=master)](https://codeclimate.com/github/robertgauld/gandi_v5)
7
-
8
- Staging branch:
9
- [![Build Status](https://secure.travis-ci.org/robertgauld/gandi_v5.png?branch=staging)](http://travis-ci.org/robertgauld/gandi_v5)
10
- [![Coveralls Status](https://coveralls.io/repos/robertgauld/gandi_v5/badge.png?branch=staging)](https://coveralls.io/r/robertgauld/gandi_v5)
11
-
12
-
13
- ## Build State
14
- This project uses continuous integration to help ensure that a quality product is delivered.
15
- Travis CI monitors two branches (versions) of the code:
16
-
17
- * Master (which is what gets released)
18
- * Staging (which is what is currently being developed ready for moving to master).
19
-
5
+ [![security](https://hakiri.io/github/robertgauld/gandi_v5/master.svg)](https://hakiri.io/github/robertgauld/gandi_v5/master)
20
6
 
21
7
  ## Ruby Versions
22
8
  This gem supports the following versions of ruby, it may work on other versions but is not tested against them so don't rely on it.
23
9
 
24
10
  * ruby:
25
- * 2.6.0 - 2.6.3
11
+ * 2.6.0 - 2.6.4
26
12
  * jruby, once it's reached parity with ruby 2.6.x
13
+ * truffleruby, once it's reached parity with ruby 2.6.x
14
+ * rubinius, once it's reached parity with ruby 2.6.x
27
15
 
28
16
 
29
17
  ## Gandi V5
@@ -86,8 +74,10 @@ TODO: More examples!
86
74
 
87
75
  We follow the [Semantic Versioning](http://semver.org/) concept.
88
76
 
89
- | Gem Version | Gandi API Release Date |
77
+ | Gem Version | Gandi API Release Date |
90
78
  | --------------- | ---------------------- |
79
+ | 0.3.0 | 2019-08-22 |
80
+ | 0.2.0 | 2019-05-16 |
91
81
  | 0.1.0 | 2019-05-16 |
92
82
 
93
83
  See <https://api.gandi.net/docs/reference#API-Changelog> to find out what
@@ -22,8 +22,9 @@ Gem::Specification.new do |gem|
22
22
 
23
23
  gem.add_dependency 'dotenv', '~> 2.5'
24
24
  gem.add_dependency 'rest-client', '>= 2', '< 3'
25
+ gem.add_dependency 'zeitwerk', '~> 2.1'
25
26
 
26
- gem.add_development_dependency 'coveralls', '~> 0.7'
27
+ gem.add_development_dependency 'coveralls', '~> 0.8'
27
28
  gem.add_development_dependency 'guard', '~> 2.15'
28
29
  gem.add_development_dependency 'guard-bundler', '~> 2.2'
29
30
  gem.add_development_dependency 'guard-rspec', '~> 4.2', '>= 4.2.5'
@@ -37,5 +38,5 @@ Gem::Specification.new do |gem|
37
38
  gem.add_development_dependency 'simplecov', '~> 0.7'
38
39
  gem.add_development_dependency 'timecop', '~> 0.5'
39
40
  gem.add_development_dependency 'vcr', '~> 4.0'
40
- gem.add_development_dependency 'webmock', '~> 3.5'
41
+ gem.add_development_dependency 'webmock', '~> 3.6'
41
42
  end
@@ -1,17 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'gandi_v5/version'
4
- require_relative 'gandi_v5/data'
5
- require_relative 'gandi_v5/error'
6
-
7
- require_relative 'gandi_v5/billing'
8
- require_relative 'gandi_v5/domain'
9
- require_relative 'gandi_v5/email'
10
- require_relative 'gandi_v5/live_dns'
11
- require_relative 'gandi_v5/organization'
12
-
13
3
  require 'rest_client'
14
4
  require 'securerandom'
5
+ require 'zeitwerk'
6
+
7
+ # Custom inflector for Zeitwerk.
8
+ class MyInflector < Zeitwerk::Inflector
9
+ # Convert file's base name to class name when
10
+ # Zeitwerk's included inflector gets it wrong.
11
+ # @param basename [String] the file's base name (no path or extension)
12
+ # @param abspath [String] the file's absolute path
13
+ # @return [String] the class name
14
+ def camelize(basename, _abspath)
15
+ case basename
16
+ when 'live_dns'
17
+ 'LiveDNS'
18
+ when 'tld'
19
+ 'TLD'
20
+ else
21
+ super
22
+ end
23
+ end
24
+ end
25
+
26
+ loader = Zeitwerk::Loader.for_gem
27
+ loader.inflector = MyInflector.new
28
+ loader.setup
15
29
 
16
30
  # Namespace for classes which access the Gandi V5 API.
17
31
  # Also provides useful methods and constants for them.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'billing/info'
4
-
5
3
  class GandiV5
6
4
  # Gandi Billing API.
7
5
  # @see https://api.gandi.net/docs/billing
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'info/prepaid'
4
-
5
3
  class GandiV5
6
4
  class Billing
7
5
  # Account's information.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'data/converter'
4
-
5
3
  class GandiV5
6
4
  # Addin providing a DSL to manage declaring attributes and how to map
7
5
  # and convert to/from Gandi's fields.
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'converter/array_of'
4
- require_relative 'converter/symbol'
5
- require_relative 'converter/time'
6
-
7
3
  class GandiV5
8
4
  module Data
9
5
  # Namespace for converters to/from Gandi's format.
@@ -1,15 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'domain/auto_renew'
4
- require_relative 'domain/availability'
5
- require_relative 'domain/contact'
6
- require_relative 'domain/contract'
7
- require_relative 'domain/dates'
8
- require_relative 'domain/renewal_information'
9
- require_relative 'domain/restore_information'
10
- require_relative 'domain/sharing_space'
11
- require_relative 'domain/tld'
12
-
13
3
  class GandiV5
14
4
  # Gandi Domain Management API.
15
5
  # @see https://api.gandi.net/docs/domains
@@ -280,10 +270,163 @@ class GandiV5
280
270
  .prices.first
281
271
  end
282
272
 
273
+ # LiveDNS information for the domain.
274
+ # @see https://api.gandi.net/docs/domains#get-v5-domain-domains-domain-livedns
275
+ # @return [GandiV5::Domain::LiveDNS]
276
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
277
+ def livedns
278
+ @livedns ||= fetch_livedns
279
+ end
280
+
281
+ # Requery Gandi for the domain's LiveDNS information.
282
+ # @see https://api.gandi.net/docs/domains#get-v5-domain-domains-domain-livedns
283
+ # @return [GandiV5::Domain::LiveDNS]
284
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
285
+ def fetch_livedns
286
+ _response, data = GandiV5.get url('livedns')
287
+ @livedns = GandiV5::Domain::LiveDNS.from_gandi data
288
+ @name_server = @livedns.current
289
+ @name_servers = @livedns.name_servers
290
+ @livedns
291
+ end
292
+
293
+ # Enable LiveDNS for the domain.
294
+ # If you want to disable LiveDNS, change the nameservers.
295
+ # Please note that if the domain is on the classic Gandi DNS,
296
+ # this will also perform a copy of all existing records immediately afterwards.
297
+ # @see https://api.gandi.net/docs/domains#post-v5-domain-domains-domain-livedns
298
+ # @return [String] confirmation message from Gandi.
299
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
300
+ def enable_livedns
301
+ _response, data = GandiV5.post url('livedns')
302
+ data['message']
303
+ end
304
+
305
+ # Name servers for the domain.
306
+ # @see https://api.gandi.net/docs/domains#get-v5-domain-domains-domain-nameservers
307
+ # @return [Array<String>]
308
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
309
+ def name_servers
310
+ @name_servers ||= fetch_name_servers
311
+ end
312
+
313
+ # Requery Gandi for the domain's name servers.
314
+ # @see https://api.gandi.net/docs/domains#get-v5-domain-domains-domain-nameservers
315
+ # @return [Array<String>]
316
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
317
+ def fetch_name_servers
318
+ _response, data = GandiV5.get url('nameservers')
319
+ @name_servers = data
320
+ end
321
+
322
+ # Update name servers in Gandi.
323
+ # @see https://api.gandi.net/docs/domains#put-v5-domain-domains-domain-nameservers
324
+ # @param nameservers [Array<String>] the name servers to use.
325
+ # @return [String] confirmation message from Gandi.
326
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
327
+ def update_name_servers(nameservers)
328
+ _response, data = GandiV5.put url('nameservers'), { 'nameservers' => nameservers }.to_json
329
+ @name_servers = nameservers
330
+ data['message']
331
+ end
332
+
333
+ # Glue records for the domain.
334
+ # @see https://api.gandi.net/docs/domains#get-v5-domain-domains-domain-hosts
335
+ # @return [Hash<String => Array<String>>] name to list of IPs
336
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
337
+ def glue_records
338
+ @glue_records ||= fetch_glue_records
339
+ end
340
+
341
+ # Requery Gandi for the domain's glue records.
342
+ # @see https://api.gandi.net/docs/domains#get-v5-domain-domains-domain-hosts
343
+ # @return [Hash<String => Array<String>>] name to list of IPs
344
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
345
+ def fetch_glue_records
346
+ _response, data = GandiV5.get url('hosts')
347
+ @glue_records = data.map { |record| record.values_at('name', 'ips') }.to_h
348
+ end
349
+
350
+ # Add a new glue record to the domain in Gandi.
351
+ # @see https://api.gandi.net/docs/domains#post-v5-domain-domains-domain-hosts
352
+ # @param name [String] the DNS name (excluding FQDN) for the glue record to add (e.g. 'ns1').
353
+ # @param ips [Array<String>] the IPs for the name.
354
+ # @return [String] confirmation message from Gandi.
355
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
356
+ def add_glue_record(name, *ips)
357
+ _response, data = GandiV5.post url('hosts'), { 'name' => name, 'ips' => ips }.to_json
358
+ @glue_records ||= {}
359
+ @glue_records[name] = ips
360
+ data['message']
361
+ end
362
+
363
+ # Get a specific glue record for the domain.
364
+ # @see https://api.gandi.net/docs/domains#get-v5-domain-domains-domain-hosts
365
+ # @param name [String] the DNS name (excluding FQDN) for the glue record to add (e.g. 'ns1').
366
+ # @return [Hash<String => Array<String>>] name to list of IPs
367
+ # @return [nil] name was not found
368
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
369
+ def glue_record(name)
370
+ records = @glue_records.key?(name) ? @glue_records : fetch_glue_records
371
+ records.key?(name) ? records.select { |k, _v| k == name } : nil
372
+ end
373
+
374
+ # Update a specific glue record for the domain.
375
+ # @see https://api.gandi.net/docs/domains#put-v5-domain-domains-domain-hosts-name
376
+ # @param name [String] the DNS name (excluding FQDN) for the glue record to update (e.g. 'ns1').
377
+ # @param ips [Array<String>] the IPs for the name.
378
+ # @return [String] confirmation message from Gandi.
379
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
380
+ def update_glue_record(name, *ips)
381
+ _response, data = GandiV5.put url('hosts', name), { 'ips' => ips }.to_json
382
+ @glue_records ||= {}
383
+ @glue_records[name] = ips
384
+ data['message']
385
+ end
386
+
387
+ # Delete a specific glue record for the domain.
388
+ # @see https://api.gandi.net/docs/domains#delete-v5-domain-domains-domain-hosts-name
389
+ # @param name [String] the DNS name (excluding FQDN) for the glue record to update (e.g. 'ns1').
390
+ # @return [String] confirmation message from Gandi.
391
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
392
+ def delete_glue_record(name)
393
+ _response, data = GandiV5.delete url('hosts', name)
394
+ @glue_records ||= {}
395
+ @glue_records.delete(name)
396
+ data['message']
397
+ end
398
+
399
+ # @see GandiV5::Email::Mailbox.list
400
+ def mailboxes(**params)
401
+ GandiV5::Email::Mailbox.list(**params, fqdn: fqdn)
402
+ end
403
+
404
+ # @see GandiV5::Email::Slot.list
405
+ def mailbox_slots(**params)
406
+ GandiV5::Email::Slot.list(**params, fqdn: fqdn)
407
+ end
408
+
409
+ # @see GandiV5::Email::Forward.list
410
+ def email_forwards(**params)
411
+ GandiV5::Email::Forward.list(**params, fqdn: fqdn)
412
+ end
413
+
283
414
  # Create (register) a new domain.
284
415
  # Warning! This is not a free operation. Please ensure your prepaid account has enough credit.
285
416
  # @see https://api.gandi.net/docs/domains#post-v5-domain-domains
286
417
  # @param fqdn [String, #to_s] the fully qualified domain name to create.
418
+ # @param dry_run [Boolean]
419
+ # whether the details should be checked instead of actually creating the domain.
420
+ # @param sharing_id [String] either:
421
+ # * nil (default) - nothing special happens
422
+ # * an organization ID - pay using another organization
423
+ # (you need to have billing permissions on the organization
424
+ # and use the same organization name for the domain name's owner).
425
+ # The invoice will be edited using this organization's information.
426
+ # * a reseller ID - buy a domain for a customer using a reseller account
427
+ # (you need to have billing permissions on the reseller organization
428
+ # and have your customer's information for the owner).
429
+ # The invoice will be edited using the reseller organization's information.
287
430
  # @param owner [GandiV5::Domain::Contact, #to_gandi, #to_h] (required)
288
431
  # the owner of the new domain.
289
432
  # @param admin [GandiV5::Domain::Contact, #to_gandi, #to_h] (optional, defaults to owner)
@@ -308,25 +451,24 @@ class GandiV5
308
451
  # @param nameservers [Array<String>, #to_gandi, #to_json] (optional)
309
452
  # List of nameservers. Gandi's LiveDNS nameservers are used if omitted..
310
453
  # @param price [Numeric, #to_gandi, #to_json] (optional) unknown - not documented at Gandi.
311
- # @param reselle_id [String, #to_gandi, #to_json] (optional) unknown - not documented at Gandi.
454
+ # @param resellee_id [String, #to_gandi, #to_json] (optional) unknown - not documented at Gandi.
312
455
  # @param smd [String, #to_gandi, #to_json] (optional)
313
456
  # Contents of a Signed Mark Data file (used for newgtld sunrises, tld_period must be sunrise).
314
457
  # @param tld_period ["sunrise", "landrush", "eap1", "eap2", "eap3", "eap4", "eap5", "eap6",
315
458
  # "eap7", "eap8", "eap9", "golive", #to_gandi, #to_json] (optional)
316
459
  # @see https://docs.gandi.net/en/domain_names/register/new_gtld.html
317
- # @param dry_run [Boolean] whether the details should be checked
318
- # instead of actually creating the domain
319
460
  # @return [GandiV5::Domain] the created domain
320
461
  # @return [Hash] if doing a dry run, you get what Gandi returns
321
462
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error
322
- def self.create(fqdn, dry_run: false, **params)
463
+ def self.create(fqdn, dry_run: false, sharing_id: nil, **params)
323
464
  fail ArgumentError, 'missing keyword: owner' unless params.key?(:owner)
324
465
 
325
466
  body = params.merge(fqdn: fqdn)
326
467
  .transform_values { |val| val.respond_to?(:to_gandi) ? val.to_gandi : val }
327
468
  .to_json
469
+ url_ = sharing_id ? "#{url}?sharing_id=#{sharing_id}" : url
328
470
 
329
- response, data = GandiV5.post(url, body, 'Dry-Run': dry_run ? 1 : 0)
471
+ response, data = GandiV5.post(url_, body, 'Dry-Run': dry_run ? 1 : 0)
330
472
  dry_run ? data : fetch(response.headers[:location].split('/').last)
331
473
  end
332
474
 
@@ -371,10 +513,10 @@ class GandiV5
371
513
 
372
514
  private
373
515
 
374
- def url(extra = nil)
516
+ def url(*extra)
375
517
  "#{BASE}domain/domains/" +
376
518
  CGI.escape(fqdn) +
377
- (extra ? "/#{extra}" : '')
519
+ (extra.empty? ? '' : "/#{extra.join('/')}")
378
520
  end
379
521
 
380
522
  def self.url(fqdn = nil)