Class: GandiV5::Domain::AutoRenew

Inherits:
Object
  • Object
show all
Includes:
GandiV5::Data
Defined in:
lib/gandi_v5/domain/auto_renew.rb

Overview

Automatic renewal information for a domain.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GandiV5::Data

#from_gandi, included, #initialize, #to_gandi, #to_h, #values_at

Instance Attribute Details

#datesnil, Array<Time> (readonly)

Returns:

  • (nil, Array<Time>)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/gandi_v5/domain/auto_renew.rb', line 14

class AutoRenew
  include GandiV5::Data

  attr_accessor :domain

  members :duration, :enabled, :org_id
  member :dates, converter: GandiV5::Data::Converter::Time, array: true

  # Disable auto renewal for the associated domain.
  # @return [String] The confirmation message from Gandi.
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
  def disable
    body = { enabled: false }.to_json
    _response, data = GandiV5.patch url, body
    self.enabled = false
    data['message']
  end

  # Disable auto renewal for the associated domain.
  # @param duration [Integer, #to_s] how long to renew for.
  # @param org_id [String, #to_s] UUID of the organisation that should pay.
  # @return [String] The confirmation message from Gandi.
  # @raise [ArgumentError] if duration is invalid (not 1 to 9 (inclusive)).
  # @raise [ArgumentError] if org_id is not passed and not set for this domain.
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
  def enable(duration: self.duration || 1, org_id: self.org_id)
    fail ArgumentError, 'duration can not be less than 1' if duration < 1
    fail ArgumentError, 'duration can not be more than 9' if duration > 9
    fail ArgumentError, 'org_id is required' if org_id.nil?

    body = {
      enabled: true,
      duration: duration,
      org_id: org_id
    }.to_json

    _response, data = GandiV5.patch url, body
    self.enabled = true
    self.duration = duration
    self.org_id = org_id
    data['message']
  end

  private

  def url
    "#{BASE}domain/domains/#{CGI.escape domain.fqdn}/autorenew"
  end
end

#domainObject

Returns the value of attribute domain.



17
18
19
# File 'lib/gandi_v5/domain/auto_renew.rb', line 17

def domain
  @domain
end

#durationnil, Integer (readonly)

Returns:

  • (nil, Integer)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/gandi_v5/domain/auto_renew.rb', line 14

class AutoRenew
  include GandiV5::Data

  attr_accessor :domain

  members :duration, :enabled, :org_id
  member :dates, converter: GandiV5::Data::Converter::Time, array: true

  # Disable auto renewal for the associated domain.
  # @return [String] The confirmation message from Gandi.
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
  def disable
    body = { enabled: false }.to_json
    _response, data = GandiV5.patch url, body
    self.enabled = false
    data['message']
  end

  # Disable auto renewal for the associated domain.
  # @param duration [Integer, #to_s] how long to renew for.
  # @param org_id [String, #to_s] UUID of the organisation that should pay.
  # @return [String] The confirmation message from Gandi.
  # @raise [ArgumentError] if duration is invalid (not 1 to 9 (inclusive)).
  # @raise [ArgumentError] if org_id is not passed and not set for this domain.
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
  def enable(duration: self.duration || 1, org_id: self.org_id)
    fail ArgumentError, 'duration can not be less than 1' if duration < 1
    fail ArgumentError, 'duration can not be more than 9' if duration > 9
    fail ArgumentError, 'org_id is required' if org_id.nil?

    body = {
      enabled: true,
      duration: duration,
      org_id: org_id
    }.to_json

    _response, data = GandiV5.patch url, body
    self.enabled = true
    self.duration = duration
    self.org_id = org_id
    data['message']
  end

  private

  def url
    "#{BASE}domain/domains/#{CGI.escape domain.fqdn}/autorenew"
  end
end

#enablednil, Boolean (readonly)

Returns:

  • (nil, Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/gandi_v5/domain/auto_renew.rb', line 14

class AutoRenew
  include GandiV5::Data

  attr_accessor :domain

  members :duration, :enabled, :org_id
  member :dates, converter: GandiV5::Data::Converter::Time, array: true

  # Disable auto renewal for the associated domain.
  # @return [String] The confirmation message from Gandi.
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
  def disable
    body = { enabled: false }.to_json
    _response, data = GandiV5.patch url, body
    self.enabled = false
    data['message']
  end

  # Disable auto renewal for the associated domain.
  # @param duration [Integer, #to_s] how long to renew for.
  # @param org_id [String, #to_s] UUID of the organisation that should pay.
  # @return [String] The confirmation message from Gandi.
  # @raise [ArgumentError] if duration is invalid (not 1 to 9 (inclusive)).
  # @raise [ArgumentError] if org_id is not passed and not set for this domain.
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
  def enable(duration: self.duration || 1, org_id: self.org_id)
    fail ArgumentError, 'duration can not be less than 1' if duration < 1
    fail ArgumentError, 'duration can not be more than 9' if duration > 9
    fail ArgumentError, 'org_id is required' if org_id.nil?

    body = {
      enabled: true,
      duration: duration,
      org_id: org_id
    }.to_json

    _response, data = GandiV5.patch url, body
    self.enabled = true
    self.duration = duration
    self.org_id = org_id
    data['message']
  end

  private

  def url
    "#{BASE}domain/domains/#{CGI.escape domain.fqdn}/autorenew"
  end
end

#org_idnil, String (readonly)

Returns:

  • (nil, String)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/gandi_v5/domain/auto_renew.rb', line 14

class AutoRenew
  include GandiV5::Data

  attr_accessor :domain

  members :duration, :enabled, :org_id
  member :dates, converter: GandiV5::Data::Converter::Time, array: true

  # Disable auto renewal for the associated domain.
  # @return [String] The confirmation message from Gandi.
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
  def disable
    body = { enabled: false }.to_json
    _response, data = GandiV5.patch url, body
    self.enabled = false
    data['message']
  end

  # Disable auto renewal for the associated domain.
  # @param duration [Integer, #to_s] how long to renew for.
  # @param org_id [String, #to_s] UUID of the organisation that should pay.
  # @return [String] The confirmation message from Gandi.
  # @raise [ArgumentError] if duration is invalid (not 1 to 9 (inclusive)).
  # @raise [ArgumentError] if org_id is not passed and not set for this domain.
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
  def enable(duration: self.duration || 1, org_id: self.org_id)
    fail ArgumentError, 'duration can not be less than 1' if duration < 1
    fail ArgumentError, 'duration can not be more than 9' if duration > 9
    fail ArgumentError, 'org_id is required' if org_id.nil?

    body = {
      enabled: true,
      duration: duration,
      org_id: org_id
    }.to_json

    _response, data = GandiV5.patch url, body
    self.enabled = true
    self.duration = duration
    self.org_id = org_id
    data['message']
  end

  private

  def url
    "#{BASE}domain/domains/#{CGI.escape domain.fqdn}/autorenew"
  end
end

Instance Method Details

#disableString

Disable auto renewal for the associated domain.

Returns:

  • (String)

    The confirmation message from Gandi.

Raises:



25
26
27
28
29
30
# File 'lib/gandi_v5/domain/auto_renew.rb', line 25

def disable
  body = { enabled: false }.to_json
  _response, data = GandiV5.patch url, body
  self.enabled = false
  data['message']
end

#enable(duration: self.duration || 1, org_id: self.org_id) ⇒ String

Disable auto renewal for the associated domain.

Parameters:

  • duration (Integer, #to_s) (defaults to: self.duration || 1)

    how long to renew for.

  • org_id (String, #to_s) (defaults to: self.org_id)

    UUID of the organisation that should pay.

Returns:

  • (String)

    The confirmation message from Gandi.

Raises:

  • (ArgumentError)

    if duration is invalid (not 1 to 9 (inclusive)).

  • (ArgumentError)

    if org_id is not passed and not set for this domain.

  • (GandiV5::Error::GandiError)

    if Gandi returns an error.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/gandi_v5/domain/auto_renew.rb', line 39

def enable(duration: self.duration || 1, org_id: self.org_id)
  fail ArgumentError, 'duration can not be less than 1' if duration < 1
  fail ArgumentError, 'duration can not be more than 9' if duration > 9
  fail ArgumentError, 'org_id is required' if org_id.nil?

  body = {
    enabled: true,
    duration: duration,
    org_id: org_id
  }.to_json

  _response, data = GandiV5.patch url, body
  self.enabled = true
  self.duration = duration
  self.org_id = org_id
  data['message']
end