Class: AdvancedBilling::ResumeOptions

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/resume_options.rb

Overview

ResumeOptions Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(require_resume: SKIP, forgive_balance: SKIP, additional_properties: {}) ⇒ ResumeOptions

Returns a new instance of ResumeOptions.



45
46
47
48
49
50
51
52
53
54
# File 'lib/advanced_billing/models/resume_options.rb', line 45

def initialize(require_resume: SKIP, forgive_balance: SKIP,
               additional_properties: {})
  @require_resume = require_resume unless require_resume == SKIP
  @forgive_balance = forgive_balance unless forgive_balance == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#forgive_balanceTrueClass | FalseClass

Indicates whether or not Chargify should clear the subscription’s existing balance before attempting to resume the subscription. If subscription cannot be resumed, the balance will remain as it was before the attempt to resume was made.

Returns:

  • (TrueClass | FalseClass)


22
23
24
# File 'lib/advanced_billing/models/resume_options.rb', line 22

def forgive_balance
  @forgive_balance
end

#require_resumeTrueClass | FalseClass

Chargify will only attempt to resume the subscription’s billing period. If not resumable, the subscription will be left in it’s current state.

Returns:

  • (TrueClass | FalseClass)


15
16
17
# File 'lib/advanced_billing/models/resume_options.rb', line 15

def require_resume
  @require_resume
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/advanced_billing/models/resume_options.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  require_resume =
    hash.key?('require_resume') ? hash['require_resume'] : SKIP
  forgive_balance =
    hash.key?('forgive_balance') ? hash['forgive_balance'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  ResumeOptions.new(require_resume: require_resume,
                    forgive_balance: forgive_balance,
                    additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
# File 'lib/advanced_billing/models/resume_options.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['require_resume'] = 'require_resume'
  @_hash['forgive_balance'] = 'forgive_balance'
  @_hash
end

.nullablesObject

An array for nullable fields



41
42
43
# File 'lib/advanced_billing/models/resume_options.rb', line 41

def self.nullables
  []
end

.optionalsObject

An array for optional fields



33
34
35
36
37
38
# File 'lib/advanced_billing/models/resume_options.rb', line 33

def self.optionals
  %w[
    require_resume
    forgive_balance
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (ResumeOptions | Hash)

    value against the validation is performed.



77
78
79
80
81
82
83
# File 'lib/advanced_billing/models/resume_options.rb', line 77

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end