gandi_v5 0.5.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +69 -5
  3. data/LICENSE.md +2 -6
  4. data/README.md +67 -18
  5. data/lib/gandi_v5.rb +137 -70
  6. data/lib/gandi_v5/billing/info/prepaid.rb +1 -0
  7. data/lib/gandi_v5/data.rb +3 -2
  8. data/lib/gandi_v5/data/converter.rb +3 -2
  9. data/lib/gandi_v5/data/converter/array_of.rb +3 -2
  10. data/lib/gandi_v5/data/converter/integer.rb +3 -2
  11. data/lib/gandi_v5/data/converter/symbol.rb +3 -2
  12. data/lib/gandi_v5/data/converter/time.rb +3 -2
  13. data/lib/gandi_v5/domain.rb +16 -17
  14. data/lib/gandi_v5/domain/availability/product/period.rb +1 -1
  15. data/lib/gandi_v5/domain/contact.rb +5 -5
  16. data/lib/gandi_v5/domain/tld.rb +2 -2
  17. data/lib/gandi_v5/domain/transfer_in.rb +170 -0
  18. data/lib/gandi_v5/domain/transfer_in/availability.rb +51 -0
  19. data/lib/gandi_v5/email.rb +1 -0
  20. data/lib/gandi_v5/email/forward.rb +2 -8
  21. data/lib/gandi_v5/email/mailbox.rb +4 -10
  22. data/lib/gandi_v5/email/slot.rb +11 -3
  23. data/lib/gandi_v5/error/gandi_error.rb +1 -0
  24. data/lib/gandi_v5/live_dns.rb +2 -12
  25. data/lib/gandi_v5/live_dns/domain.rb +340 -29
  26. data/lib/gandi_v5/live_dns/domain/dnssec_key.rb +120 -0
  27. data/lib/gandi_v5/live_dns/domain/record.rb +81 -0
  28. data/lib/gandi_v5/live_dns/domain/snapshot.rb +111 -0
  29. data/lib/gandi_v5/live_dns/domain/tsig_key.rb +74 -0
  30. data/lib/gandi_v5/sharing_space.rb +27 -0
  31. data/lib/gandi_v5/simple_hosting.rb +13 -0
  32. data/lib/gandi_v5/simple_hosting/instance.rb +245 -0
  33. data/lib/gandi_v5/simple_hosting/instance/application.rb +45 -0
  34. data/lib/gandi_v5/simple_hosting/instance/database.rb +20 -0
  35. data/lib/gandi_v5/simple_hosting/instance/language.rb +22 -0
  36. data/lib/gandi_v5/simple_hosting/instance/upgrade.rb +22 -0
  37. data/lib/gandi_v5/simple_hosting/instance/virtual_host.rb +187 -0
  38. data/lib/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone.rb +75 -0
  39. data/lib/gandi_v5/version.rb +1 -1
  40. data/spec/.rubocop.yml +9 -9
  41. data/spec/features/list_domain_renewals_spec.rb +16 -0
  42. data/spec/features/list_email_addresses_spec.rb +39 -0
  43. data/spec/fixtures/bodies/GandiV5_Domain/fetch.yml +8 -0
  44. data/spec/fixtures/bodies/GandiV5_Domain_TransferIn/fetch.yml +21 -0
  45. data/spec/fixtures/bodies/GandiV5_Domain_TransferIn_Availability/fetch.yml +10 -0
  46. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/fetch.yml +1 -2
  47. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/list_tsig.yml +3 -0
  48. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/nameservers.yml +3 -0
  49. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/fetch.yml +12 -0
  50. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/list.yml +9 -0
  51. data/spec/fixtures/bodies/{GandiV5_LiveDNS_Zone_Snapshot → GandiV5_LiveDNS_Domain_Snapshot}/fetch.yml +4 -3
  52. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_Snapshot/list.yml +5 -0
  53. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/fetch.yml +9 -0
  54. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/list.yml +4 -0
  55. data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance/fetch.yml +80 -0
  56. data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance/list.yml +38 -0
  57. data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance_VirtualHost/fetch.yml +26 -0
  58. data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance_VirtualHost/list.yml +18 -0
  59. data/spec/fixtures/vcr/Examples/List_domain_renewals.yml +54 -0
  60. data/spec/fixtures/vcr/Examples/List_email_addresses.yml +103 -0
  61. data/spec/units/gandi_v5/domain/transfer_in/availability_spec.rb +49 -0
  62. data/spec/units/gandi_v5/domain/transfer_in_spec.rb +143 -0
  63. data/spec/units/gandi_v5/domain_spec.rb +13 -39
  64. data/spec/units/gandi_v5/email/forward_spec.rb +5 -34
  65. data/spec/units/gandi_v5/email/mailbox_spec.rb +4 -34
  66. data/spec/units/gandi_v5/email/slot_spec.rb +10 -2
  67. data/spec/units/gandi_v5/live_dns/domain/dnssec_key_spec.rb +128 -0
  68. data/spec/units/gandi_v5/live_dns/{record_set_spec.rb → domain/record_spec.rb} +1 -1
  69. data/spec/units/gandi_v5/live_dns/domain/snapshot_spec.rb +101 -0
  70. data/spec/units/gandi_v5/live_dns/domain/tsig_key_spec.rb +78 -0
  71. data/spec/units/gandi_v5/live_dns/domain_spec.rb +297 -118
  72. data/spec/units/gandi_v5/live_dns_spec.rb +0 -12
  73. data/spec/units/gandi_v5/sharing_space_spec.rb +4 -0
  74. data/spec/units/gandi_v5/simple_hosting/instance/application_spec.rb +37 -0
  75. data/spec/units/gandi_v5/simple_hosting/instance/database_spec.rb +4 -0
  76. data/spec/units/gandi_v5/simple_hosting/instance/language_spec.rb +4 -0
  77. data/spec/units/gandi_v5/simple_hosting/instance/upgrade_spec.rb +4 -0
  78. data/spec/units/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone_spec.rb +50 -0
  79. data/spec/units/gandi_v5/simple_hosting/instance/virtual_host_spec.rb +199 -0
  80. data/spec/units/gandi_v5/simple_hosting/instance_spec.rb +182 -0
  81. data/spec/units/gandi_v5/simple_hosting_spec.rb +9 -0
  82. data/spec/units/gandi_v5_spec.rb +111 -14
  83. metadata +174 -53
  84. data/.gitignore +0 -26
  85. data/.rspec +0 -3
  86. data/.rubocop.yml +0 -30
  87. data/.travis.yml +0 -38
  88. data/FUNDING.yml +0 -10
  89. data/Gemfile +0 -6
  90. data/Guardfile +0 -39
  91. data/Rakefile +0 -3
  92. data/bin/console +0 -13
  93. data/gandi_v5.gemspec +0 -42
  94. data/lib/gandi_v5/domain/sharing_space.rb +0 -21
  95. data/lib/gandi_v5/live_dns/has_zone_records.rb +0 -153
  96. data/lib/gandi_v5/live_dns/record_set.rb +0 -79
  97. data/lib/gandi_v5/live_dns/zone.rb +0 -160
  98. data/lib/gandi_v5/live_dns/zone/snapshot.rb +0 -81
  99. data/spec/features/domain_spec.rb +0 -45
  100. data/spec/features/livedns_domain_spec.rb +0 -8
  101. data/spec/features/livedns_zone_spec.rb +0 -44
  102. data/spec/features/mailbox_spec.rb +0 -18
  103. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/fetch.yml +0 -11
  104. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yml +0 -11
  105. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yml +0 -3
  106. data/spec/fixtures/vcr/Domain_features/List_domains.yml +0 -55
  107. data/spec/fixtures/vcr/Domain_features/Renew_domain.yml +0 -133
  108. data/spec/fixtures/vcr/LiveDNS_Domain_features/List_domains.yml +0 -32
  109. data/spec/fixtures/vcr/LiveDNS_Zone_features/List_zones.yml +0 -42
  110. data/spec/fixtures/vcr/LiveDNS_Zone_features/Make_and_save_snapshot.yml +0 -72
  111. data/spec/fixtures/vcr/LiveDNS_Zone_features/Save_zone_to_file.yml +0 -28
  112. data/spec/fixtures/vcr/Mailbox_features/List_mailboxes.yml +0 -39
  113. data/spec/units/gandi_v5/domain/sharing_space_spec.rb +0 -4
  114. data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +0 -66
  115. data/spec/units/gandi_v5/live_dns/zone_spec.rb +0 -347
@@ -22,6 +22,7 @@ class GandiV5
22
22
  member :updated_at, converter: GandiV5::Data::Converter::Time
23
23
 
24
24
  # Check if current balance is below the warning threshold.
25
+ # @return [Boolean]
25
26
  def warning?
26
27
  return nil if warning_threshold.nil?
27
28
 
@@ -3,6 +3,7 @@
3
3
  class GandiV5
4
4
  # Addin providing a DSL to manage declaring attributes and how to map
5
5
  # and convert to/from Gandi's fields.
6
+ # @api private
6
7
  module Data
7
8
  # api private
8
9
  # Add contents of ClassMethods to the Class which includes this module.
@@ -149,8 +150,8 @@ class GandiV5
149
150
  return nil if data.nil?
150
151
 
151
152
  new(
152
- translate_gandi(data).transform_keys(&:to_sym)
153
- .select { |k, _v| data_member?(k) }
153
+ **translate_gandi(data).transform_keys(&:to_sym)
154
+ .select { |k, _v| data_member?(k) }
154
155
  )
155
156
  end
156
157
 
@@ -3,6 +3,7 @@
3
3
  class GandiV5
4
4
  module Data
5
5
  # Namespace for converters to/from Gandi's format.
6
+ # @api private
6
7
  class Converter
7
8
  # Initialize a new simple converter.
8
9
  # The passed procs will be run at the appropriate time.
@@ -21,8 +22,8 @@ class GandiV5
21
22
  to_gandi_proc.call value
22
23
  end
23
24
 
24
- # @param [Object]
25
- # @return value [Object]
25
+ # @param value [Object]
26
+ # @return [Object]
26
27
  def from_gandi(value)
27
28
  return value unless from_gandi_proc
28
29
 
@@ -4,6 +4,7 @@ class GandiV5
4
4
  module Data
5
5
  class Converter
6
6
  # Used for applying the same converter to each item in an array.
7
+ # @api private
7
8
  class ArrayOf
8
9
  # @param converter the converter to apply to each item in the array.
9
10
  def initialize(converter)
@@ -18,8 +19,8 @@ class GandiV5
18
19
  value.map { |item| converter.to_gandi(item) }
19
20
  end
20
21
 
21
- # @param [Array<Object>]
22
- # @return value [Array<Object>]
22
+ # @param value [Array<Object>]
23
+ # @return [Array<Object>]
23
24
  def from_gandi(value)
24
25
  return nil if value.nil?
25
26
 
@@ -4,6 +4,7 @@ class GandiV5
4
4
  module Data
5
5
  class Converter
6
6
  # Methods for converting strings to/from integerss.
7
+ # @api private
7
8
  class Integer
8
9
  # @param value [Integer]
9
10
  # @return [String]
@@ -13,8 +14,8 @@ class GandiV5
13
14
  value.to_s
14
15
  end
15
16
 
16
- # @param [String]
17
- # @return value [Integer]
17
+ # @param value [String]
18
+ # @return [Integer]
18
19
  def self.from_gandi(value)
19
20
  return nil if value.nil?
20
21
 
@@ -4,6 +4,7 @@ class GandiV5
4
4
  module Data
5
5
  class Converter
6
6
  # Methods for converting strings to/from symbols.
7
+ # @api private
7
8
  class Symbol
8
9
  # @param value [Symbol]
9
10
  # @return [String]
@@ -13,8 +14,8 @@ class GandiV5
13
14
  value.to_s
14
15
  end
15
16
 
16
- # @param [String]
17
- # @return value [Symbol]
17
+ # @param value [String]
18
+ # @return [Symbol]
18
19
  def self.from_gandi(value)
19
20
  return nil if value.nil?
20
21
 
@@ -4,6 +4,7 @@ class GandiV5
4
4
  module Data
5
5
  class Converter
6
6
  # Methods for converting times to/from Gandi ("2019-02-13T11:04:18Z").
7
+ # @api private
7
8
  class Time
8
9
  # Convert a time to Gandi's prefered string format.
9
10
  # @param value [Time]
@@ -15,8 +16,8 @@ class GandiV5
15
16
  end
16
17
 
17
18
  # Convert a time from Gandi's prefered string format.
18
- # @param [String]
19
- # @return value [Time]
19
+ # @param value [String]
20
+ # @return [Time]
20
21
  def self.from_gandi(value)
21
22
  return nil if value.nil?
22
23
 
@@ -7,7 +7,7 @@ class GandiV5
7
7
  # @return [String] fully qualified domain name, written in its native alphabet (IDN).
8
8
  # @!attribute [r] fqdn_unicode
9
9
  # @return [String] fully qualified domain name, written in unicode.
10
- # @see https://docs.gandi.net/en/domain_names/register/idn.html
10
+ # @see https://docs.gandi.net/en/domain_names/register/idn.html
11
11
  # @!attribute [r] name_servers
12
12
  # @return [Array<String>]
13
13
  # @!attribute [r] services
@@ -15,12 +15,12 @@ class GandiV5
15
15
  # gandidns, redirection, gandimail, packmail, dnssec, blog, hosting,
16
16
  # paas, site, certificate, gandilivedns, mailboxv2
17
17
  # @!attribute [r] sharing_space
18
- # @return [GandiV5::Domain::SharingSpace]
18
+ # @return [GandiV5::SharingSpace]
19
19
  # @!attribute [r] status
20
20
  # @return [String] one of: "clientHold", "clientUpdateProhibited", "clientTransferProhibited",
21
21
  # "clientDeleteProhibited", "clientRenewProhibited", "serverHold", "pendingTransfer",
22
22
  # "serverTransferProhibited"
23
- # @see https://docs.gandi.net/en/domain_names/faq/domain_statuses.html
23
+ # @see https://docs.gandi.net/en/domain_names/faq/domain_statuses.html
24
24
  # @!attribute [r] tld
25
25
  # @return [String]
26
26
  # @!attribute [r] dates
@@ -107,7 +107,7 @@ class GandiV5
107
107
  member(
108
108
  :sharing_space,
109
109
  gandi_key: 'sharing_space',
110
- converter: GandiV5::Domain::SharingSpace
110
+ converter: GandiV5::SharingSpace
111
111
  )
112
112
 
113
113
  member(
@@ -206,7 +206,7 @@ class GandiV5
206
206
  end
207
207
 
208
208
  # Renew domain.
209
- # Warning! This is not a free operation. Please ensure your prepaid account has enough credit.
209
+ # @note This is not a free operation. Please ensure your prepaid account has enough credit.
210
210
  # @see https://api.gandi.net/docs/domains#post-v5-domain-domains-domain-renew
211
211
  # @param duration [Integer, #to_s] how long to renew for (in years).
212
212
  # @return [String] confirmation message from Gandi.
@@ -242,7 +242,7 @@ class GandiV5
242
242
  end
243
243
 
244
244
  # Restore an expired domain.
245
- # Warning! This is not a free operation. Please ensure your prepaid account has enough credit.
245
+ # @note This is not a free operation. Please ensure your prepaid account has enough credit.
246
246
  # @see https://docs.gandi.net/en/domain_names/renew/restore.html
247
247
  # @see https://api.gandi.net/docs/domains#post-v5-domain-domains-domain-restore
248
248
  # @return [String] The confirmation message from Gandi.
@@ -399,23 +399,26 @@ class GandiV5
399
399
  data['message']
400
400
  end
401
401
 
402
+ # Get email mailboxes for the domain.
402
403
  # @see GandiV5::Email::Mailbox.list
403
404
  def mailboxes(**params)
404
405
  GandiV5::Email::Mailbox.list(**params, fqdn: fqdn)
405
406
  end
406
407
 
408
+ # Get email slots for the domain.
407
409
  # @see GandiV5::Email::Slot.list
408
410
  def mailbox_slots(**params)
409
411
  GandiV5::Email::Slot.list(**params, fqdn: fqdn)
410
412
  end
411
413
 
414
+ # Get email forwards for the domain.
412
415
  # @see GandiV5::Email::Forward.list
413
416
  def email_forwards(**params)
414
417
  GandiV5::Email::Forward.list(**params, fqdn: fqdn)
415
418
  end
416
419
 
417
420
  # Create (register) a new domain.
418
- # Warning! This is not a free operation. Please ensure your prepaid account has enough credit.
421
+ # @note This is not a free operation. Please ensure your prepaid account has enough credit.
419
422
  # @see https://api.gandi.net/docs/domains#post-v5-domain-domains
420
423
  # @param fqdn [String, #to_s] the fully qualified domain name to create.
421
424
  # @param dry_run [Boolean]
@@ -459,7 +462,7 @@ class GandiV5
459
462
  # Contents of a Signed Mark Data file (used for newgtld sunrises, tld_period must be sunrise).
460
463
  # @param tld_period ["sunrise", "landrush", "eap1", "eap2", "eap3", "eap4", "eap5", "eap6",
461
464
  # "eap7", "eap8", "eap9", "golive", #to_gandi, #to_json] (optional)
462
- # @see https://docs.gandi.net/en/domain_names/register/new_gtld.html
465
+ # @see https://docs.gandi.net/en/domain_names/register/new_gtld.html
463
466
  # @return [GandiV5::Domain] the created domain
464
467
  # @return [Hash] if doing a dry run, you get what Gandi returns
465
468
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error
@@ -492,24 +495,20 @@ class GandiV5
492
495
  # @param page [#each<Integer, #to_s>] the page(s) of results to retrieve.
493
496
  # If page is not provided keep querying until an empty list is returned.
494
497
  # If page responds to .each then iterate until an empty list is returned.
495
- # @param per_page [Integer, #to_s] (optional default 100) how many results ot get per page.
498
+ # @param per_page [Integer, #to_s] (optional default 100) how many results to get per page.
496
499
  # @param fqdn [String, #to_s] (optional)
497
500
  # filters the list by domain name, with optional patterns.
498
501
  # e.g. "example.net", "example.*", "*ample.com"
499
- # @param sort_by [String, #to_s] (optional default "fqdn") how to sort the list.
502
+ # @param resellee_id [String, #to_s] (optional)
503
+ # filters the list by resellee_id (from the Organization API).
500
504
  # @param tld [String, #to_s] (optional) used to filter by just the top level domain.
505
+ # @param sort_by [String, #to_s] (optional default "fqdn") how to sort the list.
501
506
  # @return [Array<GandiV5::Domain>]
502
507
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
503
508
  def self.list(page: (1..), per_page: 100, **params)
504
- page = [page.to_i] unless page.respond_to?(:each)
505
-
506
509
  domains = []
507
- page.each do |page_number|
508
- _resp, data = GandiV5.get url, params: params.merge(page: page_number, per_page: per_page)
509
- break if data.empty?
510
-
510
+ GandiV5.paginated_get(url, page, per_page, params: params) do |data|
511
511
  domains += data.map { |domain| from_gandi domain }
512
- break if data.count < per_page
513
512
  end
514
513
  domains
515
514
  end
@@ -4,7 +4,7 @@ class GandiV5
4
4
  class Domain
5
5
  class Availability
6
6
  class Product
7
- # Information about an available product.
7
+ # Information about an available product's period.
8
8
  # @!attribute [r] name
9
9
  # @return [String]
10
10
  # @!attribute [r]
@@ -4,15 +4,15 @@ class GandiV5
4
4
  class Domain
5
5
  # Information for a single contact for a domain.
6
6
  # @!attribute [r] country
7
- # @return [String] .
7
+ # @return [String]
8
8
  # @!attribute [r] email
9
- # @return [String] .
9
+ # @return [String]
10
10
  # @!attribute [r] family
11
- # @return [String] .
11
+ # @return [String]
12
12
  # @!attribute [r] given
13
- # @return [String] .
13
+ # @return [String]
14
14
  # @!attribute [r] address
15
- # @return [String] .
15
+ # @return [String]
16
16
  # @!attribute [r] type
17
17
  # @return [:person, :company, :association, :'public body', :reseller]
18
18
  # @!attribute [r] brand_number
@@ -12,7 +12,7 @@ class GandiV5
12
12
  # @!attribute [r] category
13
13
  # @return [String]
14
14
  # @!attribute [r] change_owner
15
- # @return [Boolean] whther changing owner is pemritted.
15
+ # @return [Boolean] whether changing owner is pemritted.
16
16
  # @!attribute [r] corporate
17
17
  # @return [Boolean] whether this is a corporate TLD.
18
18
  # @!attribute [r] ext_trade
@@ -27,7 +27,7 @@ class GandiV5
27
27
 
28
28
  # List of available TLDs.
29
29
  # @see https://api.gandi.net/docs/domains#get-v5-domain-tlds
30
- # @return Array<GandiV5::Domain::TLD>
30
+ # @return [Array<GandiV5::Domain::TLD>]
31
31
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
32
32
  def self.list
33
33
  GandiV5.get(url)
@@ -0,0 +1,170 @@
1
+ # frozen_string_literal: true
2
+
3
+ class GandiV5
4
+ class Domain
5
+ # Manage a domain's transfer to Gandi.
6
+ # @!attribute [r] fqdn
7
+ # @return [String] the fully qualified domain name being transfered
8
+ # @!attribute [r] created_at
9
+ # @return [Time]
10
+ # @!attribute [r] updated_at
11
+ # @return [Time]
12
+ # @!attribute [r] owner_contact
13
+ # @return [String]
14
+ # @!attribute [r] step
15
+ # @return [String]
16
+ # @!attribute [r] step_number
17
+ # @return [Integer]
18
+ # @!attribute [r] errortype
19
+ # @return [String] (optional)
20
+ # @!attribute [r] errortype_label
21
+ # @return [String] (optional)
22
+ # @!attribute [r] duration
23
+ # @return [Integer] (optional)
24
+ # @!attribute [r] reseller_uuid
25
+ # @return [String] (optional)
26
+ # @!attribute [r] version
27
+ # @return [Integer] (optional)
28
+ # @!attribute [r] foa
29
+ # @return [Hash{String=>String}] (optional) email => status
30
+ # @!attribute [r] inner_step
31
+ # @return [String] (optional)
32
+ # @!attribute [r] transfer_procedure
33
+ # @return [String] (optional)
34
+ # @!attribute [r] start_at
35
+ # @return [Time] (optional)
36
+ # @!attribute [r] regac_at
37
+ # @return [Time] (optional)
38
+ class TransferIn
39
+ include GandiV5::Data
40
+
41
+ members :fqdn, :owner_contact, :step, :errortype, :errortype_label, :inner_step,
42
+ :transfer_procedure, :reseller_uuid, :version, :foa_status, :duration
43
+
44
+ member :step_number, gandi_key: 'step_nb'
45
+ member :created_at, converter: GandiV5::Data::Converter::Time
46
+ member :updated_at, converter: GandiV5::Data::Converter::Time
47
+ member :regac_at, converter: GandiV5::Data::Converter::Time
48
+ member :start_at, converter: GandiV5::Data::Converter::Time
49
+
50
+ # Relaunch the transfer process after something went wrong.
51
+ # @see https://api.gandi.net/docs/domains/#put-v5-domain-transferin-domain
52
+ # @return [String] the confirmation message from Gandi
53
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
54
+ def relaunch
55
+ TransferIn.relaunch fqdn
56
+ end
57
+
58
+ # Resend the {https://icannwiki.org/FOA Form Of Authorization} email.
59
+ # @see https://api.gandi.net/docs/domains/#post-v5-domain-transferin-domain-foa
60
+ # @return [String] the confirmation message from Gandi
61
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
62
+ def resend_foa_emails(email_address)
63
+ TransferIn.resend_foa_emails fqdn, email_address
64
+ end
65
+
66
+ # Start the transfer of a domain to Gandi.
67
+ # @note This is not a free operation. Please ensure your prepaid account has enough credit.
68
+ # @see https://api.gandi.net/docs/domains/#post-v5-domain-transferin
69
+ # @param fqdn [String, #to_s] the fully qualified domain name to create.
70
+ # @param dry_run [Boolean]
71
+ # whether the details should be checked instead of actually creating the domain.
72
+ # @param sharing_id [String] either:
73
+ # * nil (default) - nothing special happens
74
+ # * an organization ID - pay using another organization
75
+ # (you need to have billing permissions on the organization
76
+ # and use the same organization name for the domain name's owner).
77
+ # The invoice will be edited using this organization's information.
78
+ # * a reseller ID - buy a domain for a customer using a reseller account
79
+ # (you need to have billing permissions on the reseller organization
80
+ # and have your customer's information for the owner).
81
+ # The invoice will be edited using the reseller organization's information.
82
+ # @param owner [GandiV5::Domain::Contact, #to_gandi, #to_h] (required)
83
+ # the owner of the new domain.
84
+ # @param admin [GandiV5::Domain::Contact, #to_gandi, #to_h] (optional, defaults to owner)
85
+ # the administrative contact for the new domain.
86
+ # @param bill [GandiV5::Domain::Contact, #to_gandi, #to_h] (optional, defaults to owner)
87
+ # the billing contact for the new domain.
88
+ # @param tech [GandiV5::Domain::Contact, #to_gandi, #to_h] (optional, defaults to owner)
89
+ # the technical contact for the new domain.
90
+ # @param currency ["EUR", "USD", "GBP", "TWD", "CNY"] (optional)
91
+ # the currency you wish to be charged in.
92
+ # @param duration [Integer] (optional, default 1, minimum 1 maximum 10)
93
+ # how many years to register for.
94
+ # @param enforce_premium [Boolean] (optional)
95
+ # must be set to true if the domain is a premium domain.
96
+ # @param extra_parameters [Hash, #to_gandi, #to_json] (optional)
97
+ # unknown - not documented at Gandi.
98
+ # @param nameserver_ips [Hash<String => Array<String>>, #to_gandi, #to_json] (optional)
99
+ # For glue records only - dictionnary associating a nameserver to a list of IP addresses.
100
+ # @param nameservers [Array<String>, #to_gandi, #to_json] (optional)
101
+ # List of nameservers. Gandi's LiveDNS nameservers are used if omitted..
102
+ # @param price [Numeric, #to_gandi, #to_json] (optional) unknown - not documented at Gandi.
103
+ # @param resellee_id [String, #to_gandi, #to_json] (optional)
104
+ # unknown - not documented at Gandi.
105
+ # @param change_owner [Boolean] (optional)
106
+ # whether the change the domain's owner during the transfer.
107
+ # @param auth_code [String] (optional) authorization code (if required).
108
+ # @return [String] the confirmation message from Gandi
109
+ # @return [Hash] if doing a dry run, you get what Gandi returns
110
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error
111
+ def self.create(fqdn, dry_run: false, sharing_id: nil, **params)
112
+ fail ArgumentError, 'missing keyword: owner' unless params.key?(:owner)
113
+
114
+ body = params.merge(fqdn: fqdn)
115
+ .transform_values { |val| val.respond_to?(:to_gandi) ? val.to_gandi : val }
116
+ .to_json
117
+ url_ = sharing_id ? "#{url}?sharing_id=#{sharing_id}" : url
118
+
119
+ _response, data = GandiV5.post(url_, body, 'Dry-Run': dry_run ? 1 : 0)
120
+ dry_run ? data : data['message']
121
+ end
122
+
123
+ # Get information on an existing transfer.
124
+ # @see https://api.gandi.net/docs/domains/#get-v5-domain-transferin-domain
125
+ # @param fqdn [String, #to_s] the fully qualified domain name to check.
126
+ # @return [GandiV5::Domain::TransferIn]
127
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
128
+ def self.fetch(fqdn)
129
+ _response, data = GandiV5.get url(fqdn)
130
+ transfer = from_gandi data
131
+ transfer.instance_exec { @fqdn = data.dig('params', 'domain') }
132
+ transfer.instance_exec { @reseller_uuid = data.dig('params', 'reseller') }
133
+ transfer.instance_exec { @version = data.dig('params', 'version') }
134
+ transfer.instance_exec { @duration = data.dig('params', 'duration') }
135
+ if data.key?('foa')
136
+ transfer.instance_exec do
137
+ @foa_status = Hash[data['foa'].map { |hash| hash.values_at('email', 'answer') }]
138
+ end
139
+ end
140
+ transfer
141
+ end
142
+
143
+ # Relaunch the transfer process after something went wrong.
144
+ # @see https://api.gandi.net/docs/domains/#put-v5-domain-transferin-domain
145
+ # @return [String] the confirmation message from Gandi
146
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
147
+ def self.relaunch(fqdn)
148
+ _response, data = GandiV5.put url(fqdn)
149
+ data['message']
150
+ end
151
+
152
+ # Resend the {https://icannwiki.org/FOA Form Of Authorization} email.
153
+ # @see https://api.gandi.net/docs/domains/#post-v5-domain-transferin-domain-foa
154
+ # @return [String] the confirmation message from Gandi
155
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
156
+ def self.resend_foa_emails(fqdn, email_address)
157
+ _response, data = GandiV5.post "#{url(fqdn)}/foa", { 'email' => email_address }.to_json
158
+ data['message']
159
+ end
160
+
161
+ private
162
+
163
+ def self.url(fqdn = nil)
164
+ "#{BASE}domain/transferin" +
165
+ (fqdn ? "/#{CGI.escape fqdn}" : '')
166
+ end
167
+ private_class_method :url
168
+ end
169
+ end
170
+ end