Class: NewStoreApi::Fulfillment1

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

Overview

Groups line items under a single fulfillment option.

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_option = nil, line_item_ids = nil) ⇒ Fulfillment1

Returns a new instance of Fulfillment1.



42
43
44
45
# File 'lib/new_store_api/models/fulfillment1.rb', line 42

def initialize(fulfillment_option = nil, line_item_ids = nil)
  @fulfillment_option = fulfillment_option
  @line_item_ids = line_item_ids
end

Instance Attribute Details

#fulfillment_optionFulfillmentOption

Service-level fulfillment option (e.g. in-store handover). The source spec models this as a oneOf; this MVP supports only the service-level variant and omits the shipping (shipping_offer_token) one.

Returns:



16
17
18
# File 'lib/new_store_api/models/fulfillment1.rb', line 16

def fulfillment_option
  @fulfillment_option
end

#line_item_idsArray[String]

The line items fulfilled by this fulfillment. Each value must match a line_items[].line_item_id in the same order. A given line_item_id must appear in exactly one fulfillment.

Returns:

  • (Array[String])


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

def line_item_ids
  @line_item_ids
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/new_store_api/models/fulfillment1.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  fulfillment_option = FulfillmentOption.from_hash(hash['fulfillment_option']) if
    hash['fulfillment_option']
  line_item_ids = hash.key?('line_item_ids') ? hash['line_item_ids'] : nil

  # Create object from extracted values.
  Fulfillment1.new(fulfillment_option,
                   line_item_ids)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['fulfillment_option'] = 'fulfillment_option'
  @_hash['line_item_ids'] = 'line_item_ids'
  @_hash
end

.nullablesObject

An array for nullable fields



38
39
40
# File 'lib/new_store_api/models/fulfillment1.rb', line 38

def self.nullables
  []
end

.optionalsObject

An array for optional fields



33
34
35
# File 'lib/new_store_api/models/fulfillment1.rb', line 33

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



69
70
71
72
73
# File 'lib/new_store_api/models/fulfillment1.rb', line 69

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

#to_sObject

Provides a human-readable string representation of the object.



62
63
64
65
66
# File 'lib/new_store_api/models/fulfillment1.rb', line 62

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