Class: NewStoreApi::FulfillmentRequestItemsStatesRequest

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

Overview

Request payload for marking fulfillment request items as shipped or rejected.

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(line_items = nil, associate_id = SKIP, carrier = SKIP, reason = SKIP, tracking_code = SKIP) ⇒ FulfillmentRequestItemsStatesRequest

Returns a new instance of FulfillmentRequestItemsStatesRequest.



59
60
61
62
63
64
65
66
# File 'lib/new_store_api/models/fulfillment_request_items_states_request.rb', line 59

def initialize(line_items = nil, associate_id = SKIP, carrier = SKIP,
               reason = SKIP, tracking_code = SKIP)
  @associate_id = associate_id unless associate_id == SKIP
  @carrier = carrier unless carrier == SKIP
  @line_items = line_items
  @reason = reason unless reason == SKIP
  @tracking_code = tracking_code unless tracking_code == SKIP
end

Instance Attribute Details

#associate_idString

Identifier of the associate who is changing the items's states.

Returns:

  • (String)


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

def associate_id
  @associate_id
end

#carrierString

Carrier used to ship items, which state is being changed to shipped.

Returns:

  • (String)


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

def carrier
  @carrier
end

#line_itemsArray[LineItem11]

List of fulfillment request items with the target state.

Returns:



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

def line_items
  @line_items
end

#reasonObject

List of fulfillment request items with the target state.

Returns:

  • (Object)


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

def reason
  @reason
end

#tracking_codeString

Tracking code applied to items, which state is being changed to shipped.

Returns:

  • (String)


31
32
33
# File 'lib/new_store_api/models/fulfillment_request_items_states_request.rb', line 31

def tracking_code
  @tracking_code
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
92
93
94
95
96
# File 'lib/new_store_api/models/fulfillment_request_items_states_request.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  line_items = nil
  unless hash['line_items'].nil?
    line_items = []
    hash['line_items'].each do |structure|
      line_items << (LineItem11.from_hash(structure) if structure)
    end
  end

  line_items = nil unless hash.key?('line_items')
  associate_id = hash.key?('associate_id') ? hash['associate_id'] : SKIP
  carrier = hash.key?('carrier') ? hash['carrier'] : SKIP
  reason = hash.key?('reason') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:FulfillmentRequestItemsStatesRequestReason), hash['reason']
  ) : SKIP
  tracking_code = hash.key?('tracking_code') ? hash['tracking_code'] : SKIP

  # Create object from extracted values.
  FulfillmentRequestItemsStatesRequest.new(line_items,
                                           associate_id,
                                           carrier,
                                           reason,
                                           tracking_code)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/new_store_api/models/fulfillment_request_items_states_request.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['associate_id'] = 'associate_id'
  @_hash['carrier'] = 'carrier'
  @_hash['line_items'] = 'line_items'
  @_hash['reason'] = 'reason'
  @_hash['tracking_code'] = 'tracking_code'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/new_store_api/models/fulfillment_request_items_states_request.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
52
# File 'lib/new_store_api/models/fulfillment_request_items_states_request.rb', line 45

def self.optionals
  %w[
    associate_id
    carrier
    reason
    tracking_code
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/new_store_api/models/fulfillment_request_items_states_request.rb', line 100

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.line_items,
                                 ->(val) { LineItem11.validate(val) },
                                 is_model_hash: true,
                                 is_inner_model_hash: true)
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['line_items'],
                        ->(val) { LineItem11.validate(val) },
                        is_model_hash: true,
                        is_inner_model_hash: true)
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



124
125
126
127
128
129
# File 'lib/new_store_api/models/fulfillment_request_items_states_request.rb', line 124

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} associate_id: #{@associate_id.inspect}, carrier: #{@carrier.inspect},"\
  " line_items: #{@line_items.inspect}, reason: #{@reason.inspect}, tracking_code:"\
  " #{@tracking_code.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



117
118
119
120
121
# File 'lib/new_store_api/models/fulfillment_request_items_states_request.rb', line 117

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} associate_id: #{@associate_id}, carrier: #{@carrier}, line_items:"\
  " #{@line_items}, reason: #{@reason}, tracking_code: #{@tracking_code}>"
end