Class: WalmartApIs::GetFulfillmentPreviewRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/get_fulfillment_preview_request.rb

Overview

GetFulfillmentPreviewRequest 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(address:, items:, marketplace_id: MarketplaceId::WALMART_US, shipping_speed_categories: SKIP, include_cod_fulfillment_preview: false, additional_properties: nil) ⇒ GetFulfillmentPreviewRequest

Returns a new instance of GetFulfillmentPreviewRequest.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 58

def initialize(address:, items:, marketplace_id: MarketplaceId::WALMART_US,
               shipping_speed_categories: SKIP,
               include_cod_fulfillment_preview: false,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @marketplace_id = marketplace_id unless marketplace_id == SKIP
  @address = address
  @items = items
  unless shipping_speed_categories == SKIP
    @shipping_speed_categories =
      shipping_speed_categories
  end
  unless include_cod_fulfillment_preview == SKIP
    @include_cod_fulfillment_preview =
      include_cod_fulfillment_preview
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressAddress

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 18

def address
  @address
end

#include_cod_fulfillment_previewTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


30
31
32
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 30

def include_cod_fulfillment_preview
  @include_cod_fulfillment_preview
end

#itemsArray[GetFulfillmentPreviewItem]

TODO: Write general description for this method

Returns:



22
23
24
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 22

def items
  @items
end

#marketplace_idMarketplaceId

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 14

def marketplace_id
  @marketplace_id
end

#shipping_speed_categoriesArray[ShippingSpeedCategory]

TODO: Write general description for this method

Returns:



26
27
28
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 26

def shipping_speed_categories
  @shipping_speed_categories
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 80

def self.from_hash(hash)
  return nil unless hash

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

  items = nil unless hash.key?('items')
  marketplace_id = hash['marketplaceId'] ||= MarketplaceId::WALMART_US
  shipping_speed_categories =
    hash.key?('shippingSpeedCategories') ? hash['shippingSpeedCategories'] : SKIP
  include_cod_fulfillment_preview =
    hash['includeCODFulfillmentPreview'] ||= false

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  GetFulfillmentPreviewRequest.new(address: address,
                                   items: items,
                                   marketplace_id: marketplace_id,
                                   shipping_speed_categories: shipping_speed_categories,
                                   include_cod_fulfillment_preview: include_cod_fulfillment_preview,
                                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
42
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['marketplace_id'] = 'marketplaceId'
  @_hash['address'] = 'address'
  @_hash['items'] = 'items'
  @_hash['shipping_speed_categories'] = 'shippingSpeedCategories'
  @_hash['include_cod_fulfillment_preview'] =
    'includeCODFulfillmentPreview'
  @_hash
end

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 45

def self.optionals
  %w[
    marketplace_id
    shipping_speed_categories
    include_cod_fulfillment_preview
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



126
127
128
129
130
131
132
133
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 126

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} marketplace_id: #{@marketplace_id.inspect}, address: #{@address.inspect},"\
  " items: #{@items.inspect}, shipping_speed_categories:"\
  " #{@shipping_speed_categories.inspect}, include_cod_fulfillment_preview:"\
  " #{@include_cod_fulfillment_preview.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



118
119
120
121
122
123
# File 'lib/walmart_ap_is/models/get_fulfillment_preview_request.rb', line 118

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} marketplace_id: #{@marketplace_id}, address: #{@address}, items: #{@items},"\
  " shipping_speed_categories: #{@shipping_speed_categories}, include_cod_fulfillment_preview:"\
  " #{@include_cod_fulfillment_preview}, additional_properties: #{@additional_properties}>"
end