Class: Square::Bookings::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/square/bookings/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Square::Bookings::Client



7
8
9
# File 'lib/square/bookings/client.rb', line 7

def initialize(client:)
  @client = client
end

Instance Method Details

#bulk_retrieve_bookings(request_options: {}, **params) ⇒ Square::Types::BulkRetrieveBookingsResponse

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.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/square/bookings/client.rb', line 95

def bulk_retrieve_bookings(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/bookings/bulk-retrieve",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::BulkRetrieveBookingsResponse.load(_response.body)
  end

  raise _response.body
end

#bulk_retrieve_team_member_booking_profiles(request_options: {}, **params) ⇒ Square::Types::BulkRetrieveTeamMemberBookingProfilesResponse

Retrieves one or more team members’ booking profiles.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/square/bookings/client.rb', line 147

def bulk_retrieve_team_member_booking_profiles(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/bookings/team-member-booking-profiles/bulk-retrieve",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::BulkRetrieveTeamMemberBookingProfilesResponse.load(_response.body)
  end

  raise _response.body
end

#cancel(request_options: {}, **params) ⇒ Square::Types::CancelBookingResponse

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*.



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/square/bookings/client.rb', line 217

def cancel(request_options: {}, **params)
  _path_param_names = ["booking_id"]

  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/bookings/#{params[:booking_id]}/cancel",
    body: params.except(*_path_param_names)
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::CancelBookingResponse.load(_response.body)
  end

  raise _response.body
end

#create(request_options: {}, **params) ⇒ Square::Types::CreateBookingResponse

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*.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/square/bookings/client.rb', line 53

def create(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/bookings",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::CreateBookingResponse.load(_response.body)
  end

  raise _response.body
end

#custom_attribute_definitionsSquare::CustomAttributeDefinitions::Client

Returns:

  • (Square::CustomAttributeDefinitions::Client)


235
236
237
# File 'lib/square/bookings/client.rb', line 235

def custom_attribute_definitions
  @custom_attribute_definitions ||= Square::Bookings::CustomAttributeDefinitions::Client.new(client: @client)
end

#custom_attributesSquare::CustomAttributes::Client

Returns:

  • (Square::CustomAttributes::Client)


240
241
242
# File 'lib/square/bookings/client.rb', line 240

def custom_attributes
  @custom_attributes ||= Square::Bookings::CustomAttributes::Client.new(client: @client)
end

#get(request_options: {}, **params) ⇒ Square::Types::GetBookingResponse

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.



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/square/bookings/client.rb', line 168

def get(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/bookings/#{params[:booking_id]}"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::GetBookingResponse.load(_response.body)
  end

  raise _response.body
end

#get_business_profile(request_options: {}, **_params) ⇒ Square::Types::GetBusinessBookingProfileResponse

Retrieves a seller’s booking profile.



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/square/bookings/client.rb', line 113

def get_business_profile(request_options: {}, **_params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/bookings/business-booking-profile"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::GetBusinessBookingProfileResponse.load(_response.body)
  end

  raise _response.body
end

#list(request_options: {}, **params) ⇒ Square::Types::ListBookingsResponse

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.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/square/bookings/client.rb', line 17

def list(request_options: {}, **params)
  _query_param_names = %w[limit cursor customer_id team_member_id location_id start_at_min
                          start_at_max]
  _query = params.slice(*_query_param_names)
  params.except(*_query_param_names)

  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/bookings",
    query: _query
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::ListBookingsResponse.load(_response.body)
  end

  raise _response.body
end

#location_profilesSquare::LocationProfiles::Client

Returns:

  • (Square::LocationProfiles::Client)


245
246
247
# File 'lib/square/bookings/client.rb', line 245

def location_profiles
  @location_profiles ||= Square::Bookings::LocationProfiles::Client.new(client: @client)
end

#retrieve_location_booking_profile(request_options: {}, **params) ⇒ Square::Types::RetrieveLocationBookingProfileResponse

Retrieves a seller’s location booking profile.



130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/square/bookings/client.rb', line 130

def retrieve_location_booking_profile(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/bookings/location-booking-profiles/#{params[:location_id]}"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::RetrieveLocationBookingProfileResponse.load(_response.body)
  end

  raise _response.body
end

#search_availability(request_options: {}, **params) ⇒ Square::Types::SearchAvailabilityResponse

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.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/square/bookings/client.rb', line 74

def search_availability(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/bookings/availability/search",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::SearchAvailabilityResponse.load(_response.body)
  end

  raise _response.body
end

#team_member_profilesSquare::TeamMemberProfiles::Client

Returns:

  • (Square::TeamMemberProfiles::Client)


250
251
252
# File 'lib/square/bookings/client.rb', line 250

def team_member_profiles
  @team_member_profiles ||= Square::Bookings::TeamMemberProfiles::Client.new(client: @client)
end

#update(request_options: {}, **params) ⇒ Square::Types::UpdateBookingResponse

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*.



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/square/bookings/client.rb', line 191

def update(request_options: {}, **params)
  _path_param_names = ["booking_id"]

  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "PUT",
    path: "v2/bookings/#{params[:booking_id]}",
    body: params.except(*_path_param_names)
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::UpdateBookingResponse.load(_response.body)
  end

  raise _response.body
end