Class: ApiReference::QuantityOnlyOverridePrice

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

Overview

QuantityOnlyOverridePrice 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:, fixed_price_quantity:, minimum_amount: SKIP, maximum_amount: SKIP, currency: SKIP, conversion_rate: SKIP, discount: SKIP, additional_properties: nil) ⇒ QuantityOnlyOverridePrice

Returns a new instance of QuantityOnlyOverridePrice.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/api_reference/models/quantity_only_override_price.rb', line 77

def initialize(id:, fixed_price_quantity:, minimum_amount: SKIP,
               maximum_amount: SKIP, currency: SKIP, conversion_rate: SKIP,
               discount: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @minimum_amount = minimum_amount unless minimum_amount == SKIP
  @maximum_amount = maximum_amount unless maximum_amount == SKIP
  @currency = currency unless currency == SKIP
  @conversion_rate = conversion_rate unless conversion_rate == SKIP
  @discount = discount unless discount == SKIP
  @fixed_price_quantity = fixed_price_quantity
  @additional_properties = additional_properties
end

Instance Attribute Details

#conversion_rateFloat

The per unit conversion rate of the price currency to the invoicing currency.

Returns:

  • (Float)


32
33
34
# File 'lib/api_reference/models/quantity_only_override_price.rb', line 32

def conversion_rate
  @conversion_rate
end

#currencyString

The currency of the price. If not provided, the currency of the plan will be used.

Returns:

  • (String)


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

def currency
  @currency
end

#discountDiscountOverride

The subscription's override discount for the plan.

Returns:



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

def discount
  @discount
end

#fixed_price_quantityFloat

The starting quantity of the price, if the price is a fixed price.

Returns:

  • (Float)


40
41
42
# File 'lib/api_reference/models/quantity_only_override_price.rb', line 40

def fixed_price_quantity
  @fixed_price_quantity
end

#idString

TODO: Write general description for this method

Returns:

  • (String)


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

def id
  @id
end

#maximum_amountString

The subscription's override maximum amount for the plan.

Returns:

  • (String)


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

def maximum_amount
  @maximum_amount
end

#minimum_amountString

The subscription's override minimum amount for the plan.

Returns:

  • (String)


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

def minimum_amount
  @minimum_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/api_reference/models/quantity_only_override_price.rb', line 94

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  fixed_price_quantity =
    hash.key?('fixed_price_quantity') ? hash['fixed_price_quantity'] : nil
  minimum_amount =
    hash.key?('minimum_amount') ? hash['minimum_amount'] : SKIP
  maximum_amount =
    hash.key?('maximum_amount') ? hash['maximum_amount'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  conversion_rate =
    hash.key?('conversion_rate') ? hash['conversion_rate'] : SKIP
  discount = DiscountOverride.from_hash(hash['discount']) if hash['discount']

  # 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.
  QuantityOnlyOverridePrice.new(id: id,
                                fixed_price_quantity: fixed_price_quantity,
                                minimum_amount: minimum_amount,
                                maximum_amount: maximum_amount,
                                currency: currency,
                                conversion_rate: conversion_rate,
                                discount: discount,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/api_reference/models/quantity_only_override_price.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['minimum_amount'] = 'minimum_amount'
  @_hash['maximum_amount'] = 'maximum_amount'
  @_hash['currency'] = 'currency'
  @_hash['conversion_rate'] = 'conversion_rate'
  @_hash['discount'] = 'discount'
  @_hash['fixed_price_quantity'] = 'fixed_price_quantity'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    minimum_amount
    maximum_amount
    currency
    conversion_rate
    discount
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    minimum_amount
    maximum_amount
    currency
    conversion_rate
    discount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



138
139
140
141
142
143
144
145
# File 'lib/api_reference/models/quantity_only_override_price.rb', line 138

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, minimum_amount: #{@minimum_amount.inspect},"\
  " maximum_amount: #{@maximum_amount.inspect}, currency: #{@currency.inspect},"\
  " conversion_rate: #{@conversion_rate.inspect}, discount: #{@discount.inspect},"\
  " fixed_price_quantity: #{@fixed_price_quantity.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



129
130
131
132
133
134
135
# File 'lib/api_reference/models/quantity_only_override_price.rb', line 129

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, minimum_amount: #{@minimum_amount}, maximum_amount:"\
  " #{@maximum_amount}, currency: #{@currency}, conversion_rate: #{@conversion_rate},"\
  " discount: #{@discount}, fixed_price_quantity: #{@fixed_price_quantity},"\
  " additional_properties: #{@additional_properties}>"
end