Class: Repull::Reservation

Inherits:
ApiModelBase show all
Defined in:
lib/repull/models/reservation.rb

Overview

A booking/reservation from a connected PMS. Identical shape between list-row (‘GET /v1/reservations`) and detail (`GET /v1/reservations/#id`) — SDK consumers can use the same type for both.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Reservation

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/repull/models/reservation.rb', line 113

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::Reservation` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Repull::Reservation`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

  if attributes.key?(:'listing_id')
    self.listing_id = attributes[:'listing_id']
  else
    self.listing_id = nil
  end

  if attributes.key?(:'guest_id')
    self.guest_id = attributes[:'guest_id']
  else
    self.guest_id = nil
  end

  if attributes.key?(:'check_in')
    self.check_in = attributes[:'check_in']
  else
    self.check_in = nil
  end

  if attributes.key?(:'check_out')
    self.check_out = attributes[:'check_out']
  else
    self.check_out = nil
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  else
    self.status = nil
  end

  if attributes.key?(:'platform')
    self.platform = attributes[:'platform']
  end

  if attributes.key?(:'total_price')
    self.total_price = attributes[:'total_price']
  else
    self.total_price = nil
  end

  if attributes.key?(:'currency')
    self.currency = attributes[:'currency']
  else
    self.currency = nil
  end

  if attributes.key?(:'confirmation_code')
    self.confirmation_code = attributes[:'confirmation_code']
  else
    self.confirmation_code = nil
  end

  if attributes.key?(:'guest_details')
    if (value = attributes[:'guest_details']).is_a?(Hash)
      self.guest_details = value
    end
  else
    self.guest_details = nil
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  else
    self.created_at = nil
  end

  if attributes.key?(:'guest_name')
    self.guest_name = attributes[:'guest_name']
  end
end

Instance Attribute Details

#check_inObject

Returns the value of attribute check_in.



28
29
30
# File 'lib/repull/models/reservation.rb', line 28

def check_in
  @check_in
end

#check_outObject

Returns the value of attribute check_out.



30
31
32
# File 'lib/repull/models/reservation.rb', line 30

def check_out
  @check_out
end

#confirmation_codeObject

Channel-side confirmation code (Airbnb HMxxx, Booking.com numeric, etc.).



44
45
46
# File 'lib/repull/models/reservation.rb', line 44

def confirmation_code
  @confirmation_code
end

#created_atObject

When the reservation row was created in Repull (not the booking-on-channel timestamp).



50
51
52
# File 'lib/repull/models/reservation.rb', line 50

def created_at
  @created_at
end

#currencyObject

ISO 4217 currency code.



41
42
43
# File 'lib/repull/models/reservation.rb', line 41

def currency
  @currency
end

#guest_detailsObject

Raw guest details from the source channel (firstName, lastName, email, phone, count, etc.). Shape varies by platform — use the dedicated guest endpoint for a normalized profile.



47
48
49
# File 'lib/repull/models/reservation.rb', line 47

def guest_details
  @guest_details
end

#guest_idObject

Internal Repull guest ID. Use ‘GET /v1/guests/#id` for the full profile.



26
27
28
# File 'lib/repull/models/reservation.rb', line 26

def guest_id
  @guest_id
end

#guest_nameObject

Pre-resolved display name (‘firstName lastName`) extracted from `guestDetails`. Null when no first name is available.



53
54
55
# File 'lib/repull/models/reservation.rb', line 53

def guest_name
  @guest_name
end

#idObject

Internal Repull reservation ID



20
21
22
# File 'lib/repull/models/reservation.rb', line 20

def id
  @id
end

#listing_idObject

Internal Repull listing ID this reservation is on.



23
24
25
# File 'lib/repull/models/reservation.rb', line 23

def listing_id
  @listing_id
end

#platformObject

Booking source. Lowercase. May be null on legacy rows.



35
36
37
# File 'lib/repull/models/reservation.rb', line 35

def platform
  @platform
end

#statusObject

Returns the value of attribute status.



32
33
34
# File 'lib/repull/models/reservation.rb', line 32

def status
  @status
end

#total_priceObject

Decimal-as-string (precision 10, scale 2) to preserve precision across mixed-currency totals.



38
39
40
# File 'lib/repull/models/reservation.rb', line 38

def total_price
  @total_price
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



75
76
77
# File 'lib/repull/models/reservation.rb', line 75

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



80
81
82
# File 'lib/repull/models/reservation.rb', line 80

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/repull/models/reservation.rb', line 56

def self.attribute_map
  {
    :'id' => :'id',
    :'listing_id' => :'listingId',
    :'guest_id' => :'guestId',
    :'check_in' => :'checkIn',
    :'check_out' => :'checkOut',
    :'status' => :'status',
    :'platform' => :'platform',
    :'total_price' => :'totalPrice',
    :'currency' => :'currency',
    :'confirmation_code' => :'confirmationCode',
    :'guest_details' => :'guestDetails',
    :'created_at' => :'createdAt',
    :'guest_name' => :'guestName'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/repull/models/reservation.rb', line 419

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



104
105
106
107
108
109
# File 'lib/repull/models/reservation.rb', line 104

def self.openapi_nullable
  Set.new([
    :'platform',
    :'guest_name'
  ])
end

.openapi_typesObject

Attribute type mapping.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/repull/models/reservation.rb', line 85

def self.openapi_types
  {
    :'id' => :'String',
    :'listing_id' => :'String',
    :'guest_id' => :'String',
    :'check_in' => :'Date',
    :'check_out' => :'Date',
    :'status' => :'String',
    :'platform' => :'String',
    :'total_price' => :'String',
    :'currency' => :'String',
    :'confirmation_code' => :'String',
    :'guest_details' => :'Hash<String, Object>',
    :'created_at' => :'Time',
    :'guest_name' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/repull/models/reservation.rb', line 386

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      listing_id == o.listing_id &&
      guest_id == o.guest_id &&
      check_in == o.check_in &&
      check_out == o.check_out &&
      status == o.status &&
      platform == o.platform &&
      total_price == o.total_price &&
      currency == o.currency &&
      confirmation_code == o.confirmation_code &&
      guest_details == o.guest_details &&
      created_at == o.created_at &&
      guest_name == o.guest_name
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


406
407
408
# File 'lib/repull/models/reservation.rb', line 406

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



412
413
414
# File 'lib/repull/models/reservation.rb', line 412

def hash
  [id, listing_id, guest_id, check_in, check_out, status, platform, total_price, currency, confirmation_code, guest_details, created_at, guest_name].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/repull/models/reservation.rb', line 206

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @listing_id.nil?
    invalid_properties.push('invalid value for "listing_id", listing_id cannot be nil.')
  end

  if @guest_id.nil?
    invalid_properties.push('invalid value for "guest_id", guest_id cannot be nil.')
  end

  if @check_in.nil?
    invalid_properties.push('invalid value for "check_in", check_in cannot be nil.')
  end

  if @check_out.nil?
    invalid_properties.push('invalid value for "check_out", check_out cannot be nil.')
  end

  if @status.nil?
    invalid_properties.push('invalid value for "status", status cannot be nil.')
  end

  if @total_price.nil?
    invalid_properties.push('invalid value for "total_price", total_price cannot be nil.')
  end

  if @currency.nil?
    invalid_properties.push('invalid value for "currency", currency cannot be nil.')
  end

  if @confirmation_code.nil?
    invalid_properties.push('invalid value for "confirmation_code", confirmation_code cannot be nil.')
  end

  if @guest_details.nil?
    invalid_properties.push('invalid value for "guest_details", guest_details cannot be nil.')
  end

  if @created_at.nil?
    invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/repull/models/reservation.rb', line 441

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/repull/models/reservation.rb', line 258

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @listing_id.nil?
  return false if @guest_id.nil?
  return false if @check_in.nil?
  return false if @check_out.nil?
  return false if @status.nil?
  return false if @total_price.nil?
  return false if @currency.nil?
  return false if @confirmation_code.nil?
  return false if @guest_details.nil?
  return false if @created_at.nil?
  true
end