Class: Repull::ReservationsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/repull/api/reservations_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ReservationsApi

Returns a new instance of ReservationsApi.



19
20
21
# File 'lib/repull/api/reservations_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/repull/api/reservations_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#cancel_reservation(id, opts = {}) ⇒ nil

Cancel reservation Cancel an existing reservation. Cancellation rules vary by provider — Airbnb host-cancellations carry penalties; Booking.com cancellations apply the per-rate-plan policy. Once 200 is returned, the upstream PMS state is committed.

Parameters:

  • id (Integer)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


27
28
29
30
# File 'lib/repull/api/reservations_api.rb', line 27

def cancel_reservation(id, opts = {})
  cancel_reservation_with_http_info(id, opts)
  nil
end

#cancel_reservation_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Cancel reservation Cancel an existing reservation. Cancellation rules vary by provider — Airbnb host-cancellations carry penalties; Booking.com cancellations apply the per-rate-plan policy. Once 200 is returned, the upstream PMS state is committed.

Parameters:

  • id (Integer)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/repull/api/reservations_api.rb', line 37

def cancel_reservation_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ReservationsApi.cancel_reservation ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ReservationsApi.cancel_reservation"
  end
  # resource path
  local_var_path = '/v1/reservations/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ReservationsApi.cancel_reservation",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ReservationsApi#cancel_reservation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_reservation(create_reservation_request, opts = {}) ⇒ Reservation

Create a reservation Create a reservation in the source PMS. Required fields depend on the connected provider (e.g. Airbnb requires guest email; Booking.com requires hotel id). Validation errors return 422 with the offending ‘field` populated.

Parameters:

Returns:



88
89
90
91
# File 'lib/repull/api/reservations_api.rb', line 88

def create_reservation(create_reservation_request, opts = {})
  data, _status_code, _headers = create_reservation_with_http_info(create_reservation_request, opts)
  data
end

#create_reservation_with_http_info(create_reservation_request, opts = {}) ⇒ Array<(Reservation, Integer, Hash)>

Create a reservation Create a reservation in the source PMS. Required fields depend on the connected provider (e.g. Airbnb requires guest email; Booking.com requires hotel id). Validation errors return 422 with the offending &#x60;field&#x60; populated.

Parameters:

Returns:

  • (Array<(Reservation, Integer, Hash)>)

    Reservation data, response status code and response headers



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
# File 'lib/repull/api/reservations_api.rb', line 98

def create_reservation_with_http_info(create_reservation_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ReservationsApi.create_reservation ...'
  end
  # verify the required parameter 'create_reservation_request' is set
  if @api_client.config.client_side_validation && create_reservation_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_reservation_request' when calling ReservationsApi.create_reservation"
  end
  # resource path
  local_var_path = '/v1/reservations'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_reservation_request)

  # return_type
  return_type = opts[:debug_return_type] || 'Reservation'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ReservationsApi.create_reservation",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ReservationsApi#create_reservation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_reservation(id, opts = {}) ⇒ Reservation

Get reservation details Returns the full record for a single reservation, scoped to the authenticated workspace. Response shape is identical to a single row in ‘GET /v1/reservations` so SDK consumers can use the same type for both. Returns 404 if the id does not exist OR belongs to a different workspace — the API never differentiates the two so caller can’t enumerate other workspaces’ ids.

Parameters:

  • id (Integer)

    Internal Repull reservation ID.

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

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: &#x60;native&#x60; (default), &#x60;calry&#x60;, &#x60;calry-v1&#x60;. Custom: any schema name created via &#x60;POST /v1/schema/custom&#x60;. Unknown / inactive schema names fall back to &#x60;native&#x60;.

Returns:



157
158
159
160
# File 'lib/repull/api/reservations_api.rb', line 157

def get_reservation(id, opts = {})
  data, _status_code, _headers = get_reservation_with_http_info(id, opts)
  data
end

#get_reservation_with_http_info(id, opts = {}) ⇒ Array<(Reservation, Integer, Hash)>

Get reservation details Returns the full record for a single reservation, scoped to the authenticated workspace. Response shape is identical to a single row in &#x60;GET /v1/reservations&#x60; so SDK consumers can use the same type for both. Returns 404 if the id does not exist OR belongs to a different workspace — the API never differentiates the two so caller can&#39;t enumerate other workspaces&#39; ids.

Parameters:

  • id (Integer)

    Internal Repull reservation ID.

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

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: &#x60;native&#x60; (default), &#x60;calry&#x60;, &#x60;calry-v1&#x60;. Custom: any schema name created via &#x60;POST /v1/schema/custom&#x60;. Unknown / inactive schema names fall back to &#x60;native&#x60;.

Returns:

  • (Array<(Reservation, Integer, Hash)>)

    Reservation data, response status code and response headers



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
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/repull/api/reservations_api.rb', line 168

def get_reservation_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ReservationsApi.get_reservation ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ReservationsApi.get_reservation"
  end
  # resource path
  local_var_path = '/v1/reservations/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Schema'] = opts[:'x_schema'] if !opts[:'x_schema'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Reservation'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ReservationsApi.get_reservation",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ReservationsApi#get_reservation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_reservations(opts = {}) ⇒ ReservationListResponse

List reservations Cursor-paginated list of reservations across all connected PMS platforms. Filter by platform, status, listing, or check-in date range. Pagination: Walk pages with ‘?cursor=` — pass `pagination.nextCursor` from one response back as `?cursor=` on the next request. Stop when `pagination.hasMore` is `false`. `limit` defaults to 50, max 100; requesting more returns 422 (no silent truncation). **Breaking change:** `?offset=` is no longer accepted. Requests passing it return 422 with a `did_you_mean: ’cursor’‘ hint.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: &#x60;native&#x60; (default), &#x60;calry&#x60;, &#x60;calry-v1&#x60;. Custom: any schema name created via &#x60;POST /v1/schema/custom&#x60;. Unknown / inactive schema names fall back to &#x60;native&#x60;.

  • :limit (Integer)

    Page size (max 100). Requests over the cap return 422. (default to 50)

  • :cursor (String)

    Opaque cursor returned in the previous response&#39;s &#x60;pagination.nextCursor&#x60;. Omit to fetch the first page.

  • :platform (String)

    Filter by booking platform

  • :status (String)
  • :listing_id (Integer)

    Filter to a single listing

  • :check_in_after (Date)

    Check-in date &gt;&#x3D; this value

  • :check_in_before (Date)

    Check-in date &lt;&#x3D; this value

  • :check_in_from (Date)

    Deprecated alias for &#x60;check_in_after&#x60;.

  • :check_in_to (Date)

    Deprecated alias for &#x60;check_in_before&#x60;.

  • :include_total (Boolean)

    When &#x60;true&#x60; (default), the response&#39;s &#x60;pagination.total&#x60; carries the count of rows matching the current filter, across all pages. Pass &#x60;false&#x60; to skip the count for very large workspaces where the per-page COUNT(*) cost matters. (default to true)

Returns:



232
233
234
235
# File 'lib/repull/api/reservations_api.rb', line 232

def list_reservations(opts = {})
  data, _status_code, _headers = list_reservations_with_http_info(opts)
  data
end

#list_reservations_with_http_info(opts = {}) ⇒ Array<(ReservationListResponse, Integer, Hash)>

List reservations Cursor-paginated list of reservations across all connected PMS platforms. Filter by platform, status, listing, or check-in date range. Pagination: Walk pages with &#x60;?cursor&#x3D;&#x60; — pass &#x60;pagination.nextCursor&#x60; from one response back as &#x60;?cursor&#x3D;&#x60; on the next request. Stop when &#x60;pagination.hasMore&#x60; is &#x60;false&#x60;. &#x60;limit&#x60; defaults to 50, max 100; requesting more returns 422 (no silent truncation). **Breaking change:** &#x60;?offset&#x3D;&#x60; is no longer accepted. Requests passing it return 422 with a &#x60;did_you_mean: &#39;cursor&#39;&#x60; hint.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: &#x60;native&#x60; (default), &#x60;calry&#x60;, &#x60;calry-v1&#x60;. Custom: any schema name created via &#x60;POST /v1/schema/custom&#x60;. Unknown / inactive schema names fall back to &#x60;native&#x60;.

  • :limit (Integer)

    Page size (max 100). Requests over the cap return 422. (default to 50)

  • :cursor (String)

    Opaque cursor returned in the previous response&#39;s &#x60;pagination.nextCursor&#x60;. Omit to fetch the first page.

  • :platform (String)

    Filter by booking platform

  • :status (String)
  • :listing_id (Integer)

    Filter to a single listing

  • :check_in_after (Date)

    Check-in date &gt;&#x3D; this value

  • :check_in_before (Date)

    Check-in date &lt;&#x3D; this value

  • :check_in_from (Date)

    Deprecated alias for &#x60;check_in_after&#x60;.

  • :check_in_to (Date)

    Deprecated alias for &#x60;check_in_before&#x60;.

  • :include_total (Boolean)

    When &#x60;true&#x60; (default), the response&#39;s &#x60;pagination.total&#x60; carries the count of rows matching the current filter, across all pages. Pass &#x60;false&#x60; to skip the count for very large workspaces where the per-page COUNT(*) cost matters. (default to true)

Returns:

  • (Array<(ReservationListResponse, Integer, Hash)>)

    ReservationListResponse data, response status code and response headers



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/repull/api/reservations_api.rb', line 252

def list_reservations_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ReservationsApi.list_reservations ...'
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ReservationsApi.list_reservations, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ReservationsApi.list_reservations, must be greater than or equal to 1.'
  end

  allowable_values = ["confirmed", "pending", "cancelled", "completed"]
  if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
    fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/reservations'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
  query_params[:'platform'] = opts[:'platform'] if !opts[:'platform'].nil?
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'listingId'] = opts[:'listing_id'] if !opts[:'listing_id'].nil?
  query_params[:'check_in_after'] = opts[:'check_in_after'] if !opts[:'check_in_after'].nil?
  query_params[:'check_in_before'] = opts[:'check_in_before'] if !opts[:'check_in_before'].nil?
  query_params[:'checkInFrom'] = opts[:'check_in_from'] if !opts[:'check_in_from'].nil?
  query_params[:'checkInTo'] = opts[:'check_in_to'] if !opts[:'check_in_to'].nil?
  query_params[:'include_total'] = opts[:'include_total'] if !opts[:'include_total'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Schema'] = opts[:'x_schema'] if !opts[:'x_schema'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ReservationListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ReservationsApi.list_reservations",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ReservationsApi#list_reservations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_reservation(id, opts = {}) ⇒ nil

Update reservation Patch reservation fields (dates, status, special requests). Only fields included in the body are modified. Use the cancel endpoint for cancellations — DELETE handles cancellation but not partial updates.

Parameters:

  • id (Integer)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (nil)


325
326
327
328
# File 'lib/repull/api/reservations_api.rb', line 325

def update_reservation(id, opts = {})
  update_reservation_with_http_info(id, opts)
  nil
end

#update_reservation_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Update reservation Patch reservation fields (dates, status, special requests). Only fields included in the body are modified. Use the cancel endpoint for cancellations — DELETE handles cancellation but not partial updates.

Parameters:

  • id (Integer)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/repull/api/reservations_api.rb', line 336

def update_reservation_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ReservationsApi.update_reservation ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ReservationsApi.update_reservation"
  end
  # resource path
  local_var_path = '/v1/reservations/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'update_reservation_request'])

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ReservationsApi.update_reservation",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ReservationsApi#update_reservation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end