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

#to_hash, #to_json

Constructor Details

#initialize(dunner = nil, current_step = nil, next_step = nil) ⇒ DunningStepReached



43
44
45
46
47
# File 'lib/advanced_billing/models/dunning_step_reached.rb', line 43

def initialize(dunner = nil, current_step = nil, next_step = nil)
  @dunner = dunner
  @current_step = current_step
  @next_step = next_step
end

Instance Attribute Details

#current_stepDunningStepData

TODO: Write general description for this method



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



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



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.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/advanced_billing/models/dunning_step_reached.rb', line 50

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']

  # Create object from extracted values.

  DunningStepReached.new(dunner,
                         current_step,
                         next_step)
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.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/advanced_billing/models/dunning_step_reached.rb', line 66

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