Class: Square::BookingsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/bookings_api.rb

Overview

BookingsApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#bulk_retrieve_bookings(body:) ⇒ BulkRetrieveBookingsResponse Hash

Bulk-Retrieves a list of bookings by booking IDs. To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_READ` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BulkRetrieveBookingsRequest)

    Required parameter: An object

Returns:

  • (BulkRetrieveBookingsResponse Hash)

    response from the API call



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/square/api/bookings_api.rb', line 127

def bulk_retrieve_bookings(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/bookings/bulk-retrieve',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#bulk_retrieve_team_member_booking_profiles(body:) ⇒ BulkRetrieveTeamMemberBookingProfilesResponse Hash

Retrieves one or more team members’ booking profiles. parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BulkRetrieveTeamMemberBookingProfilesRequest)

    Required

Returns:

  • (BulkRetrieveTeamMemberBookingProfilesResponse Hash)

    response from the API call



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/square/api/bookings_api.rb', line 243

def bulk_retrieve_team_member_booking_profiles(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/bookings/team-member-booking-profiles/bulk-retrieve',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#cancel_booking(booking_id:, body:) ⇒ CancelBookingResponse Hash

Cancels an existing booking. To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_WRITE` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus* or *Appointments Premium*. [Booking](entity:Booking) object representing the to-be-cancelled booking. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • booking_id (String)

    Required parameter: The ID of the

  • body (CancelBookingRequest)

    Required parameter: An object

Returns:

  • (CancelBookingResponse Hash)

    response from the API call



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/square/api/bookings_api.rb', line 354

def cancel_booking(booking_id:,
                   body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/bookings/{booking_id}/cancel',
                                 'default')
               .template_param(new_parameter(booking_id, key: 'booking_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#create_booking(body:) ⇒ CreateBookingResponse Hash

Creates a booking. The required input must include the following:

  • ‘Booking.location_id`

  • ‘Booking.start_at`

  • ‘Booking.AppointmentSegment.team_member_id`

  • ‘Booking.AppointmentSegment.service_variation_id`

  • ‘Booking.AppointmentSegment.service_variation_version`

To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_WRITE` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus* or *Appointments Premium*. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (CreateBookingRequest)

    Required parameter: An object

Returns:

  • (CreateBookingResponse Hash)

    response from the API call



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/square/api/bookings_api.rb', line 75

def create_booking(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/bookings',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#list_bookings(limit: nil, cursor: nil, customer_id: nil, team_member_id: nil, location_id: nil, start_at_min: nil, start_at_max: nil) ⇒ ListBookingsResponse Hash

Retrieve a collection of bookings. To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_READ` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. per page to return in a paged response. preceding response to return the next page of the results. Do not set this when retrieving the first page of the results. [customer](entity:Customer) for whom to retrieve bookings. If this is not set, bookings for all customers are retrieved. whom to retrieve bookings. If this is not set, bookings of all members are retrieved. retrieve bookings. If this is not set, all locations’ bookings are retrieved. specifying the earliest of the start time. If this is not set, the current time is used. specifying the latest of the start time. If this is not set, the time of 31 days after ‘start_at_min` is used.

Parameters:

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of results

  • cursor (String) (defaults to: nil)

    Optional parameter: The pagination cursor from the

  • customer_id (String) (defaults to: nil)

    Optional parameter: The

  • team_member_id (String) (defaults to: nil)

    Optional parameter: The team member for

  • location_id (String) (defaults to: nil)

    Optional parameter: The location for which to

  • start_at_min (String) (defaults to: nil)

    Optional parameter: The RFC 3339 timestamp

  • start_at_max (String) (defaults to: nil)

    Optional parameter: The RFC 3339 timestamp

Returns:

  • (ListBookingsResponse Hash)

    response from the API call



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/square/api/bookings_api.rb', line 30

def list_bookings(limit: nil,
                  cursor: nil,
                  customer_id: nil,
                  team_member_id: nil,
                  location_id: nil,
                  start_at_min: nil,
                  start_at_max: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/bookings',
                                 'default')
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(customer_id, key: 'customer_id'))
               .query_param(new_parameter(team_member_id, key: 'team_member_id'))
               .query_param(new_parameter(location_id, key: 'location_id'))
               .query_param(new_parameter(start_at_min, key: 'start_at_min'))
               .query_param(new_parameter(start_at_max, key: 'start_at_max'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#list_location_booking_profiles(limit: nil, cursor: nil) ⇒ ListLocationBookingProfilesResponse Hash

Lists location booking profiles of a seller. to return in a paged response. preceding response to return the next page of the results. Do not set this when retrieving the first page of the results.

Parameters:

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of results

  • cursor (String) (defaults to: nil)

    Optional parameter: The pagination cursor from the

Returns:

  • (ListLocationBookingProfilesResponse Hash)

    response from the API call



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/square/api/bookings_api.rb', line 167

def list_location_booking_profiles(limit: nil,
                                   cursor: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/bookings/location-booking-profiles',
                                 'default')
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#list_team_member_booking_profiles(bookable_only: false, limit: nil, cursor: nil, location_id: nil) ⇒ ListTeamMemberBookingProfilesResponse Hash

Lists booking profiles for team members. Indicates whether to include only bookable team members in the returned result (‘true`) or not (`false`). to return in a paged response. preceding response to return the next page of the results. Do not set this when retrieving the first page of the results. include only team members enabled at the given location in the returned result.

Parameters:

  • bookable_only (TrueClass | FalseClass) (defaults to: false)

    Optional parameter:

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of results

  • cursor (String) (defaults to: nil)

    Optional parameter: The pagination cursor from the

  • location_id (String) (defaults to: nil)

    Optional parameter: Indicates whether to

Returns:

  • (ListTeamMemberBookingProfilesResponse Hash)

    response from the API call



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/square/api/bookings_api.rb', line 217

def list_team_member_booking_profiles(bookable_only: false,
                                      limit: nil,
                                      cursor: nil,
                                      location_id: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/bookings/team-member-booking-profiles',
                                 'default')
               .query_param(new_parameter(bookable_only, key: 'bookable_only'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(location_id, key: 'location_id'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_booking(booking_id:) ⇒ RetrieveBookingResponse Hash

Retrieves a booking. To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_READ` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. [Booking](entity:Booking) object representing the to-be-retrieved booking.

Parameters:

  • booking_id (String)

    Required parameter: The ID of the

Returns:

  • (RetrieveBookingResponse Hash)

    response from the API call



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/square/api/bookings_api.rb', line 289

def retrieve_booking(booking_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/bookings/{booking_id}',
                                 'default')
               .template_param(new_parameter(booking_id, key: 'booking_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_business_booking_profileRetrieveBusinessBookingProfileResponse Hash

Retrieves a seller’s booking profile.

Returns:

  • (RetrieveBusinessBookingProfileResponse Hash)

    response from the API call



146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/square/api/bookings_api.rb', line 146

def retrieve_business_booking_profile
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/bookings/business-booking-profile',
                                 'default')
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_location_booking_profile(location_id:) ⇒ RetrieveLocationBookingProfileResponse Hash

Retrieves a seller’s location booking profile. retrieve the booking profile.

Parameters:

  • location_id (String)

    Required parameter: The ID of the location to

Returns:

  • (RetrieveLocationBookingProfileResponse Hash)

    response from the API call



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/square/api/bookings_api.rb', line 188

def retrieve_location_booking_profile(location_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/bookings/location-booking-profiles/{location_id}',
                                 'default')
               .template_param(new_parameter(location_id, key: 'location_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_team_member_booking_profile(team_member_id:) ⇒ RetrieveTeamMemberBookingProfileResponse Hash

Retrieves a team member’s booking profile. member to retrieve.

Parameters:

  • team_member_id (String)

    Required parameter: The ID of the team

Returns:

  • (RetrieveTeamMemberBookingProfileResponse Hash)

    response from the API call



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/square/api/bookings_api.rb', line 264

def retrieve_team_member_booking_profile(team_member_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/bookings/team-member-booking-profiles/{team_member_id}',
                                 'default')
               .template_param(new_parameter(team_member_id, key: 'team_member_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#search_availability(body:) ⇒ SearchAvailabilityResponse Hash

Searches for availabilities for booking. To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_READ` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (SearchAvailabilityRequest)

    Required parameter: An object

Returns:

  • (SearchAvailabilityResponse Hash)

    response from the API call



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/square/api/bookings_api.rb', line 101

def search_availability(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/bookings/availability/search',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#update_booking(booking_id:, body:) ⇒ UpdateBookingResponse Hash

Updates a booking. To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_WRITE` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus* or *Appointments Premium*. [Booking](entity:Booking) object representing the to-be-updated booking. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • booking_id (String)

    Required parameter: The ID of the

  • body (UpdateBookingRequest)

    Required parameter: An object

Returns:

  • (UpdateBookingResponse Hash)

    response from the API call



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/square/api/bookings_api.rb', line 319

def update_booking(booking_id:,
                   body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/bookings/{booking_id}',
                                 'default')
               .template_param(new_parameter(booking_id, key: 'booking_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end