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:) ⇒ Square::Bookings::Client 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:) ⇒ 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.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/square/bookings/client.rb', line 115 def bulk_retrieve_bookings(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/bookings/bulk-retrieve", body: params ) 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.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/square/bookings/client.rb', line 185 def bulk_retrieve_team_member_booking_profiles(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/bookings/team-member-booking-profiles/bulk-retrieve", body: params ) 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*.
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/square/bookings/client.rb', line 273 def cancel(request_options: {}, **params) _path_param_names = ["booking_id"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/bookings/#{params[:booking_id]}/cancel", body: params.except(*_path_param_names) ) 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*.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/square/bookings/client.rb', line 61 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/bookings", body: params ) 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
297 298 299 |
# File 'lib/square/bookings/client.rb', line 297 def custom_attribute_definitions @custom_attribute_definitions ||= Square::Bookings::CustomAttributeDefinitions::Client.new(client: @client) end |
#custom_attributes ⇒ Square::CustomAttributes::Client
302 303 304 |
# File 'lib/square/bookings/client.rb', line 302 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.
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/square/bookings/client.rb', line 212 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/bookings/#{params[:booking_id]}" ) 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.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/square/bookings/client.rb', line 139 def get_business_profile(request_options: {}, **_params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/bookings/business-booking-profile" ) 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.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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], %i[limit cursor customer_id team_member_id location_id start_at_min start_at_max] ].flatten _query = params.slice(*_query_param_names) params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/bookings", query: _query ) 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 |
#location_profiles ⇒ Square::LocationProfiles::Client
307 308 309 |
# File 'lib/square/bookings/client.rb', line 307 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.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/square/bookings/client.rb', line 162 def retrieve_location_booking_profile(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/bookings/location-booking-profiles/#{params[:location_id]}" ) 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.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/square/bookings/client.rb', line 88 def search_availability(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/bookings/availability/search", body: params ) 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
312 313 314 |
# File 'lib/square/bookings/client.rb', line 312 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*.
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/square/bookings/client.rb', line 241 def update(request_options: {}, **params) _path_param_names = ["booking_id"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "PUT", path: "v2/bookings/#{params[:booking_id]}", body: params.except(*_path_param_names) ) 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 |