Class: Square::Bookings::Client
- Inherits:
-
Object
- Object
- Square::Bookings::Client
- Defined in:
- lib/square/bookings/client.rb
Instance Method Summary collapse
-
#bulk_retrieve_bookings(request_options: {}, **params) ⇒ Square::Types::BulkRetrieveBookingsResponse
Bulk-Retrieves a list of bookings by booking IDs.
-
#bulk_retrieve_team_member_booking_profiles(request_options: {}, **params) ⇒ Square::Types::BulkRetrieveTeamMemberBookingProfilesResponse
Retrieves one or more team members’ booking profiles.
-
#cancel(request_options: {}, **params) ⇒ Square::Types::CancelBookingResponse
Cancels an existing booking.
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateBookingResponse
Creates a booking.
- #custom_attribute_definitions ⇒ Square::CustomAttributeDefinitions::Client
- #custom_attributes ⇒ Square::CustomAttributes::Client
-
#get(request_options: {}, **params) ⇒ Square::Types::GetBookingResponse
Retrieves a booking.
-
#get_business_profile(request_options: {}, **params) ⇒ Square::Types::GetBusinessBookingProfileResponse
Retrieves a seller’s booking profile.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListBookingsResponse
Retrieve a collection of bookings.
- #location_profiles ⇒ Square::LocationProfiles::Client
-
#retrieve_location_booking_profile(request_options: {}, **params) ⇒ Square::Types::RetrieveLocationBookingProfileResponse
Retrieves a seller’s location booking profile.
-
#search_availability(request_options: {}, **params) ⇒ Square::Types::SearchAvailabilityResponse
Searches for availabilities for booking.
- #team_member_profiles ⇒ Square::TeamMemberProfiles::Client
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdateBookingResponse
Updates a booking.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/square/bookings/client.rb', line 9 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.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/square/bookings/client.rb', line 178 def bulk_retrieve_bookings(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/bookings/bulk-retrieve", body: Square::Bookings::Types::BulkRetrieveBookingsRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::BulkRetrieveBookingsResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#bulk_retrieve_team_member_booking_profiles(request_options: {}, **params) ⇒ Square::Types::BulkRetrieveTeamMemberBookingProfilesResponse
Retrieves one or more team members’ booking profiles.
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/square/bookings/client.rb', line 279 def bulk_retrieve_team_member_booking_profiles(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/bookings/team-member-booking-profiles/bulk-retrieve", body: Square::Bookings::Types::BulkRetrieveTeamMemberBookingProfilesRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::BulkRetrieveTeamMemberBookingProfilesResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end 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*.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'lib/square/bookings/client.rb', line 407 def cancel(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request_data = Square::Bookings::Types::CancelBookingRequest.new(params).to_h non_body_param_names = ["booking_id"] body = request_data.except(*non_body_param_names) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/bookings/#{params[:booking_id]}/cancel", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::CancelBookingResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end 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*.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/square/bookings/client.rb', line 102 def create(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/bookings", body: Square::Bookings::Types::CreateBookingRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::CreateBookingResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#custom_attribute_definitions ⇒ Square::CustomAttributeDefinitions::Client
435 436 437 |
# File 'lib/square/bookings/client.rb', line 435 def custom_attribute_definitions @custom_attribute_definitions ||= Square::Bookings::CustomAttributeDefinitions::Client.new(client: @client) end |
#custom_attributes ⇒ Square::CustomAttributes::Client
440 441 442 |
# File 'lib/square/bookings/client.rb', line 440 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.
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/square/bookings/client.rb', line 318 def get(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/bookings/#{params[:booking_id]}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::GetBookingResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_business_profile(request_options: {}, **params) ⇒ Square::Types::GetBusinessBookingProfileResponse
Retrieves a seller’s booking profile.
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/square/bookings/client.rb', line 212 def get_business_profile(request_options: {}, **params) Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/bookings/business-booking-profile", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::GetBusinessBookingProfileResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end 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.
35 36 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 |
# File 'lib/square/bookings/client.rb', line 35 def list(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[limit cursor customer_id team_member_id location_id start_at_min start_at_max] query_params = {} query_params["limit"] = params[:limit] if params.key?(:limit) query_params["cursor"] = params[:cursor] if params.key?(:cursor) query_params["customer_id"] = params[:customer_id] if params.key?(:customer_id) query_params["team_member_id"] = params[:team_member_id] if params.key?(:team_member_id) query_params["location_id"] = params[:location_id] if params.key?(:location_id) query_params["start_at_min"] = params[:start_at_min] if params.key?(:start_at_min) query_params["start_at_max"] = params[:start_at_max] if params.key?(:start_at_max) params.except(*query_param_names) Square::Internal::CursorItemIterator.new( cursor_field: :cursor, item_field: :bookings, initial_cursor: query_params[:cursor] ) do |next_cursor| query_params[:cursor] = next_cursor request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/bookings", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::ListBookingsResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |
#location_profiles ⇒ Square::LocationProfiles::Client
445 446 447 |
# File 'lib/square/bookings/client.rb', line 445 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.
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/square/bookings/client.rb', line 246 def retrieve_location_booking_profile(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/bookings/location-booking-profiles/#{params[:location_id]}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::RetrieveLocationBookingProfileResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end 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.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/square/bookings/client.rb', line 140 def search_availability(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/bookings/availability/search", body: Square::Bookings::Types::SearchAvailabilityRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::SearchAvailabilityResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#team_member_profiles ⇒ Square::TeamMemberProfiles::Client
450 451 452 |
# File 'lib/square/bookings/client.rb', line 450 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*.
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/square/bookings/client.rb', line 360 def update(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request_data = Square::Bookings::Types::UpdateBookingRequest.new(params).to_h non_body_param_names = ["booking_id"] body = request_data.except(*non_body_param_names) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "v2/bookings/#{params[:booking_id]}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::UpdateBookingResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |