Class: NewStoreApi::Item41

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

Overview

Item41 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 = nil, price = nil, type = nil) ⇒ Item41

Returns a new instance of Item41.



43
44
45
46
47
# File 'lib/new_store_api/models/item41.rb', line 43

def initialize(id = nil, price = nil, type = nil)
  @id = id
  @price = price
  @type = type
end

Instance Attribute Details

#idString

The identifier of the item.

Returns:

  • (String)


14
15
16
# File 'lib/new_store_api/models/item41.rb', line 14

def id
  @id
end

#priceSalesOrderPrice1

The response for retrieving price information.

Returns:



18
19
20
# File 'lib/new_store_api/models/item41.rb', line 18

def price
  @price
end

#typeType11Enum

The response for retrieving price information.

Returns:



22
23
24
# File 'lib/new_store_api/models/item41.rb', line 22

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/new_store_api/models/item41.rb', line 50

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  price = SalesOrderPrice1.from_hash(hash['price']) if hash['price']
  type = hash.key?('type') ? hash['type'] : nil

  # Create object from extracted values.
  Item41.new(id,
             price,
             type)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/new_store_api/models/item41.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['price'] = 'price'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



39
40
41
# File 'lib/new_store_api/models/item41.rb', line 39

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
# File 'lib/new_store_api/models/item41.rb', line 34

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Item41 | Hash)

    value against the validation is performed.



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

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.price,
                              ->(val) { SalesOrderPrice1.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.type,
                              ->(val) { Type11Enum.validate(val) })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['price'],
                            ->(val) { SalesOrderPrice1.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['type'],
                            ->(val) { Type11Enum.validate(val) })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



99
100
101
102
# File 'lib/new_store_api/models/item41.rb', line 99

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

#to_sObject

Provides a human-readable string representation of the object.



93
94
95
96
# File 'lib/new_store_api/models/item41.rb', line 93

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