Class: Square::BookingsApi
- Defined in:
- lib/square/api/bookings_api.rb
Overview
BookingsApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#cancel_booking(booking_id:, body:) ⇒ CancelBookingResponse Hash
Cancels an existing booking.
-
#create_booking(body:) ⇒ CreateBookingResponse Hash
Creates a booking.
-
#list_bookings(limit: nil, cursor: nil, team_member_id: nil, location_id: nil, start_at_min: nil, start_at_max: nil) ⇒ ListBookingsResponse Hash
Retrieve a collection of bookings.
-
#list_team_member_booking_profiles(bookable_only: false, limit: nil, cursor: nil, location_id: nil) ⇒ ListTeamMemberBookingProfilesResponse Hash
Lists booking profiles for team members.
-
#retrieve_booking(booking_id:) ⇒ RetrieveBookingResponse Hash
Retrieves a booking.
-
#retrieve_business_booking_profile ⇒ RetrieveBusinessBookingProfileResponse Hash
Retrieves a seller’s booking profile.
-
#retrieve_team_member_booking_profile(team_member_id:) ⇒ RetrieveTeamMemberBookingProfileResponse Hash
Retrieves a team member’s booking profile.
-
#search_availability(body:) ⇒ SearchAvailabilityResponse Hash
Searches for availabilities for booking.
-
#update_booking(booking_id:, body:) ⇒ UpdateBookingResponse Hash
Updates a booking.
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
#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.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/square/api/bookings_api.rb', line 257 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.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.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/square/api/bookings_api.rb', line 70 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, 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. 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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/square/api/bookings_api.rb', line 27 def list_bookings(limit: nil, cursor: 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(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_team_member_booking_profiles(bookable_only: false, limit: nil, cursor: nil, location_id: nil) ⇒ ListTeamMemberBookingProfilesResponse Hash
Lists booking profiles for team members. 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.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/square/api/bookings_api.rb', line 142 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.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/square/api/bookings_api.rb', line 192 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_profile ⇒ RetrieveBusinessBookingProfileResponse Hash
Retrieves a seller’s booking profile.
115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/square/api/bookings_api.rb', line 115 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_team_member_booking_profile(team_member_id:) ⇒ RetrieveTeamMemberBookingProfileResponse Hash
Retrieves a team member’s booking profile. member to retrieve.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/square/api/bookings_api.rb', line 167 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.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/square/api/bookings_api.rb', line 96 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.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/square/api/bookings_api.rb', line 222 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 |