Class: ApiReference::PriceGroup

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

Overview

PriceGroup 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(grouping_key:, grouping_value:, secondary_grouping_key:, secondary_grouping_value:, total:, quantity: SKIP, additional_properties: nil) ⇒ PriceGroup

Returns a new instance of PriceGroup.



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

def initialize(grouping_key:, grouping_value:, secondary_grouping_key:,
               secondary_grouping_value:, total:, quantity: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @grouping_key = grouping_key
  @grouping_value = grouping_value
  @secondary_grouping_key = secondary_grouping_key
  @secondary_grouping_value = secondary_grouping_value
  @quantity = quantity unless quantity == SKIP
  @total = total
  @additional_properties = additional_properties
end

Instance Attribute Details

#grouping_keyString

Grouping key to break down a single price's costs

Returns:

  • (String)


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

def grouping_key
  @grouping_key
end

#grouping_valueString

Grouping key to break down a single price's costs

Returns:

  • (String)


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

def grouping_value
  @grouping_value
end

#quantityFloat

The price's quantity for the group

Returns:

  • (Float)


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

def quantity
  @quantity
end

#secondary_grouping_keyString

If the price is a matrix price, this is the second dimension key

Returns:

  • (String)


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

def secondary_grouping_key
  @secondary_grouping_key
end

#secondary_grouping_valueString

If the price is a matrix price, this is the second dimension key

Returns:

  • (String)


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

def secondary_grouping_value
  @secondary_grouping_value
end

#totalString

Total costs for this group for the timeframe. Note that this does not account for any minimums or discounts.

Returns:

  • (String)


35
36
37
# File 'lib/api_reference/models/price_group.rb', line 35

def total
  @total
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



82
83
84
85
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
# File 'lib/api_reference/models/price_group.rb', line 82

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  grouping_key = hash.key?('grouping_key') ? hash['grouping_key'] : nil
  grouping_value =
    hash.key?('grouping_value') ? hash['grouping_value'] : nil
  secondary_grouping_key =
    hash.key?('secondary_grouping_key') ? hash['secondary_grouping_key'] : nil
  secondary_grouping_value =
    hash.key?('secondary_grouping_value') ? hash['secondary_grouping_value'] : nil
  total = hash.key?('total') ? hash['total'] : nil
  quantity = hash.key?('quantity') ? hash['quantity'] : 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.
  PriceGroup.new(grouping_key: grouping_key,
                 grouping_value: grouping_value,
                 secondary_grouping_key: secondary_grouping_key,
                 secondary_grouping_value: secondary_grouping_value,
                 total: total,
                 quantity: quantity,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['grouping_key'] = 'grouping_key'
  @_hash['grouping_value'] = 'grouping_value'
  @_hash['secondary_grouping_key'] = 'secondary_grouping_key'
  @_hash['secondary_grouping_value'] = 'secondary_grouping_value'
  @_hash['quantity'] = 'quantity'
  @_hash['total'] = 'total'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    grouping_value
    secondary_grouping_key
    secondary_grouping_value
    quantity
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    quantity
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



123
124
125
126
127
128
129
130
# File 'lib/api_reference/models/price_group.rb', line 123

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} grouping_key: #{@grouping_key.inspect}, grouping_value:"\
  " #{@grouping_value.inspect}, secondary_grouping_key: #{@secondary_grouping_key.inspect},"\
  " secondary_grouping_value: #{@secondary_grouping_value.inspect}, quantity:"\
  " #{@quantity.inspect}, total: #{@total.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



114
115
116
117
118
119
120
# File 'lib/api_reference/models/price_group.rb', line 114

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} grouping_key: #{@grouping_key}, grouping_value: #{@grouping_value},"\
  " secondary_grouping_key: #{@secondary_grouping_key}, secondary_grouping_value:"\
  " #{@secondary_grouping_value}, quantity: #{@quantity}, total: #{@total},"\
  " additional_properties: #{@additional_properties}>"
end