Class: ApiReference::AddEditPriceIntervalParams

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

Overview

AddEditPriceIntervalParams 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(add: SKIP, edit: SKIP, add_adjustments: SKIP, edit_adjustments: SKIP, can_defer_billing: SKIP, allow_invoice_credit_or_void: true) ⇒ AddEditPriceIntervalParams

Returns a new instance of AddEditPriceIntervalParams.



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/api_reference/models/add_edit_price_interval_params.rb', line 71

def initialize(add: SKIP, edit: SKIP, add_adjustments: SKIP,
               edit_adjustments: SKIP, can_defer_billing: SKIP,
               allow_invoice_credit_or_void: true)
  @add = add unless add == SKIP
  @edit = edit unless edit == SKIP
  @add_adjustments = add_adjustments unless add_adjustments == SKIP
  @edit_adjustments = edit_adjustments unless edit_adjustments == SKIP
  @can_defer_billing = can_defer_billing unless can_defer_billing == SKIP
  unless allow_invoice_credit_or_void == SKIP
    @allow_invoice_credit_or_void =
      allow_invoice_credit_or_void
  end
end

Instance Attribute Details

#addArray[AddPriceIntervalParams]

A list of price intervals to add to the subscription.

Returns:



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

def add
  @add
end

#add_adjustmentsArray[AddAdjustmentIntervalParams]

A list of adjustments to add to the subscription.

Returns:



22
23
24
# File 'lib/api_reference/models/add_edit_price_interval_params.rb', line 22

def add_adjustments
  @add_adjustments
end

#allow_invoice_credit_or_voidTrueClass | FalseClass

If false, this request will fail if it would void an issued invoice or create a credit note. Consider using this as a safety mechanism if you do not expect existing invoices to be changed.

Returns:

  • (TrueClass | FalseClass)


37
38
39
# File 'lib/api_reference/models/add_edit_price_interval_params.rb', line 37

def allow_invoice_credit_or_void
  @allow_invoice_credit_or_void
end

#can_defer_billingTrueClass | FalseClass

If set, the default value to use for added/edited price intervals with an end_date set.

Returns:

  • (TrueClass | FalseClass)


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

def can_defer_billing
  @can_defer_billing
end

#editArray[EditPriceIntervalParams]

A list of price intervals to edit on the subscription.

Returns:



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

def edit
  @edit
end

#edit_adjustmentsArray[EditAdjustmentIntervalParams]

A list of adjustments to edit on the subscription.

Returns:



26
27
28
# File 'lib/api_reference/models/add_edit_price_interval_params.rb', line 26

def edit_adjustments
  @edit_adjustments
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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
# File 'lib/api_reference/models/add_edit_price_interval_params.rb', line 86

def self.from_hash(hash)
  return nil unless hash

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

  add = SKIP unless hash.key?('add')
  # Parameter is an array, so we need to iterate through it
  edit = nil
  unless hash['edit'].nil?
    edit = []
    hash['edit'].each do |structure|
      edit << (EditPriceIntervalParams.from_hash(structure) if structure)
    end
  end

  edit = SKIP unless hash.key?('edit')
  # Parameter is an array, so we need to iterate through it
  add_adjustments = nil
  unless hash['add_adjustments'].nil?
    add_adjustments = []
    hash['add_adjustments'].each do |structure|
      add_adjustments << (AddAdjustmentIntervalParams.from_hash(structure) if structure)
    end
  end

  add_adjustments = SKIP unless hash.key?('add_adjustments')
  # Parameter is an array, so we need to iterate through it
  edit_adjustments = nil
  unless hash['edit_adjustments'].nil?
    edit_adjustments = []
    hash['edit_adjustments'].each do |structure|
      edit_adjustments << (EditAdjustmentIntervalParams.from_hash(structure) if structure)
    end
  end

  edit_adjustments = SKIP unless hash.key?('edit_adjustments')
  can_defer_billing =
    hash.key?('can_defer_billing') ? hash['can_defer_billing'] : SKIP
  allow_invoice_credit_or_void =
    hash['allow_invoice_credit_or_void'] ||= true

  # Create object from extracted values.
  AddEditPriceIntervalParams.new(add: add,
                                 edit: edit,
                                 add_adjustments: add_adjustments,
                                 edit_adjustments: edit_adjustments,
                                 can_defer_billing: can_defer_billing,
                                 allow_invoice_credit_or_void: allow_invoice_credit_or_void)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['add'] = 'add'
  @_hash['edit'] = 'edit'
  @_hash['add_adjustments'] = 'add_adjustments'
  @_hash['edit_adjustments'] = 'edit_adjustments'
  @_hash['can_defer_billing'] = 'can_defer_billing'
  @_hash['allow_invoice_credit_or_void'] = 'allow_invoice_credit_or_void'
  @_hash
end

.nullablesObject

An array for nullable fields



64
65
66
67
68
69
# File 'lib/api_reference/models/add_edit_price_interval_params.rb', line 64

def self.nullables
  %w[
    can_defer_billing
    allow_invoice_credit_or_void
  ]
end

.optionalsObject

An array for optional fields



52
53
54
55
56
57
58
59
60
61
# File 'lib/api_reference/models/add_edit_price_interval_params.rb', line 52

def self.optionals
  %w[
    add
    edit
    add_adjustments
    edit_adjustments
    can_defer_billing
    allow_invoice_credit_or_void
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



153
154
155
156
157
158
159
# File 'lib/api_reference/models/add_edit_price_interval_params.rb', line 153

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} add: #{@add.inspect}, edit: #{@edit.inspect}, add_adjustments:"\
  " #{@add_adjustments.inspect}, edit_adjustments: #{@edit_adjustments.inspect},"\
  " can_defer_billing: #{@can_defer_billing.inspect}, allow_invoice_credit_or_void:"\
  " #{@allow_invoice_credit_or_void.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



145
146
147
148
149
150
# File 'lib/api_reference/models/add_edit_price_interval_params.rb', line 145

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} add: #{@add}, edit: #{@edit}, add_adjustments: #{@add_adjustments},"\
  " edit_adjustments: #{@edit_adjustments}, can_defer_billing: #{@can_defer_billing},"\
  " allow_invoice_credit_or_void: #{@allow_invoice_credit_or_void}>"
end