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

#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #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: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @cancellation_message = cancellation_message unless cancellation_message == SKIP
  @reason_code = reason_code unless reason_code == SKIP
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.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  CancellationOptions.new(cancellation_message: cancellation_message,
                          reason_code: reason_code,
                          additional_properties: additional_properties)
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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



80
81
82
83
84
# File 'lib/advanced_billing/models/cancellation_options.rb', line 80

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} cancellation_message: #{@cancellation_message.inspect}, reason_code:"\
  " #{@reason_code.inspect}, additional_properties: #{get_additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



73
74
75
76
77
# File 'lib/advanced_billing/models/cancellation_options.rb', line 73

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} cancellation_message: #{@cancellation_message}, reason_code:"\
  " #{@reason_code}, additional_properties: #{get_additional_properties}>"
end