Class: AdvancedBilling::DunningStepReached

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

Overview

DunningStepReached Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(dunner:, current_step:, next_step:, additional_properties: {}) ⇒ DunningStepReached

Returns a new instance of DunningStepReached.



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

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

  @dunner = dunner
  @current_step = current_step
  @next_step = next_step
end

Instance Attribute Details

#current_stepDunningStepData

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/advanced_billing/models/dunning_step_reached.rb', line 18

def current_step
  @current_step
end

#dunnerDunnerData

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/advanced_billing/models/dunning_step_reached.rb', line 14

def dunner
  @dunner
end

#next_stepDunningStepData

TODO: Write general description for this method

Returns:



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

def next_step
  @next_step
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  dunner = DunnerData.from_hash(hash['dunner']) if hash['dunner']
  current_step = DunningStepData.from_hash(hash['current_step']) if hash['current_step']
  next_step = DunningStepData.from_hash(hash['next_step']) if hash['next_step']

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  DunningStepReached.new(dunner: dunner,
                         current_step: current_step,
                         next_step: next_step,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['dunner'] = 'dunner'
  @_hash['current_step'] = 'current_step'
  @_hash['next_step'] = 'next_step'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
# File 'lib/advanced_billing/models/dunning_step_reached.rb', line 34

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/advanced_billing/models/dunning_step_reached.rb', line 76

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.dunner,
                            ->(val) { DunnerData.validate(val) },
                            is_model_hash: true) and
        APIHelper.valid_type?(value.current_step,
                              ->(val) { DunningStepData.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.next_step,
                              ->(val) { DunningStepData.validate(val) },
                              is_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['dunner'],
                          ->(val) { DunnerData.validate(val) },
                          is_model_hash: true) and
      APIHelper.valid_type?(value['current_step'],
                            ->(val) { DunningStepData.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['next_step'],
                            ->(val) { DunningStepData.validate(val) },
                            is_model_hash: true)
  )
end