Class: ApiReference::AddAdjustmentIntervalParams

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

Overview

AddAdjustmentIntervalParams 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(start_date:, adjustment_id: SKIP, adjustment: SKIP, end_date: SKIP, additional_properties: nil) ⇒ AddAdjustmentIntervalParams

Returns a new instance of AddAdjustmentIntervalParams.



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

def initialize(start_date:, adjustment_id: SKIP, adjustment: SKIP,
               end_date: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @adjustment_id = adjustment_id unless adjustment_id == SKIP
  @adjustment = adjustment unless adjustment == SKIP
  @start_date = start_date
  @end_date = end_date unless end_date == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#adjustmentObject

The definition of a new adjustment to create and add to the subscription.

Returns:

  • (Object)


20
21
22
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 20

def adjustment
  @adjustment
end

#adjustment_idString

The ID of the adjustment to add to the subscription. Adjustment IDs can be re-used from existing subscriptions or plans, but adjustments associated with coupon redemptions cannot be re-used.

Returns:

  • (String)


16
17
18
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 16

def adjustment_id
  @adjustment_id
end

#end_dateObject

The end date of the adjustment interval. This is the date that the adjustment will stop affecting prices on the subscription. The adjustment will apply to invoice dates that overlap with this end_date.This end_date is treated as exclusive for in-advance prices, and inclusive for in-arrears prices.

Returns:

  • (Object)


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

def end_date
  @end_date
end

#start_dateObject

The start date of the adjustment interval. This is the date that the adjustment will start affecting prices on the subscription. The adjustment will apply to invoice dates that overlap with this start_date. This start_date is treated as inclusive for in-advance prices, and exclusive for in-arrears prices.

Returns:

  • (Object)


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

def start_date
  @start_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
105
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  start_date = hash.key?('start_date') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:AddAdjustmentIntervalParamsStartDate), hash['start_date']
  ) : nil
  adjustment_id = hash.key?('adjustment_id') ? hash['adjustment_id'] : SKIP
  adjustment = hash.key?('adjustment') ? hash['adjustment'] : SKIP
  end_date = hash.key?('end_date') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:AddAdjustmentIntervalParamsEndDate), hash['end_date']
  ) : SKIP

  # 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.
  AddAdjustmentIntervalParams.new(start_date: start_date,
                                  adjustment_id: adjustment_id,
                                  adjustment: adjustment,
                                  end_date: end_date,
                                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['adjustment_id'] = 'adjustment_id'
  @_hash['adjustment'] = 'adjustment'
  @_hash['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    adjustment_id
    adjustment
    end_date
  ]
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 49

def self.optionals
  %w[
    adjustment_id
    adjustment
    end_date
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



121
122
123
124
125
126
127
128
129
130
131
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 121

def self.validate(value)
  if value.instance_of? self
    return UnionTypeLookUp.get(:AddAdjustmentIntervalParamsStartDate)
                          .validate(value.start_date)
  end

  return false unless value.instance_of? Hash

  UnionTypeLookUp.get(:AddAdjustmentIntervalParamsStartDate)
                 .validate(value['start_date'])
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



141
142
143
144
145
146
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 141

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} adjustment_id: #{@adjustment_id.inspect}, adjustment:"\
  " #{@adjustment.inspect}, start_date: #{@start_date.inspect}, end_date:"\
  " #{@end_date.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



134
135
136
137
138
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 134

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} adjustment_id: #{@adjustment_id}, adjustment: #{@adjustment}, start_date:"\
  " #{@start_date}, end_date: #{@end_date}, additional_properties: #{@additional_properties}>"
end

#to_union_type_end_dateObject



113
114
115
116
117
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 113

def to_union_type_end_date
  UnionTypeLookUp.get(:AddAdjustmentIntervalParamsEndDate)
                 .validate(end_date)
                 .serialize(end_date)
end

#to_union_type_start_dateObject



107
108
109
110
111
# File 'lib/api_reference/models/add_adjustment_interval_params.rb', line 107

def to_union_type_start_date
  UnionTypeLookUp.get(:AddAdjustmentIntervalParamsStartDate)
                 .validate(start_date)
                 .serialize(start_date)
end