Class: WalmartApIs::DeliveryWindowOption

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

Overview

Contains information pertaining to a delivery window 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(availability_type:, delivery_window_option_id:, end_date:, start_date:, valid_until:, additional_properties: nil) ⇒ DeliveryWindowOption

Returns a new instance of DeliveryWindowOption.



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 58

def initialize(availability_type:, delivery_window_option_id:, end_date:,
               start_date:, valid_until:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @availability_type = availability_type
  @delivery_window_option_id = delivery_window_option_id
  @end_date = end_date
  @start_date = start_date
  @valid_until = valid_until
  @additional_properties = additional_properties
end

Instance Attribute Details

#availability_typeString

The type of delivery window availability. Values: AVAILABLE, BLOCKED, CONGESTED, DISCOUNTED.

Returns:

  • (String)


16
17
18
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 16

def availability_type
  @availability_type
end

#delivery_window_option_idString

Identifier of a delivery window option.

Returns:

  • (String)


20
21
22
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 20

def delivery_window_option_id
  @delivery_window_option_id
end

#end_dateDateTime

The time at which this delivery window option ends. In ISO 8601 datetime format with pattern yyyy-MM-ddTHH:mmZ.

Returns:

  • (DateTime)


25
26
27
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 25

def end_date
  @end_date
end

#start_dateDateTime

The time at which this delivery window option starts. In ISO 8601 datetime format with pattern yyyy-MM-ddTHH:mmZ.

Returns:

  • (DateTime)


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

def start_date
  @start_date
end

#valid_untilDateTime

The time at which this delivery window option is no longer valid. In ISO 8601 datetime format with pattern yyyy-MM-ddTHH:mmZ.

Returns:

  • (DateTime)


35
36
37
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 35

def valid_until
  @valid_until
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
97
98
99
100
101
102
103
104
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 72

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  availability_type =
    hash.key?('availabilityType') ? hash['availabilityType'] : nil
  delivery_window_option_id =
    hash.key?('deliveryWindowOptionId') ? hash['deliveryWindowOptionId'] : nil
  end_date = if hash.key?('endDate')
               (DateTimeHelper.from_rfc3339(hash['endDate']) if hash['endDate'])
             end
  start_date = if hash.key?('startDate')
                 (DateTimeHelper.from_rfc3339(hash['startDate']) if hash['startDate'])
               end
  valid_until = if hash.key?('validUntil')
                  (DateTimeHelper.from_rfc3339(hash['validUntil']) if hash['validUntil'])
                end

  # 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.
  DeliveryWindowOption.new(availability_type: availability_type,
                           delivery_window_option_id: delivery_window_option_id,
                           end_date: end_date,
                           start_date: start_date,
                           valid_until: valid_until,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['availability_type'] = 'availabilityType'
  @_hash['delivery_window_option_id'] = 'deliveryWindowOptionId'
  @_hash['end_date'] = 'endDate'
  @_hash['start_date'] = 'startDate'
  @_hash['valid_until'] = 'validUntil'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 49

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} availability_type: #{@availability_type.inspect},"\
  " delivery_window_option_id: #{@delivery_window_option_id.inspect}, end_date:"\
  " #{@end_date.inspect}, start_date: #{@start_date.inspect}, valid_until:"\
  " #{@valid_until.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_end_dateObject



106
107
108
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 106

def to_custom_end_date
  DateTimeHelper.to_rfc3339(end_date)
end

#to_custom_start_dateObject



110
111
112
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 110

def to_custom_start_date
  DateTimeHelper.to_rfc3339(start_date)
end

#to_custom_valid_untilObject



114
115
116
# File 'lib/walmart_ap_is/models/delivery_window_option.rb', line 114

def to_custom_valid_until
  DateTimeHelper.to_rfc3339(valid_until)
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} availability_type: #{@availability_type}, delivery_window_option_id:"\
  " #{@delivery_window_option_id}, end_date: #{@end_date}, start_date: #{@start_date},"\
  " valid_until: #{@valid_until}, additional_properties: #{@additional_properties}>"
end