Class: ApiReference::FixedFeeQuantityChange

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

Overview

FixedFeeQuantityChange 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(price_id:, quantity:, effective_date: SKIP, change_option: ChangeOption::IMMEDIATE, allow_invoice_credit_or_void: true) ⇒ FixedFeeQuantityChange

Returns a new instance of FixedFeeQuantityChange.



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

def initialize(price_id:, quantity:, effective_date: SKIP,
               change_option: ChangeOption::IMMEDIATE,
               allow_invoice_credit_or_void: true)
  @price_id = price_id
  @quantity = quantity
  @effective_date = effective_date unless effective_date == SKIP
  @change_option = change_option unless change_option == SKIP
  unless allow_invoice_credit_or_void == SKIP
    @allow_invoice_credit_or_void =
      allow_invoice_credit_or_void
  end
end

Instance Attribute Details

#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)


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

def allow_invoice_credit_or_void
  @allow_invoice_credit_or_void
end

#change_optionChangeOption

Determines when the change takes effect. Note that if effective_date is specified, this defaults to effective_date. Otherwise, this defaults to immediate unless it's explicitly set to upcoming_invoice.

Returns:



30
31
32
# File 'lib/api_reference/models/fixed_fee_quantity_change.rb', line 30

def change_option
  @change_option
end

#effective_dateDate

The date that the quantity change should take effect, localized to the customer's timezone. If this parameter is not passed in, the quantity change is effective according to change_option.

Returns:

  • (Date)


24
25
26
# File 'lib/api_reference/models/fixed_fee_quantity_change.rb', line 24

def effective_date
  @effective_date
end

#price_idString

Price for which the quantity should be updated. Must be a fixed fee.

Returns:

  • (String)


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

def price_id
  @price_id
end

#quantityFloat

Price for which the quantity should be updated. Must be a fixed fee.

Returns:

  • (Float)


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

def quantity
  @quantity
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/api_reference/models/fixed_fee_quantity_change.rb', line 80

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  price_id = hash.key?('price_id') ? hash['price_id'] : nil
  quantity = hash.key?('quantity') ? hash['quantity'] : nil
  effective_date =
    hash.key?('effective_date') ? hash['effective_date'] : SKIP
  change_option = hash['change_option'] ||= ChangeOption::IMMEDIATE
  allow_invoice_credit_or_void =
    hash['allow_invoice_credit_or_void'] ||= true

  # Create object from extracted values.
  FixedFeeQuantityChange.new(price_id: price_id,
                             quantity: quantity,
                             effective_date: effective_date,
                             change_option: change_option,
                             allow_invoice_credit_or_void: allow_invoice_credit_or_void)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['price_id'] = 'price_id'
  @_hash['quantity'] = 'quantity'
  @_hash['effective_date'] = 'effective_date'
  @_hash['change_option'] = 'change_option'
  @_hash['allow_invoice_credit_or_void'] = 'allow_invoice_credit_or_void'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    effective_date
    allow_invoice_credit_or_void
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    effective_date
    change_option
    allow_invoice_credit_or_void
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



109
110
111
112
113
114
# File 'lib/api_reference/models/fixed_fee_quantity_change.rb', line 109

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} price_id: #{@price_id.inspect}, quantity: #{@quantity.inspect},"\
  " effective_date: #{@effective_date.inspect}, change_option: #{@change_option.inspect},"\
  " allow_invoice_credit_or_void: #{@allow_invoice_credit_or_void.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



101
102
103
104
105
106
# File 'lib/api_reference/models/fixed_fee_quantity_change.rb', line 101

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} price_id: #{@price_id}, quantity: #{@quantity}, effective_date:"\
  " #{@effective_date}, change_option: #{@change_option}, allow_invoice_credit_or_void:"\
  " #{@allow_invoice_credit_or_void}>"
end