Class: ApiReference::OtherSubLineItem

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

Overview

OtherSubLineItem 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(amount:, name:, quantity:, grouping:, additional_properties: nil) ⇒ OtherSubLineItem

Returns a new instance of OtherSubLineItem.



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

def initialize(amount:, name:, quantity:, grouping:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @amount = amount
  @name = name
  @quantity = quantity
  @grouping = grouping
  @type = '\'null\''
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountString

The total amount for this sub line item.

Returns:

  • (String)


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

def amount
  @amount
end

#groupingSubLineItemGrouping

The total amount for this sub line item.

Returns:



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

def grouping
  @grouping
end

#nameString

The total amount for this sub line item.

Returns:

  • (String)


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

def name
  @name
end

#quantityFloat

The total amount for this sub line item.

Returns:

  • (Float)


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

def quantity
  @quantity
end

#typeString (readonly)

The total amount for this sub line item.

Returns:

  • (String)


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

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/api_reference/models/other_sub_line_item.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  quantity = hash.key?('quantity') ? hash['quantity'] : nil
  grouping = SubLineItemGrouping.from_hash(hash['grouping']) if hash['grouping']

  # 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.
  OtherSubLineItem.new(amount: amount,
                       name: name,
                       quantity: quantity,
                       grouping: grouping,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/api_reference/models/other_sub_line_item.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['name'] = 'name'
  @_hash['quantity'] = 'quantity'
  @_hash['grouping'] = 'grouping'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    grouping
  ]
end

.optionalsObject

An array for optional fields



44
45
46
# File 'lib/api_reference/models/other_sub_line_item.rb', line 44

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.amount,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.quantity,
                              ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.grouping,
                              ->(val) { SubLineItemGrouping.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.type,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['amount'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['name'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['quantity'],
                            ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['grouping'],
                            ->(val) { SubLineItemGrouping.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['type'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



137
138
139
140
141
142
# File 'lib/api_reference/models/other_sub_line_item.rb', line 137

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, name: #{@name.inspect}, quantity:"\
  " #{@quantity.inspect}, grouping: #{@grouping.inspect}, type: #{@type.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, name: #{@name}, quantity: #{@quantity}, grouping:"\
  " #{@grouping}, type: #{@type}, additional_properties: #{@additional_properties}>"
end