Class: Repull::ReservationWebhookObject

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

Overview

Lightweight reservation snapshot delivered as ‘data.object` on every reservation webhook event. Stable across `reservation.created`, `reservation.updated`, and `reservation.cancelled`. Fetch the full reservation via `GET /v1/reservations/#id` if you need pricing, guest contact info, or audit history — those are deliberately omitted to keep deliveries small.

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 = {}) ⇒ ReservationWebhookObject

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
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
# File 'lib/repull/models/reservation_webhook_object.rb', line 89

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::ReservationWebhookObject` 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::ReservationWebhookObject`. 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?(:'uid')
    self.uid = attributes[:'uid']
  else
    self.uid = nil
  end

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

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

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

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

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

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

Instance Attribute Details

#channelObject

Source channel — ‘airbnb`, `booking`, `vrbo`, `direct`, `owner`, `mid_stay_clean`, etc.



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

def channel
  @channel
end

#checkin_dateObject

Check-in date (local property date, no timezone).



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

def checkin_date
  @checkin_date
end

#checkout_dateObject

Check-out date (local property date, no timezone).



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

def checkout_date
  @checkout_date
end

#customer_idObject

Workspace (customer) id this reservation belongs to.



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

def customer_id
  @customer_id
end

#idObject

Repull-internal reservation id. Pass to ‘GET /v1/reservations/#id`.



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

def id
  @id
end

#listing_idObject

Repull listing id this reservation is on.



29
30
31
# File 'lib/repull/models/reservation_webhook_object.rb', line 29

def listing_id
  @listing_id
end

#statusObject

Lifecycle status — typically ‘confirmed`, `cancelled`, `pending`, `inquiry`.



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

def status
  @status
end

#uidObject

Channel-side confirmation code (Airbnb HM-prefixed, Booking.com numeric, etc.). Stable across the lifetime of the reservation.



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

def uid
  @uid
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



58
59
60
# File 'lib/repull/models/reservation_webhook_object.rb', line 58

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



63
64
65
# File 'lib/repull/models/reservation_webhook_object.rb', line 63

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/repull/models/reservation_webhook_object.rb', line 44

def self.attribute_map
  {
    :'id' => :'id',
    :'uid' => :'uid',
    :'channel' => :'channel',
    :'listing_id' => :'listingId',
    :'customer_id' => :'customerId',
    :'checkin_date' => :'checkinDate',
    :'checkout_date' => :'checkoutDate',
    :'status' => :'status'
  }
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



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/repull/models/reservation_webhook_object.rb', line 317

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



82
83
84
85
# File 'lib/repull/models/reservation_webhook_object.rb', line 82

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/repull/models/reservation_webhook_object.rb', line 68

def self.openapi_types
  {
    :'id' => :'Integer',
    :'uid' => :'String',
    :'channel' => :'String',
    :'listing_id' => :'Integer',
    :'customer_id' => :'Integer',
    :'checkin_date' => :'Date',
    :'checkout_date' => :'Date',
    :'status' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/repull/models/reservation_webhook_object.rb', line 289

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      uid == o.uid &&
      channel == o.channel &&
      listing_id == o.listing_id &&
      customer_id == o.customer_id &&
      checkin_date == o.checkin_date &&
      checkout_date == o.checkout_date &&
      status == o.status
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


304
305
306
# File 'lib/repull/models/reservation_webhook_object.rb', line 304

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



310
311
312
# File 'lib/repull/models/reservation_webhook_object.rb', line 310

def hash
  [id, uid, channel, listing_id, customer_id, checkin_date, checkout_date, status].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/repull/models/reservation_webhook_object.rb', line 154

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 @uid.nil?
    invalid_properties.push('invalid value for "uid", uid cannot be nil.')
  end

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

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

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

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

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

  if @status.nil?
    invalid_properties.push('invalid value for "status", status 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



339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/repull/models/reservation_webhook_object.rb', line 339

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



194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/repull/models/reservation_webhook_object.rb', line 194

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @uid.nil?
  return false if @channel.nil?
  return false if @listing_id.nil?
  return false if @customer_id.nil?
  return false if @checkin_date.nil?
  return false if @checkout_date.nil?
  return false if @status.nil?
  true
end