Class: ApiReference::PlanVersionPhase

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/plan_version_phase.rb

Overview

PlanVersionPhase 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(id:, description:, duration:, duration_unit:, name:, order:, additional_properties: nil) ⇒ PlanVersionPhase

Returns a new instance of PlanVersionPhase.



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/api_reference/models/plan_version_phase.rb', line 66

def initialize(id:, description:, duration:, duration_unit:, name:, order:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @description = description
  @duration = duration
  @duration_unit = duration_unit
  @name = name
  @order = order
  @additional_properties = additional_properties
end

Instance Attribute Details

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/api_reference/models/plan_version_phase.rb', line 18

def description
  @description
end

#durationInteger

How many terms of length duration_unit this phase is active for. If null, this phase is evergreen and active indefinitely

Returns:

  • (Integer)


23
24
25
# File 'lib/api_reference/models/plan_version_phase.rb', line 23

def duration
  @duration
end

#duration_unitDurationUnit3

How many terms of length duration_unit this phase is active for. If null, this phase is evergreen and active indefinitely

Returns:



28
29
30
# File 'lib/api_reference/models/plan_version_phase.rb', line 28

def duration_unit
  @duration_unit
end

#idString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/api_reference/models/plan_version_phase.rb', line 14

def id
  @id
end

#nameString

How many terms of length duration_unit this phase is active for. If null, this phase is evergreen and active indefinitely

Returns:

  • (String)


33
34
35
# File 'lib/api_reference/models/plan_version_phase.rb', line 33

def name
  @name
end

#orderInteger

Determines the ordering of the phase in a plan's lifecycle. 1 = first phase.

Returns:

  • (Integer)


38
39
40
# File 'lib/api_reference/models/plan_version_phase.rb', line 38

def order
  @order
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/api_reference/models/plan_version_phase.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  description = hash.key?('description') ? hash['description'] : nil
  duration = hash.key?('duration') ? hash['duration'] : nil
  duration_unit = hash.key?('duration_unit') ? hash['duration_unit'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  order = hash.key?('order') ? hash['order'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  PlanVersionPhase.new(id: id,
                       description: description,
                       duration: duration,
                       duration_unit: duration_unit,
                       name: name,
                       order: order,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
# File 'lib/api_reference/models/plan_version_phase.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['description'] = 'description'
  @_hash['duration'] = 'duration'
  @_hash['duration_unit'] = 'duration_unit'
  @_hash['name'] = 'name'
  @_hash['order'] = 'order'
  @_hash
end

.nullablesObject

An array for nullable fields



58
59
60
61
62
63
64
# File 'lib/api_reference/models/plan_version_phase.rb', line 58

def self.nullables
  %w[
    description
    duration
    duration_unit
  ]
end

.optionalsObject

An array for optional fields



53
54
55
# File 'lib/api_reference/models/plan_version_phase.rb', line 53

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/api_reference/models/plan_version_phase.rb', line 111

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.description,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.duration,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.duration_unit,
                              ->(val) { DurationUnit3.validate(val) }) and
        APIHelper.valid_type?(value.name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.order,
                              ->(val) { val.instance_of? Integer })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['description'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['duration'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['duration_unit'],
                            ->(val) { DurationUnit3.validate(val) }) and
      APIHelper.valid_type?(value['name'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['order'],
                            ->(val) { val.instance_of? Integer })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



156
157
158
159
160
161
# File 'lib/api_reference/models/plan_version_phase.rb', line 156

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, description: #{@description.inspect}, duration:"\
  " #{@duration.inspect}, duration_unit: #{@duration_unit.inspect}, name: #{@name.inspect},"\
  " order: #{@order.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



148
149
150
151
152
153
# File 'lib/api_reference/models/plan_version_phase.rb', line 148

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, description: #{@description}, duration: #{@duration},"\
  " duration_unit: #{@duration_unit}, name: #{@name}, order: #{@order}, additional_properties:"\
  " #{@additional_properties}>"
end