Class: ApiReference::PlanPhaseMinimumAdjustment

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

Overview

PlanPhaseMinimumAdjustment 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:, is_invoice_level:, filters:, applies_to_price_ids:, reason:, replaces_adjustment_id:, minimum_amount:, item_id:, plan_phase_order:, additional_properties: nil) ⇒ PlanPhaseMinimumAdjustment

Returns a new instance of PlanPhaseMinimumAdjustment.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 86

def initialize(id:, is_invoice_level:, filters:, applies_to_price_ids:,
               reason:, replaces_adjustment_id:, minimum_amount:, item_id:,
               plan_phase_order:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @is_invoice_level = is_invoice_level
  @filters = filters
  @applies_to_price_ids = applies_to_price_ids
  @reason = reason
  @replaces_adjustment_id = replaces_adjustment_id
  @adjustment_type = 'minimum'
  @minimum_amount = minimum_amount
  @item_id = item_id
  @plan_phase_order = plan_phase_order
  @additional_properties = additional_properties
end

Instance Attribute Details

#adjustment_typeString (readonly)

The adjustment id this adjustment replaces. This adjustment will take the place of the replaced adjustment in plan version migrations.

Returns:

  • (String)


41
42
43
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 41

def adjustment_type
  @adjustment_type
end

#applies_to_price_idsArray[String]

The price IDs that this adjustment applies to.

Returns:

  • (Array[String])


27
28
29
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 27

def applies_to_price_ids
  @applies_to_price_ids
end

#filtersArray[PriceFilter]

The filters that determine which prices to apply this adjustment to.

Returns:



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

def filters
  @filters
end

#idString

TODO: Write general description for this method

Returns:

  • (String)


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

def id
  @id
end

#is_invoice_levelTrueClass | FalseClass

True for adjustments that apply to an entire invoice, false for adjustments that apply to only one price.

Returns:

  • (TrueClass | FalseClass)


19
20
21
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 19

def is_invoice_level
  @is_invoice_level
end

#item_idString

The item ID that revenue from this minimum will be attributed to.

Returns:

  • (String)


50
51
52
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 50

def item_id
  @item_id
end

#minimum_amountString

The minimum amount to charge in a given billing period for the prices this adjustment applies to.

Returns:

  • (String)


46
47
48
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 46

def minimum_amount
  @minimum_amount
end

#plan_phase_orderInteger

The plan phase in which this adjustment is active.

Returns:

  • (Integer)


54
55
56
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 54

def plan_phase_order
  @plan_phase_order
end

#reasonString

The reason for the adjustment.

Returns:

  • (String)


31
32
33
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 31

def reason
  @reason
end

#replaces_adjustment_idString

The adjustment id this adjustment replaces. This adjustment will take the place of the replaced adjustment in plan version migrations.

Returns:

  • (String)


36
37
38
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 36

def replaces_adjustment_id
  @replaces_adjustment_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



106
107
108
109
110
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
146
147
148
149
150
151
152
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 106

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  is_invoice_level =
    hash.key?('is_invoice_level') ? hash['is_invoice_level'] : nil
  # Parameter is an array, so we need to iterate through it
  filters = nil
  unless hash['filters'].nil?
    filters = []
    hash['filters'].each do |structure|
      filters << (PriceFilter.from_hash(structure) if structure)
    end
  end

  filters = nil unless hash.key?('filters')
  applies_to_price_ids =
    hash.key?('applies_to_price_ids') ? hash['applies_to_price_ids'] : nil
  reason = hash.key?('reason') ? hash['reason'] : nil
  replaces_adjustment_id =
    hash.key?('replaces_adjustment_id') ? hash['replaces_adjustment_id'] : nil
  minimum_amount =
    hash.key?('minimum_amount') ? hash['minimum_amount'] : nil
  item_id = hash.key?('item_id') ? hash['item_id'] : nil
  plan_phase_order =
    hash.key?('plan_phase_order') ? hash['plan_phase_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.
  PlanPhaseMinimumAdjustment.new(id: id,
                                 is_invoice_level: is_invoice_level,
                                 filters: filters,
                                 applies_to_price_ids: applies_to_price_ids,
                                 reason: reason,
                                 replaces_adjustment_id: replaces_adjustment_id,
                                 minimum_amount: minimum_amount,
                                 item_id: item_id,
                                 plan_phase_order: plan_phase_order,
                                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['is_invoice_level'] = 'is_invoice_level'
  @_hash['filters'] = 'filters'
  @_hash['applies_to_price_ids'] = 'applies_to_price_ids'
  @_hash['reason'] = 'reason'
  @_hash['replaces_adjustment_id'] = 'replaces_adjustment_id'
  @_hash['adjustment_type'] = 'adjustment_type'
  @_hash['minimum_amount'] = 'minimum_amount'
  @_hash['item_id'] = 'item_id'
  @_hash['plan_phase_order'] = 'plan_phase_order'
  @_hash
end

.nullablesObject

An array for nullable fields



78
79
80
81
82
83
84
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 78

def self.nullables
  %w[
    reason
    replaces_adjustment_id
    plan_phase_order
  ]
end

.optionalsObject

An array for optional fields



73
74
75
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 73

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 156

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.is_invoice_level,
                              ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and
        APIHelper.valid_type?(value.filters,
                              ->(val) { PriceFilter.validate(val) },
                              is_model_hash: true,
                              is_inner_model_hash: true) and
        APIHelper.valid_type?(value.applies_to_price_ids,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.reason,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.replaces_adjustment_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.adjustment_type,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.minimum_amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.item_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.plan_phase_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['is_invoice_level'],
                            ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and
      APIHelper.valid_type?(value['filters'],
                            ->(val) { PriceFilter.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true) and
      APIHelper.valid_type?(value['applies_to_price_ids'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['reason'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['replaces_adjustment_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['adjustment_type'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['minimum_amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['item_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['plan_phase_order'],
                            ->(val) { val.instance_of? Integer })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



223
224
225
226
227
228
229
230
231
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 223

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, is_invoice_level: #{@is_invoice_level.inspect},"\
  " filters: #{@filters.inspect}, applies_to_price_ids: #{@applies_to_price_ids.inspect},"\
  " reason: #{@reason.inspect}, replaces_adjustment_id: #{@replaces_adjustment_id.inspect},"\
  " adjustment_type: #{@adjustment_type.inspect}, minimum_amount: #{@minimum_amount.inspect},"\
  " item_id: #{@item_id.inspect}, plan_phase_order: #{@plan_phase_order.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



213
214
215
216
217
218
219
220
# File 'lib/api_reference/models/plan_phase_minimum_adjustment.rb', line 213

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, is_invoice_level: #{@is_invoice_level}, filters: #{@filters},"\
  " applies_to_price_ids: #{@applies_to_price_ids}, reason: #{@reason},"\
  " replaces_adjustment_id: #{@replaces_adjustment_id}, adjustment_type: #{@adjustment_type},"\
  " minimum_amount: #{@minimum_amount}, item_id: #{@item_id}, plan_phase_order:"\
  " #{@plan_phase_order}, additional_properties: #{@additional_properties}>"
end