Class: NewStoreApi::Item9

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

Overview

Item9 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(fulfillment_location_id = nil, id = nil, product_id = nil, quantity = nil, shipping_service_level = nil, status = nil, shipping_method = SKIP) ⇒ Item9

Returns a new instance of Item9.



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/new_store_api/models/item9.rb', line 68

def initialize(fulfillment_location_id = nil, id = nil, product_id = nil,
               quantity = nil, shipping_service_level = nil, status = nil,
               shipping_method = SKIP)
  @fulfillment_location_id = fulfillment_location_id
  @id = id
  @product_id = product_id
  @quantity = quantity
  @shipping_method = shipping_method unless shipping_method == SKIP
  @shipping_service_level = shipping_service_level
  @status = status
end

Instance Attribute Details

#fulfillment_location_idString

The location (warehouse or store) where the item is going to be fulfilled or was fulfilled.

Returns:

  • (String)


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

def fulfillment_location_id
  @fulfillment_location_id
end

#idString

Unique identifier of the item in the order. This identifier is used in all events that notify about item changes.

Returns:

  • (String)


20
21
22
# File 'lib/new_store_api/models/item9.rb', line 20

def id
  @id
end

#product_idString

The identifier of the corresponding product.

Returns:

  • (String)


24
25
26
# File 'lib/new_store_api/models/item9.rb', line 24

def product_id
  @product_id
end

#quantityInteger

The sold quantity (always 1).

Returns:

  • (Integer)


28
29
30
# File 'lib/new_store_api/models/item9.rb', line 28

def quantity
  @quantity
end

#shipping_methodString

Indicates the type of shipping used for the order item.

Returns:

  • (String)


32
33
34
# File 'lib/new_store_api/models/item9.rb', line 32

def shipping_method
  @shipping_method
end

#shipping_service_levelString

The shipping service level of the order. This the service_level_identifier configured as part of each shipping option.

Returns:

  • (String)


37
38
39
# File 'lib/new_store_api/models/item9.rb', line 37

def shipping_service_level
  @shipping_service_level
end

#statusString

Current status of the item (e.g. shipped, cancelled).

Returns:

  • (String)


41
42
43
# File 'lib/new_store_api/models/item9.rb', line 41

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/new_store_api/models/item9.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  fulfillment_location_id =
    hash.key?('fulfillment_location_id') ? hash['fulfillment_location_id'] : nil
  id = hash.key?('id') ? hash['id'] : nil
  product_id = hash.key?('product_id') ? hash['product_id'] : nil
  quantity = hash.key?('quantity') ? hash['quantity'] : nil
  shipping_service_level =
    hash.key?('shipping_service_level') ? hash['shipping_service_level'] : nil
  status = hash.key?('status') ? hash['status'] : nil
  shipping_method =
    hash.key?('shipping_method') ? hash['shipping_method'] : SKIP

  # Create object from extracted values.
  Item9.new(fulfillment_location_id,
            id,
            product_id,
            quantity,
            shipping_service_level,
            status,
            shipping_method)
end

.namesObject

A mapping from model property names to API property names.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/new_store_api/models/item9.rb', line 44

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['fulfillment_location_id'] = 'fulfillment_location_id'
  @_hash['id'] = 'id'
  @_hash['product_id'] = 'product_id'
  @_hash['quantity'] = 'quantity'
  @_hash['shipping_method'] = 'shipping_method'
  @_hash['shipping_service_level'] = 'shipping_service_level'
  @_hash['status'] = 'status'
  @_hash
end

.nullablesObject

An array for nullable fields



64
65
66
# File 'lib/new_store_api/models/item9.rb', line 64

def self.nullables
  []
end

.optionalsObject

An array for optional fields



57
58
59
60
61
# File 'lib/new_store_api/models/item9.rb', line 57

def self.optionals
  %w[
    shipping_method
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Item9 | Hash)

    value against the validation is performed.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/new_store_api/models/item9.rb', line 108

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.fulfillment_location_id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.product_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.quantity,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.shipping_service_level,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.status,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['fulfillment_location_id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['product_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['quantity'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['shipping_service_level'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['status'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



153
154
155
156
157
158
159
# File 'lib/new_store_api/models/item9.rb', line 153

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} fulfillment_location_id: #{@fulfillment_location_id.inspect}, id:"\
  " #{@id.inspect}, product_id: #{@product_id.inspect}, quantity: #{@quantity.inspect},"\
  " shipping_method: #{@shipping_method.inspect}, shipping_service_level:"\
  " #{@shipping_service_level.inspect}, status: #{@status.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



145
146
147
148
149
150
# File 'lib/new_store_api/models/item9.rb', line 145

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} fulfillment_location_id: #{@fulfillment_location_id}, id: #{@id},"\
  " product_id: #{@product_id}, quantity: #{@quantity}, shipping_method: #{@shipping_method},"\
  " shipping_service_level: #{@shipping_service_level}, status: #{@status}>"
end