gandi_v5 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.rspec +3 -0
- data/.rubocop.yml +20 -0
- data/.travis.yml +23 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +6 -0
- data/Guardfile +40 -0
- data/LICENSE.md +32 -0
- data/README.md +94 -0
- data/Rakefile +3 -0
- data/TODO.md +29 -0
- data/bin/console +13 -0
- data/gandi_v5.gemspec +41 -0
- data/lib/gandi_v5/billing/info/prepaid.rb +33 -0
- data/lib/gandi_v5/billing/info.rb +26 -0
- data/lib/gandi_v5/billing.rb +28 -0
- data/lib/gandi_v5/data/converter/array_of.rb +35 -0
- data/lib/gandi_v5/data/converter/symbol.rb +26 -0
- data/lib/gandi_v5/data/converter/time.rb +28 -0
- data/lib/gandi_v5/data/converter.rb +41 -0
- data/lib/gandi_v5/data.rb +244 -0
- data/lib/gandi_v5/domain/auto_renew.rb +64 -0
- data/lib/gandi_v5/domain/contact.rb +102 -0
- data/lib/gandi_v5/domain/contract.rb +22 -0
- data/lib/gandi_v5/domain/dates.rb +44 -0
- data/lib/gandi_v5/domain/renewal_information.rb +41 -0
- data/lib/gandi_v5/domain/restore_information.rb +18 -0
- data/lib/gandi_v5/domain/sharing_space.rb +21 -0
- data/lib/gandi_v5/domain.rb +431 -0
- data/lib/gandi_v5/email/mailbox/responder.rb +36 -0
- data/lib/gandi_v5/email/mailbox.rb +236 -0
- data/lib/gandi_v5/email/offer.rb +27 -0
- data/lib/gandi_v5/email/slot.rb +134 -0
- data/lib/gandi_v5/email.rb +11 -0
- data/lib/gandi_v5/error/gandi_error.rb +21 -0
- data/lib/gandi_v5/error.rb +9 -0
- data/lib/gandi_v5/live_dns/domain.rb +211 -0
- data/lib/gandi_v5/live_dns/record_set.rb +79 -0
- data/lib/gandi_v5/live_dns/zone/snapshot.rb +62 -0
- data/lib/gandi_v5/live_dns/zone.rb +301 -0
- data/lib/gandi_v5/live_dns.rb +30 -0
- data/lib/gandi_v5/organization.rb +66 -0
- data/lib/gandi_v5/version.rb +5 -0
- data/lib/gandi_v5.rb +178 -0
- data/spec/.rubocop.yml +4 -0
- data/spec/features/domain_spec.rb +45 -0
- data/spec/features/livedns_domain_spec.rb +8 -0
- data/spec/features/livedns_zone_spec.rb +45 -0
- data/spec/features/mailbox_spec.rb +18 -0
- data/spec/fixtures/bodies/GandiV5_Billing/info.yaml +10 -0
- data/spec/fixtures/bodies/GandiV5_Domain/availability.yaml +15 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_contacts.yaml +8 -0
- data/spec/fixtures/bodies/GandiV5_Domain/get.yaml +37 -0
- data/spec/fixtures/bodies/GandiV5_Domain/list.yaml +20 -0
- data/spec/fixtures/bodies/GandiV5_Domain/renewal_info.yaml +12 -0
- data/spec/fixtures/bodies/GandiV5_Domain/restore_info.yaml +5 -0
- data/spec/fixtures/bodies/GandiV5_Domain/tld.yaml +10 -0
- data/spec/fixtures/bodies/GandiV5_Domain/tlds.yaml +7 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/get.yaml +16 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/list.yaml +8 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/get.yaml +10 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/list.yaml +8 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/get.yaml +4 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/list.yaml +2 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/get.yaml +11 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yaml +11 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/get.yaml +9 -0
- data/spec/fixtures/bodies/GandiV5_Organization/get.yaml +17 -0
- data/spec/fixtures/vcr/Domain_features/List_domains.yml +54 -0
- data/spec/fixtures/vcr/Domain_features/Renew_domain.yml +133 -0
- data/spec/fixtures/vcr/LiveDNS_Domain_features/List_domains.yml +32 -0
- data/spec/fixtures/vcr/LiveDNS_Zone_features/List_zones.yml +42 -0
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Make_and_save_snapshot.yml +72 -0
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Save_zone_to_file.yml +28 -0
- data/spec/fixtures/vcr/Mailbox_features/List_mailboxes.yml +39 -0
- data/spec/spec_helper.rb +60 -0
- data/spec/test.env +1 -0
- data/spec/units/gandi_v5/billing/info/prepaid_spec.rb +20 -0
- data/spec/units/gandi_v5/billing/info_spec.rb +4 -0
- data/spec/units/gandi_v5/billing_spec.rb +41 -0
- data/spec/units/gandi_v5/data/converter/array_of_spec.rb +18 -0
- data/spec/units/gandi_v5/data/converter/symbol_spec.rb +16 -0
- data/spec/units/gandi_v5/data/converter/time_spec.rb +16 -0
- data/spec/units/gandi_v5/data/converter_spec.rb +31 -0
- data/spec/units/gandi_v5/data_spec.rb +340 -0
- data/spec/units/gandi_v5/domain/auto_renew_spec.rb +70 -0
- data/spec/units/gandi_v5/domain/contact_spec.rb +36 -0
- data/spec/units/gandi_v5/domain/contract_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/dates_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/renewal_information_spec.rb +81 -0
- data/spec/units/gandi_v5/domain/restore_information_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/sharing_space_spec.rb +4 -0
- data/spec/units/gandi_v5/domain_spec.rb +451 -0
- data/spec/units/gandi_v5/email/mailbox/responder_spec.rb +131 -0
- data/spec/units/gandi_v5/email/mailbox_spec.rb +384 -0
- data/spec/units/gandi_v5/email/offer_spec.rb +17 -0
- data/spec/units/gandi_v5/email/slot_spec.rb +102 -0
- data/spec/units/gandi_v5/error/gandi_error_spec.rb +30 -0
- data/spec/units/gandi_v5/error_spec.rb +4 -0
- data/spec/units/gandi_v5/live_dns/domain_spec.rb +247 -0
- data/spec/units/gandi_v5/live_dns/record_set_spec.rb +74 -0
- data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +37 -0
- data/spec/units/gandi_v5/live_dns/zone_spec.rb +329 -0
- data/spec/units/gandi_v5/live_dns_spec.rb +17 -0
- data/spec/units/gandi_v5/organization_spec.rb +30 -0
- data/spec/units/gandi_v5_spec.rb +204 -0
- metadata +406 -0
@@ -0,0 +1,244 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'data/converter'
|
4
|
+
|
5
|
+
class GandiV5
|
6
|
+
# Addin providing a DSL to manage declaring attributes and how to map
|
7
|
+
# and convert to/from Gandi's fields.
|
8
|
+
module Data
|
9
|
+
# api private
|
10
|
+
# Add contents of ClassMethods to the Class which includes this module.
|
11
|
+
# @param host_class [Class] the class which included us.
|
12
|
+
def self.included(host_class)
|
13
|
+
host_class.extend ClassMethods
|
14
|
+
|
15
|
+
host_class.instance_exec do
|
16
|
+
@data_members ||= Set.new
|
17
|
+
@data_converters ||= {}
|
18
|
+
@data_map_key_to_member ||= {}
|
19
|
+
@data_map_member_to_key ||= {}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get a hash representation of the object.
|
24
|
+
# @return [Hash<Symbol => Object>]
|
25
|
+
def to_h
|
26
|
+
Hash[
|
27
|
+
data_members.map do |key|
|
28
|
+
value = send(key)
|
29
|
+
next [key, value] if value.nil?
|
30
|
+
|
31
|
+
if value.is_a?(Enumerable)
|
32
|
+
value = to_h_transform_enumerable(value)
|
33
|
+
elsif value.respond_to?(:to_h)
|
34
|
+
value = value.to_h
|
35
|
+
end
|
36
|
+
[key, value]
|
37
|
+
end
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Get a hash representation of this object suitable for passing back to Gandi.
|
42
|
+
# @return [Hash<String => nil, Boolean, String, Numeric, Hash, Array>]
|
43
|
+
def to_gandi
|
44
|
+
data = {}
|
45
|
+
|
46
|
+
data_members.each do |member|
|
47
|
+
key = data_member_to_gandi_key(member)
|
48
|
+
value = send(member)
|
49
|
+
converter = data_converter_for(member)
|
50
|
+
|
51
|
+
data[key] = if value.respond_to?(:to_gandi)
|
52
|
+
value.to_gandi
|
53
|
+
elsif converter && !value.nil?
|
54
|
+
converter.to_gandi(value)
|
55
|
+
else
|
56
|
+
value
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
data
|
61
|
+
end
|
62
|
+
|
63
|
+
# Get an array of values from particular members.
|
64
|
+
# @param keys [Array<Symbol, String>] e.g. :fqdn, "contacts.owner"
|
65
|
+
# @return [Array<Object>]
|
66
|
+
# rubocop:disable Style/IfUnlessModifier
|
67
|
+
def values_at(*keys)
|
68
|
+
keys.map(&:to_s).map do |key|
|
69
|
+
key, sub_key = key.split('.', 2)
|
70
|
+
unless data_member?(key.to_sym)
|
71
|
+
fail ArgumentError, "#{key} is not a member."
|
72
|
+
end
|
73
|
+
|
74
|
+
sub_key.empty? ? send(key) : send(key).values_at(sub_key)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
# rubocop:enable Style/IfUnlessModifier
|
78
|
+
|
79
|
+
# Update instance with data from Gandi.
|
80
|
+
# @param data [Hash]
|
81
|
+
# @return [self]
|
82
|
+
def from_gandi(data)
|
83
|
+
translate_gandi(data).each do |key, value|
|
84
|
+
next unless data_member?(key.to_sym)
|
85
|
+
|
86
|
+
send "#{key}=", value
|
87
|
+
end
|
88
|
+
self
|
89
|
+
end
|
90
|
+
|
91
|
+
# Create a new instance from any passed members.
|
92
|
+
# @param members [Hash<Symbol => Object>]
|
93
|
+
# rubocop:disable Style/IfUnlessModifier
|
94
|
+
def initialize(**members)
|
95
|
+
members.each do |member, value|
|
96
|
+
unless data_member?(member)
|
97
|
+
fail ArgumentError, "unknown keyword: #{member}"
|
98
|
+
end
|
99
|
+
|
100
|
+
send "#{member}=", value
|
101
|
+
end
|
102
|
+
end
|
103
|
+
# rubocop:enable Style/IfUnlessModifier
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def data_members
|
108
|
+
self.class.send(:data_members)
|
109
|
+
end
|
110
|
+
|
111
|
+
def data_member?(member)
|
112
|
+
self.class.send(:data_member?, member)
|
113
|
+
end
|
114
|
+
|
115
|
+
def data_gandi_key_to_member(gandi_key)
|
116
|
+
self.class.send(:data_gandi_key_to_member, gandi_key)
|
117
|
+
end
|
118
|
+
|
119
|
+
def data_member_to_gandi_key(member)
|
120
|
+
self.class.send(:data_member_to_gandi_key, member)
|
121
|
+
end
|
122
|
+
|
123
|
+
def data_converter_for(member)
|
124
|
+
self.class.send(:data_converter_for, member)
|
125
|
+
end
|
126
|
+
|
127
|
+
def data_converter_for?(member)
|
128
|
+
self.class.send(:data_converter_for?, member)
|
129
|
+
end
|
130
|
+
|
131
|
+
def translate_gandi(data)
|
132
|
+
self.class.send(:translate_gandi, data)
|
133
|
+
end
|
134
|
+
|
135
|
+
def to_h_transform_enumerable(value)
|
136
|
+
method = :transform_keys if value.respond_to?(:transform_keys)
|
137
|
+
method ||= :map if value.respond_to?(:map)
|
138
|
+
|
139
|
+
value.send(method) do |v|
|
140
|
+
next to_h_transform_value(v) if v.is_a?(Enumerable)
|
141
|
+
|
142
|
+
v.respond_to?(:to_h) ? v.to_h : v
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Class methods to add to classes which include this module.
|
147
|
+
module ClassMethods
|
148
|
+
# Create a new instance with data from Gandi.
|
149
|
+
# @param data [Hash]
|
150
|
+
def from_gandi(data)
|
151
|
+
return nil if data.nil?
|
152
|
+
|
153
|
+
new(
|
154
|
+
translate_gandi(data).transform_keys(&:to_sym)
|
155
|
+
.select { |k, _v| data_member?(k) }
|
156
|
+
)
|
157
|
+
end
|
158
|
+
|
159
|
+
private
|
160
|
+
|
161
|
+
def members(*names)
|
162
|
+
names.each do |name|
|
163
|
+
member name
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def member(name, gandi_key: name.to_s, converter: nil, array: false)
|
168
|
+
@data_members.add name
|
169
|
+
@data_map_key_to_member[gandi_key] = name
|
170
|
+
@data_map_member_to_key[name] = gandi_key
|
171
|
+
convert_member_with(name, gandi_key, converter, array) if converter
|
172
|
+
|
173
|
+
define_method name do
|
174
|
+
instance_variable_get "@#{name}"
|
175
|
+
end
|
176
|
+
|
177
|
+
define_method "#{name}?" do
|
178
|
+
!instance_variable_get("@#{name}").nil?
|
179
|
+
end
|
180
|
+
|
181
|
+
define_method "#{name}=" do |value|
|
182
|
+
instance_variable_set("@#{name}", value)
|
183
|
+
end
|
184
|
+
private "#{name}="
|
185
|
+
end
|
186
|
+
|
187
|
+
# @api private
|
188
|
+
def data_members
|
189
|
+
instance_variable_get(:@data_members).to_a
|
190
|
+
end
|
191
|
+
|
192
|
+
# @api private
|
193
|
+
def data_member?(member)
|
194
|
+
instance_variable_get(:@data_members).include?(member)
|
195
|
+
end
|
196
|
+
|
197
|
+
# @api private
|
198
|
+
def data_gandi_key_to_member(gandi_key)
|
199
|
+
instance_variable_get(:@data_map_key_to_member).fetch(gandi_key)
|
200
|
+
end
|
201
|
+
|
202
|
+
# @api private
|
203
|
+
def data_member_to_gandi_key(member)
|
204
|
+
instance_variable_get(:@data_map_member_to_key).fetch(member)
|
205
|
+
end
|
206
|
+
|
207
|
+
# @api private
|
208
|
+
def data_converter_for(member)
|
209
|
+
instance_variable_get(:@data_converters)[member]
|
210
|
+
end
|
211
|
+
|
212
|
+
# @api private
|
213
|
+
def data_converter_for?(member)
|
214
|
+
instance_variable_get(:@data_converters).key?(member)
|
215
|
+
end
|
216
|
+
|
217
|
+
# @api private
|
218
|
+
def convert_member_with(name, gandi_key, converter, array)
|
219
|
+
converter = GandiV5::Data::Converter::ArrayOf.new(converter) if array
|
220
|
+
@data_converters[name] = converter
|
221
|
+
@data_converters[gandi_key] = converter
|
222
|
+
end
|
223
|
+
|
224
|
+
def translate_gandi(data)
|
225
|
+
return nil unless data.is_a?(Hash)
|
226
|
+
|
227
|
+
data = data.clone
|
228
|
+
|
229
|
+
# Do name mapping
|
230
|
+
@data_map_key_to_member.each do |key, member|
|
231
|
+
data[member] = data.delete(key) if data.key?(key)
|
232
|
+
end
|
233
|
+
|
234
|
+
# Do value conversions
|
235
|
+
data.each do |key, value|
|
236
|
+
converter = data_converter_for(key)
|
237
|
+
data[key] = converter.from_gandi(value) if converter
|
238
|
+
end
|
239
|
+
|
240
|
+
data
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class Domain
|
5
|
+
# Automatic renewal information for a domain.
|
6
|
+
# @!attribute [r] dates
|
7
|
+
# @return [nil, Array<Time>]
|
8
|
+
# @!attribute [r] duration
|
9
|
+
# @return [nil, Integer]
|
10
|
+
# @!attribute [r] enabled
|
11
|
+
# @return [nil, Boolean]
|
12
|
+
# @!attribute [r] org_id
|
13
|
+
# @return [nil, String]
|
14
|
+
class AutoRenew
|
15
|
+
include GandiV5::Data
|
16
|
+
|
17
|
+
attr_accessor :domain
|
18
|
+
|
19
|
+
members :duration, :enabled, :org_id
|
20
|
+
member :dates, converter: GandiV5::Data::Converter::Time, array: true
|
21
|
+
|
22
|
+
# Disable auto renewal for the associated domain.
|
23
|
+
# @return [String] The confirmation message from Gandi.
|
24
|
+
# @raise [GandiV5::Error::GandiError::GandiError] if Gandi returns an error.
|
25
|
+
def disable
|
26
|
+
body = { enabled: false }.to_json
|
27
|
+
data = GandiV5.patch url, body
|
28
|
+
self.enabled = false
|
29
|
+
data['message']
|
30
|
+
end
|
31
|
+
|
32
|
+
# Disable auto renewal for the associated domain.
|
33
|
+
# @param duration [Integer, #to_s] how long to renew for.
|
34
|
+
# @param org_id [String, #to_s] UUID of the organisation that should pay.
|
35
|
+
# @return [String] The confirmation message from Gandi.
|
36
|
+
# @raise [ArgumentError] if duration is invalid (not 1 to 9 (inclusive)).
|
37
|
+
# @raise [ArgumentError] if org_id is not passed and not set for this domain.
|
38
|
+
# @raise [GandiV5::Error::GandiError::GandiError] if Gandi returns an error.
|
39
|
+
def enable(duration: self.duration || 1, org_id: self.org_id)
|
40
|
+
fail ArgumentError, 'duration can not be less than 1' if duration < 1
|
41
|
+
fail ArgumentError, 'duration can not be more than 9' if duration > 9
|
42
|
+
fail ArgumentError, 'org_id is required' if org_id.nil?
|
43
|
+
|
44
|
+
body = {
|
45
|
+
enabled: true,
|
46
|
+
duration: duration,
|
47
|
+
org_id: org_id
|
48
|
+
}.to_json
|
49
|
+
|
50
|
+
data = GandiV5.patch url, body
|
51
|
+
self.enabled = true
|
52
|
+
self.duration = duration
|
53
|
+
self.org_id = org_id
|
54
|
+
data['message']
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def url
|
60
|
+
"#{BASE}domain/domains/#{CGI.escape domain.fqdn}/autorenew"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class Domain
|
5
|
+
# Information for a single contact for a domain.
|
6
|
+
# @!attribute [r] country
|
7
|
+
# @return [String] .
|
8
|
+
# @!attribute [r] email
|
9
|
+
# @return [String] .
|
10
|
+
# @!attribute [r] family
|
11
|
+
# @return [String] .
|
12
|
+
# @!attribute [r] given
|
13
|
+
# @return [String] .
|
14
|
+
# @!attribute [r] address
|
15
|
+
# @return [String] .
|
16
|
+
# @!attribute [r] type
|
17
|
+
# @return [:person, :company, :association, :'public body', :reseller]
|
18
|
+
# @!attribute [r] brand_number
|
19
|
+
# @return [nil, String]
|
20
|
+
# @!attribute [r] city
|
21
|
+
# @return [nil, String]
|
22
|
+
# @!attribute [r] data_obfuscated
|
23
|
+
# @return [nil, Boolean]
|
24
|
+
# @!attribute [r] extra_parameters
|
25
|
+
# @return [nil, Hash]
|
26
|
+
# @!attribute [r] fax
|
27
|
+
# @return [nil, String]
|
28
|
+
# @!attribute [r] jo_announce_number
|
29
|
+
# @return [nil, String]
|
30
|
+
# @!attribute [r] jo_announce_page
|
31
|
+
# @return [nil, String]
|
32
|
+
# @!attribute [r] jo_declaration_page
|
33
|
+
# @return [nil, String]
|
34
|
+
# @!attribute [r] jo_publication_date
|
35
|
+
# @return [nil, String]
|
36
|
+
# @!attribute [r] mail_obfuscated
|
37
|
+
# @return [nil, Boolean]
|
38
|
+
# @!attribute [r] mobile
|
39
|
+
# @return [nil, String]
|
40
|
+
# @!attribute [r] organisation_name
|
41
|
+
# @return [nil, String] the legal name of the company, association, or public body
|
42
|
+
# if the contact type is not :person.
|
43
|
+
# @!attribute [r] phone
|
44
|
+
# @return [nil, String]
|
45
|
+
# @!attribute [r] reachability
|
46
|
+
# @return [nil, :pending, :done, :failed, :deleted, :none]
|
47
|
+
# @!attribute [r] sharing_uuid
|
48
|
+
# @return [nil, String]
|
49
|
+
# @!attribute [r] siren
|
50
|
+
# @return [nil, String]
|
51
|
+
# @!attribute [r] state
|
52
|
+
# @return [nil, String]
|
53
|
+
# @see https://docs.gandi.net/en/rest_api/domain_api/contacts_api.html
|
54
|
+
# @!attribute [r] validation
|
55
|
+
# @return [nil, :pending, :done, :failed, :deleted, :none]
|
56
|
+
# @!attribute [r] zip
|
57
|
+
# @return [nil, String]
|
58
|
+
class Contact
|
59
|
+
include GandiV5::Data
|
60
|
+
|
61
|
+
TYPES = {
|
62
|
+
person: 'Person',
|
63
|
+
company: 'Company',
|
64
|
+
association: 'Association',
|
65
|
+
'public body': 'Public Body',
|
66
|
+
reseller: 'Reseller'
|
67
|
+
}.freeze
|
68
|
+
REACHABILITIES = %i[pending done failed deleted none].freeze
|
69
|
+
VALIDATIONS = %i[pending done failed deleted none].freeze
|
70
|
+
|
71
|
+
members :country, :email, :family, :given, :brand_number, :city, :data_obfuscated,
|
72
|
+
:extra_parameters, :fax, :jo_announce_number, :jo_announce_page,
|
73
|
+
:jo_declaration_page, :jo_publication_date, :mail_obfuscated,
|
74
|
+
:mobile, :phone, :siren, :state, :zip
|
75
|
+
|
76
|
+
member :organisation_name, gandi_key: 'orgname'
|
77
|
+
member :address, gandi_key: 'streetaddr'
|
78
|
+
member :sharing_uuid, gandi_key: 'sharing_id'
|
79
|
+
|
80
|
+
member(
|
81
|
+
:type,
|
82
|
+
converter: GandiV5::Data::Converter.new(
|
83
|
+
from_gandi: ->(type) { TYPES.keys[type] },
|
84
|
+
to_gandi: ->(type) { TYPES.keys.index(type) }
|
85
|
+
)
|
86
|
+
)
|
87
|
+
member :reachability, converter: GandiV5::Data::Converter::Symbol
|
88
|
+
member :validation, converter: GandiV5::Data::Converter::Symbol
|
89
|
+
|
90
|
+
# Get the name for this contact.
|
91
|
+
# @return [String] e.g. "John Smith" or "Some Company LTD."
|
92
|
+
def name
|
93
|
+
type.eql?(:person) ? "#{given} #{family}" : organisation_name
|
94
|
+
end
|
95
|
+
|
96
|
+
# @return [String] Containing type and name.
|
97
|
+
def to_s
|
98
|
+
"#{TYPES[type]}\t#{name}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class Domain
|
5
|
+
# A contract relevant to renewing/restoring a domain.
|
6
|
+
# @!attribute [r] id
|
7
|
+
# @return [String]
|
8
|
+
# @!attribute [r] name
|
9
|
+
# @return [String]
|
10
|
+
# @!attribute [r] href
|
11
|
+
# @return [nil, String]
|
12
|
+
# @!attribute [r] registry_contract_href
|
13
|
+
# @return [nil, String]
|
14
|
+
class Contract
|
15
|
+
include GandiV5::Data
|
16
|
+
|
17
|
+
members :id, :name, :href, :registry_contract_href
|
18
|
+
|
19
|
+
alias contract_id id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class Domain
|
5
|
+
# Dates of key events for a domain.
|
6
|
+
# @!attribute [r] registry_created_at
|
7
|
+
# @return [Time]
|
8
|
+
# @!attribute [r] updated_at
|
9
|
+
# @return [Time]
|
10
|
+
# @!attribute [r] authinfo_expires_at
|
11
|
+
# @return [nil, Time]
|
12
|
+
# @!attribute [r] created_at
|
13
|
+
# @return [nil, Time]
|
14
|
+
# @!attribute [r] deletes_at
|
15
|
+
# @return [nil, Time]
|
16
|
+
# @!attribute [r] hold_begins_at
|
17
|
+
# @return [nil, Time]
|
18
|
+
# @!attribute [r] hold_ends_at
|
19
|
+
# @return [nil, Time]
|
20
|
+
# @!attribute [r] pending_delete_ends_at
|
21
|
+
# @return [nil, Time]
|
22
|
+
# @!attribute [r] registry_ends_at
|
23
|
+
# @return [nil, Time]
|
24
|
+
# @!attribute [r] renew_begins_at
|
25
|
+
# @return [nil, Time]
|
26
|
+
# @!attribute [r] restore_ends_at
|
27
|
+
# @return [nil, Time]
|
28
|
+
class Dates
|
29
|
+
include GandiV5::Data
|
30
|
+
|
31
|
+
member :registry_created_at, converter: GandiV5::Data::Converter::Time
|
32
|
+
member :updated_at, converter: GandiV5::Data::Converter::Time
|
33
|
+
member :authinfo_expires_at, converter: GandiV5::Data::Converter::Time
|
34
|
+
member :created_at, converter: GandiV5::Data::Converter::Time
|
35
|
+
member :deletes_at, converter: GandiV5::Data::Converter::Time
|
36
|
+
member :hold_begins_at, converter: GandiV5::Data::Converter::Time
|
37
|
+
member :hold_ends_at, converter: GandiV5::Data::Converter::Time
|
38
|
+
member :pending_delete_ends_at, converter: GandiV5::Data::Converter::Time
|
39
|
+
member :registry_ends_at, converter: GandiV5::Data::Converter::Time
|
40
|
+
member :renew_begins_at, converter: GandiV5::Data::Converter::Time
|
41
|
+
member :restore_ends_at, converter: GandiV5::Data::Converter::Time
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class Domain
|
5
|
+
# Renewal information for a domain.
|
6
|
+
# @!attribute [r] begins_at
|
7
|
+
# @return [Time]
|
8
|
+
# @!attribute [r] ends_at
|
9
|
+
# @return [nil, Time]
|
10
|
+
# @!attribute [r] in_renew_period
|
11
|
+
# @return [nil, Boolean]
|
12
|
+
# @!attribute [r] prohibited
|
13
|
+
# @return [Boolean]
|
14
|
+
# @!attribute [r] durations
|
15
|
+
# @return [Array<Integer>]
|
16
|
+
# @!attribute [r] maximum
|
17
|
+
# @return [Integer]
|
18
|
+
# @!attribute [r] minimum
|
19
|
+
# @return [Integer]
|
20
|
+
# @!attribute [r] contracts
|
21
|
+
# @return [Array<GandiV5::Domain::Contract>]
|
22
|
+
class RenewalInformation
|
23
|
+
include GandiV5::Data
|
24
|
+
|
25
|
+
members :in_renew_period, :prohibited, :durations, :maximum, :minimum
|
26
|
+
|
27
|
+
member :begins_at, converter: GandiV5::Data::Converter::Time
|
28
|
+
member :ends_at, converter: GandiV5::Data::Converter::Time
|
29
|
+
member :contracts, converter: GandiV5::Domain::Contract, array: true
|
30
|
+
|
31
|
+
# Check if the domain is currently renewable.
|
32
|
+
# @return [Boolean]
|
33
|
+
def renewable?
|
34
|
+
return false if prohibited
|
35
|
+
return false if begins_at > Time.now
|
36
|
+
|
37
|
+
ends_at.nil? || ends_at >= Time.now
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class Domain
|
5
|
+
# Restoration information for a domain.
|
6
|
+
# @see https://docs.gandi.net/en/domain_names/renew/restore.html
|
7
|
+
# @!attribute [r] restorable
|
8
|
+
# @return [Boolean]
|
9
|
+
# @!attribute [r] contracts
|
10
|
+
# @return [nil, Array<GandiV5::Domain::Contract>]
|
11
|
+
class RestoreInformation
|
12
|
+
include GandiV5::Data
|
13
|
+
|
14
|
+
members :restorable, :contracts
|
15
|
+
member :contracts, converter: GandiV5::Domain::Contract, array: true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class Domain
|
5
|
+
# Sharing space which contains a domain.
|
6
|
+
# @!attribute [r] uuid
|
7
|
+
# @return [String]
|
8
|
+
# @!attribute [r] name
|
9
|
+
# @return [String]
|
10
|
+
# @!attribute [r] reseller
|
11
|
+
# @return [nil, Boolean]
|
12
|
+
class SharingSpace
|
13
|
+
include GandiV5::Data
|
14
|
+
|
15
|
+
members :name, :reseller
|
16
|
+
member :uuid, gandi_key: 'id'
|
17
|
+
|
18
|
+
alias sharing_space_uuid uuid
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|