Class: NewStoreApi::CreateReservationRequestV1

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

Overview

CreateReservationRequestV1 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(customer_profile_id = nil, items = nil, location_id = nil, associate_id = SKIP, expires_in_min = SKIP, status = SKIP) ⇒ CreateReservationRequestV1

Returns a new instance of CreateReservationRequestV1.



74
75
76
77
78
79
80
81
82
# File 'lib/new_store_api/models/create_reservation_request_v1.rb', line 74

def initialize(customer_profile_id = nil, items = nil, location_id = nil,
               associate_id = SKIP, expires_in_min = SKIP, status = SKIP)
  @associate_id = associate_id unless associate_id == SKIP
  @customer_profile_id = customer_profile_id
  @expires_in_min = expires_in_min unless expires_in_min == SKIP
  @items = items
  @location_id = location_id
  @status = status unless status == SKIP
end

Instance Attribute Details

#associate_idString

ID of the associate who owns the reservation. If not provided, the associate ID present in the JWT will be used. Important: if this method is called using an API client and the 'associate_id' value is not provided, it will be set to null and the reservation won't be linked to any associate.

Returns:

  • (String)


18
19
20
# File 'lib/new_store_api/models/create_reservation_request_v1.rb', line 18

def associate_id
  @associate_id
end

#customer_profile_idString

Profile ID of the customer the reservation is for

Returns:

  • (String)


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

def customer_profile_id
  @customer_profile_id
end

#expires_in_minInteger

Duration of the reservation in minutes. If not provided, the default value is the configured one

or 1440 minutes (if there's no default configured).

Returns:

  • (Integer)


30
31
32
# File 'lib/new_store_api/models/create_reservation_request_v1.rb', line 30

def expires_in_min
  @expires_in_min
end

#itemsArray[ReservationItemRequest]

Items to reserve

Returns:



34
35
36
# File 'lib/new_store_api/models/create_reservation_request_v1.rb', line 34

def items
  @items
end

#location_idString

ID of the fulfillment location the reservation is created in

Returns:

  • (String)


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

def location_id
  @location_id
end

#statusInitialReservationStatusEnum

ID of the fulfillment location the reservation is created in



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

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/new_store_api/models/create_reservation_request_v1.rb', line 85

def self.from_hash(hash)
  return nil unless hash

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

  items = nil unless hash.key?('items')
  location_id = hash.key?('location_id') ? hash['location_id'] : nil
  associate_id = hash.key?('associate_id') ? hash['associate_id'] : SKIP
  expires_in_min =
    hash.key?('expires_in_min') ? hash['expires_in_min'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP

  # Create object from extracted values.
  CreateReservationRequestV1.new(customer_profile_id,
                                 items,
                                 location_id,
                                 associate_id,
                                 expires_in_min,
                                 status)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['associate_id'] = 'associate_id'
  @_hash['customer_profile_id'] = 'customer_profile_id'
  @_hash['expires_in_min'] = 'expires_in_min'
  @_hash['items'] = 'items'
  @_hash['location_id'] = 'location_id'
  @_hash['status'] = 'status'
  @_hash
end

.nullablesObject

An array for nullable fields



66
67
68
69
70
71
72
# File 'lib/new_store_api/models/create_reservation_request_v1.rb', line 66

def self.nullables
  %w[
    associate_id
    expires_in_min
    status
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    associate_id
    expires_in_min
    status
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} associate_id: #{@associate_id.inspect}, customer_profile_id:"\
  " #{@customer_profile_id.inspect}, expires_in_min: #{@expires_in_min.inspect}, items:"\
  " #{@items.inspect}, location_id: #{@location_id.inspect}, status: #{@status.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} associate_id: #{@associate_id}, customer_profile_id:"\
  " #{@customer_profile_id}, expires_in_min: #{@expires_in_min}, items: #{@items},"\
  " location_id: #{@location_id}, status: #{@status}>"
end