Class: NewStoreApi::PackageTypeResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/package_type_response.rb

Overview

A package type that is available for associates to select during the packing flow.

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(dimensions = nil, id = nil, name = nil, weight = nil) ⇒ PackageTypeResponse

Returns a new instance of PackageTypeResponse.



49
50
51
52
53
54
# File 'lib/new_store_api/models/package_type_response.rb', line 49

def initialize(dimensions = nil, id = nil, name = nil, weight = nil)
  @dimensions = dimensions
  @id = id
  @name = name
  @weight = weight
end

Instance Attribute Details

#dimensionsPackageDimensions

The physical dimensions of a package type.

Returns:



15
16
17
# File 'lib/new_store_api/models/package_type_response.rb', line 15

def dimensions
  @dimensions
end

#idUUID | String

Unique identifier of the package type.

Returns:

  • (UUID | String)


19
20
21
# File 'lib/new_store_api/models/package_type_response.rb', line 19

def id
  @id
end

#nameString

Display name shown to associates when selecting a package.

Returns:

  • (String)


23
24
25
# File 'lib/new_store_api/models/package_type_response.rb', line 23

def name
  @name
end

#weightPackageWeight

The weight of a package type.

Returns:



27
28
29
# File 'lib/new_store_api/models/package_type_response.rb', line 27

def weight
  @weight
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/new_store_api/models/package_type_response.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  dimensions = PackageDimensions.from_hash(hash['dimensions']) if hash['dimensions']
  id = hash.key?('id') ? hash['id'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  weight = PackageWeight.from_hash(hash['weight']) if hash['weight']

  # Create object from extracted values.
  PackageTypeResponse.new(dimensions,
                          id,
                          name,
                          weight)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/new_store_api/models/package_type_response.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['dimensions'] = 'dimensions'
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['weight'] = 'weight'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/new_store_api/models/package_type_response.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
# File 'lib/new_store_api/models/package_type_response.rb', line 40

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



81
82
83
84
85
# File 'lib/new_store_api/models/package_type_response.rb', line 81

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} dimensions: #{@dimensions.inspect}, id: #{@id.inspect}, name:"\
  " #{@name.inspect}, weight: #{@weight.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



74
75
76
77
78
# File 'lib/new_store_api/models/package_type_response.rb', line 74

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} dimensions: #{@dimensions}, id: #{@id}, name: #{@name}, weight:"\
  " #{@weight}>"
end