Class: AdvancedBilling::CancellationOptions

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

Overview

CancellationOptions Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(cancellation_message: SKIP, reason_code: SKIP, additional_properties: {}) ⇒ CancellationOptions

Returns a new instance of CancellationOptions.



43
44
45
46
47
48
49
50
51
52
# File 'lib/advanced_billing/models/cancellation_options.rb', line 43

def initialize(cancellation_message: SKIP, reason_code: SKIP,
               additional_properties: {})
  @cancellation_message = cancellation_message unless cancellation_message == SKIP
  @reason_code = reason_code unless reason_code == SKIP

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

Instance Attribute Details

#cancellation_messageString

For your internal use. An indication as to why the subscription is being canceled.

Returns:

  • (String)


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

def cancellation_message
  @cancellation_message
end

#reason_codeString

The reason code associated with the cancellation. See the list of reason codes associated with your site.

Returns:

  • (String)


20
21
22
# File 'lib/advanced_billing/models/cancellation_options.rb', line 20

def reason_code
  @reason_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/advanced_billing/models/cancellation_options.rb', line 55

def self.from_hash(hash)
  return nil unless hash

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

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

  # Create object from extracted values.
  CancellationOptions.new(cancellation_message: cancellation_message,
                          reason_code: reason_code,
                          additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



23
24
25
26
27
28
# File 'lib/advanced_billing/models/cancellation_options.rb', line 23

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

.nullablesObject

An array for nullable fields



39
40
41
# File 'lib/advanced_billing/models/cancellation_options.rb', line 39

def self.nullables
  []
end

.optionalsObject

An array for optional fields



31
32
33
34
35
36
# File 'lib/advanced_billing/models/cancellation_options.rb', line 31

def self.optionals
  %w[
    cancellation_message
    reason_code
  ]
end