Class: FreightFinancialsWebhookIngestionApi::LineItem

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/freight_financials_webhook_ingestion_api/models/line_item.rb

Overview

LineItem 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(description: SKIP, freight_class: SKIP, handling_unit: SKIP, handling_unit_count: SKIP, item_id: SKIP, weight: SKIP, weight_unit: SKIP) ⇒ LineItem

Returns a new instance of LineItem.



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 78

def initialize(description: SKIP, freight_class: SKIP, handling_unit: SKIP,
               handling_unit_count: SKIP, item_id: SKIP, weight: SKIP,
               weight_unit: SKIP)
  @description = description unless description == SKIP
  @freight_class = freight_class unless freight_class == SKIP
  @handling_unit = handling_unit unless handling_unit == SKIP
  @handling_unit_count = handling_unit_count unless handling_unit_count == SKIP
  @item_id = item_id unless item_id == SKIP
  @weight = weight unless weight == SKIP
  @weight_unit = weight_unit unless weight_unit == SKIP
end

Instance Attribute Details

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 14

def description
  @description
end

#freight_classFloat

TODO: Write general description for this method

Returns:

  • (Float)


18
19
20
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 18

def freight_class
  @freight_class
end

#handling_unitString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 22

def handling_unit
  @handling_unit
end

#handling_unit_countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


26
27
28
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 26

def handling_unit_count
  @handling_unit_count
end

#item_idString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 30

def item_id
  @item_id
end

#weightFloat

TODO: Write general description for this method

Returns:

  • (Float)


34
35
36
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 34

def weight
  @weight
end

#weight_unitString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 38

def weight_unit
  @weight_unit
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  description = hash.key?('description') ? hash['description'] : SKIP
  freight_class = hash.key?('freightClass') ? hash['freightClass'] : SKIP
  handling_unit = hash.key?('handlingUnit') ? hash['handlingUnit'] : SKIP
  handling_unit_count =
    hash.key?('handlingUnitCount') ? hash['handlingUnitCount'] : SKIP
  item_id = hash.key?('itemId') ? hash['itemId'] : SKIP
  weight = hash.key?('weight') ? hash['weight'] : SKIP
  weight_unit = hash.key?('weightUnit') ? hash['weightUnit'] : SKIP

  # Create object from extracted values.
  LineItem.new(description: description,
               freight_class: freight_class,
               handling_unit: handling_unit,
               handling_unit_count: handling_unit_count,
               item_id: item_id,
               weight: weight,
               weight_unit: weight_unit)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['description'] = 'description'
  @_hash['freight_class'] = 'freightClass'
  @_hash['handling_unit'] = 'handlingUnit'
  @_hash['handling_unit_count'] = 'handlingUnitCount'
  @_hash['item_id'] = 'itemId'
  @_hash['weight'] = 'weight'
  @_hash['weight_unit'] = 'weightUnit'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
70
71
72
73
74
75
76
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 67

def self.nullables
  %w[
    description
    freight_class
    handling_unit
    handling_unit_count
    weight
    weight_unit
  ]
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 54

def self.optionals
  %w[
    description
    freight_class
    handling_unit
    handling_unit_count
    item_id
    weight
    weight_unit
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



123
124
125
126
127
128
129
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 123

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description.inspect}, freight_class:"\
  " #{@freight_class.inspect}, handling_unit: #{@handling_unit.inspect}, handling_unit_count:"\
  " #{@handling_unit_count.inspect}, item_id: #{@item_id.inspect}, weight: #{@weight.inspect},"\
  " weight_unit: #{@weight_unit.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



115
116
117
118
119
120
# File 'lib/freight_financials_webhook_ingestion_api/models/line_item.rb', line 115

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description}, freight_class: #{@freight_class},"\
  " handling_unit: #{@handling_unit}, handling_unit_count: #{@handling_unit_count}, item_id:"\
  " #{@item_id}, weight: #{@weight}, weight_unit: #{@weight_unit}>"
end