Skip to main content

autogen_squareup/apis/
bookings_api.rs

1/*
2 * Square
3 *
4 * Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management.
5 *
6 * The version of the OpenAPI document: 2.0
7 * Contact: developers@squareup.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`bulk_retrieve_bookings`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BulkRetrieveBookingsError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`bulk_retrieve_team_member_booking_profiles`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum BulkRetrieveTeamMemberBookingProfilesError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`cancel_booking`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum CancelBookingError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`create_booking`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum CreateBookingError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_bookings`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListBookingsError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`list_location_booking_profiles`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListLocationBookingProfilesError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`list_team_member_booking_profiles`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListTeamMemberBookingProfilesError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`retrieve_booking`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum RetrieveBookingError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`retrieve_business_booking_profile`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum RetrieveBusinessBookingProfileError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`retrieve_location_booking_profile`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum RetrieveLocationBookingProfileError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`retrieve_team_member_booking_profile`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum RetrieveTeamMemberBookingProfileError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`search_availability`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum SearchAvailabilityError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`update_booking`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum UpdateBookingError {
106    UnknownValue(serde_json::Value),
107}
108
109
110/// 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.
111pub async fn bulk_retrieve_bookings(configuration: &configuration::Configuration, bulk_retrieve_bookings_request: models::BulkRetrieveBookingsRequest) -> Result<models::BulkRetrieveBookingsResponse, Error<BulkRetrieveBookingsError>> {
112    // add a prefix to parameters to efficiently prevent name collisions
113    let p_bulk_retrieve_bookings_request = bulk_retrieve_bookings_request;
114
115    let uri_str = format!("{}/v2/bookings/bulk-retrieve", configuration.base_path);
116    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
117
118    if let Some(ref user_agent) = configuration.user_agent {
119        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
120    }
121    if let Some(ref token) = configuration.oauth_access_token {
122        req_builder = req_builder.bearer_auth(token.to_owned());
123    };
124    req_builder = req_builder.json(&p_bulk_retrieve_bookings_request);
125
126    let req = req_builder.build()?;
127    let resp = configuration.client.execute(req).await?;
128
129    let status = resp.status();
130    let content_type = resp
131        .headers()
132        .get("content-type")
133        .and_then(|v| v.to_str().ok())
134        .unwrap_or("application/octet-stream");
135    let content_type = super::ContentType::from(content_type);
136
137    if !status.is_client_error() && !status.is_server_error() {
138        let content = resp.text().await?;
139        match content_type {
140            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
141            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkRetrieveBookingsResponse`"))),
142            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BulkRetrieveBookingsResponse`")))),
143        }
144    } else {
145        let content = resp.text().await?;
146        let entity: Option<BulkRetrieveBookingsError> = serde_json::from_str(&content).ok();
147        Err(Error::ResponseError(ResponseContent { status, content, entity }))
148    }
149}
150
151/// Retrieves one or more team members' booking profiles.
152pub async fn bulk_retrieve_team_member_booking_profiles(configuration: &configuration::Configuration, bulk_retrieve_team_member_booking_profiles_request: models::BulkRetrieveTeamMemberBookingProfilesRequest) -> Result<models::BulkRetrieveTeamMemberBookingProfilesResponse, Error<BulkRetrieveTeamMemberBookingProfilesError>> {
153    // add a prefix to parameters to efficiently prevent name collisions
154    let p_bulk_retrieve_team_member_booking_profiles_request = bulk_retrieve_team_member_booking_profiles_request;
155
156    let uri_str = format!("{}/v2/bookings/team-member-booking-profiles/bulk-retrieve", configuration.base_path);
157    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
158
159    if let Some(ref user_agent) = configuration.user_agent {
160        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
161    }
162    if let Some(ref token) = configuration.oauth_access_token {
163        req_builder = req_builder.bearer_auth(token.to_owned());
164    };
165    req_builder = req_builder.json(&p_bulk_retrieve_team_member_booking_profiles_request);
166
167    let req = req_builder.build()?;
168    let resp = configuration.client.execute(req).await?;
169
170    let status = resp.status();
171    let content_type = resp
172        .headers()
173        .get("content-type")
174        .and_then(|v| v.to_str().ok())
175        .unwrap_or("application/octet-stream");
176    let content_type = super::ContentType::from(content_type);
177
178    if !status.is_client_error() && !status.is_server_error() {
179        let content = resp.text().await?;
180        match content_type {
181            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
182            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkRetrieveTeamMemberBookingProfilesResponse`"))),
183            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BulkRetrieveTeamMemberBookingProfilesResponse`")))),
184        }
185    } else {
186        let content = resp.text().await?;
187        let entity: Option<BulkRetrieveTeamMemberBookingProfilesError> = serde_json::from_str(&content).ok();
188        Err(Error::ResponseError(ResponseContent { status, content, entity }))
189    }
190}
191
192/// 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*.
193pub async fn cancel_booking(configuration: &configuration::Configuration, booking_id: &str, cancel_booking_request: models::CancelBookingRequest) -> Result<models::CancelBookingResponse, Error<CancelBookingError>> {
194    // add a prefix to parameters to efficiently prevent name collisions
195    let p_booking_id = booking_id;
196    let p_cancel_booking_request = cancel_booking_request;
197
198    let uri_str = format!("{}/v2/bookings/{booking_id}/cancel", configuration.base_path, booking_id=crate::apis::urlencode(p_booking_id));
199    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
200
201    if let Some(ref user_agent) = configuration.user_agent {
202        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
203    }
204    if let Some(ref token) = configuration.oauth_access_token {
205        req_builder = req_builder.bearer_auth(token.to_owned());
206    };
207    req_builder = req_builder.json(&p_cancel_booking_request);
208
209    let req = req_builder.build()?;
210    let resp = configuration.client.execute(req).await?;
211
212    let status = resp.status();
213    let content_type = resp
214        .headers()
215        .get("content-type")
216        .and_then(|v| v.to_str().ok())
217        .unwrap_or("application/octet-stream");
218    let content_type = super::ContentType::from(content_type);
219
220    if !status.is_client_error() && !status.is_server_error() {
221        let content = resp.text().await?;
222        match content_type {
223            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
224            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CancelBookingResponse`"))),
225            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CancelBookingResponse`")))),
226        }
227    } else {
228        let content = resp.text().await?;
229        let entity: Option<CancelBookingError> = serde_json::from_str(&content).ok();
230        Err(Error::ResponseError(ResponseContent { status, content, entity }))
231    }
232}
233
234/// 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*.
235pub async fn create_booking(configuration: &configuration::Configuration, create_booking_request: models::CreateBookingRequest) -> Result<models::CreateBookingResponse, Error<CreateBookingError>> {
236    // add a prefix to parameters to efficiently prevent name collisions
237    let p_create_booking_request = create_booking_request;
238
239    let uri_str = format!("{}/v2/bookings", configuration.base_path);
240    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
241
242    if let Some(ref user_agent) = configuration.user_agent {
243        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
244    }
245    if let Some(ref token) = configuration.oauth_access_token {
246        req_builder = req_builder.bearer_auth(token.to_owned());
247    };
248    req_builder = req_builder.json(&p_create_booking_request);
249
250    let req = req_builder.build()?;
251    let resp = configuration.client.execute(req).await?;
252
253    let status = resp.status();
254    let content_type = resp
255        .headers()
256        .get("content-type")
257        .and_then(|v| v.to_str().ok())
258        .unwrap_or("application/octet-stream");
259    let content_type = super::ContentType::from(content_type);
260
261    if !status.is_client_error() && !status.is_server_error() {
262        let content = resp.text().await?;
263        match content_type {
264            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
265            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateBookingResponse`"))),
266            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateBookingResponse`")))),
267        }
268    } else {
269        let content = resp.text().await?;
270        let entity: Option<CreateBookingError> = serde_json::from_str(&content).ok();
271        Err(Error::ResponseError(ResponseContent { status, content, entity }))
272    }
273}
274
275/// 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.
276pub async fn list_bookings(configuration: &configuration::Configuration, limit: Option<i32>, cursor: Option<&str>, customer_id: Option<&str>, team_member_id: Option<&str>, location_id: Option<&str>, start_at_min: Option<&str>, start_at_max: Option<&str>) -> Result<models::ListBookingsResponse, Error<ListBookingsError>> {
277    // add a prefix to parameters to efficiently prevent name collisions
278    let p_limit = limit;
279    let p_cursor = cursor;
280    let p_customer_id = customer_id;
281    let p_team_member_id = team_member_id;
282    let p_location_id = location_id;
283    let p_start_at_min = start_at_min;
284    let p_start_at_max = start_at_max;
285
286    let uri_str = format!("{}/v2/bookings", configuration.base_path);
287    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
288
289    if let Some(ref param_value) = p_limit {
290        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
291    }
292    if let Some(ref param_value) = p_cursor {
293        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
294    }
295    if let Some(ref param_value) = p_customer_id {
296        req_builder = req_builder.query(&[("customer_id", &param_value.to_string())]);
297    }
298    if let Some(ref param_value) = p_team_member_id {
299        req_builder = req_builder.query(&[("team_member_id", &param_value.to_string())]);
300    }
301    if let Some(ref param_value) = p_location_id {
302        req_builder = req_builder.query(&[("location_id", &param_value.to_string())]);
303    }
304    if let Some(ref param_value) = p_start_at_min {
305        req_builder = req_builder.query(&[("start_at_min", &param_value.to_string())]);
306    }
307    if let Some(ref param_value) = p_start_at_max {
308        req_builder = req_builder.query(&[("start_at_max", &param_value.to_string())]);
309    }
310    if let Some(ref user_agent) = configuration.user_agent {
311        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
312    }
313    if let Some(ref token) = configuration.oauth_access_token {
314        req_builder = req_builder.bearer_auth(token.to_owned());
315    };
316
317    let req = req_builder.build()?;
318    let resp = configuration.client.execute(req).await?;
319
320    let status = resp.status();
321    let content_type = resp
322        .headers()
323        .get("content-type")
324        .and_then(|v| v.to_str().ok())
325        .unwrap_or("application/octet-stream");
326    let content_type = super::ContentType::from(content_type);
327
328    if !status.is_client_error() && !status.is_server_error() {
329        let content = resp.text().await?;
330        match content_type {
331            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
332            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListBookingsResponse`"))),
333            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListBookingsResponse`")))),
334        }
335    } else {
336        let content = resp.text().await?;
337        let entity: Option<ListBookingsError> = serde_json::from_str(&content).ok();
338        Err(Error::ResponseError(ResponseContent { status, content, entity }))
339    }
340}
341
342/// Lists location booking profiles of a seller.
343pub async fn list_location_booking_profiles(configuration: &configuration::Configuration, limit: Option<i32>, cursor: Option<&str>) -> Result<models::ListLocationBookingProfilesResponse, Error<ListLocationBookingProfilesError>> {
344    // add a prefix to parameters to efficiently prevent name collisions
345    let p_limit = limit;
346    let p_cursor = cursor;
347
348    let uri_str = format!("{}/v2/bookings/location-booking-profiles", configuration.base_path);
349    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
350
351    if let Some(ref param_value) = p_limit {
352        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
353    }
354    if let Some(ref param_value) = p_cursor {
355        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
356    }
357    if let Some(ref user_agent) = configuration.user_agent {
358        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
359    }
360    if let Some(ref token) = configuration.oauth_access_token {
361        req_builder = req_builder.bearer_auth(token.to_owned());
362    };
363
364    let req = req_builder.build()?;
365    let resp = configuration.client.execute(req).await?;
366
367    let status = resp.status();
368    let content_type = resp
369        .headers()
370        .get("content-type")
371        .and_then(|v| v.to_str().ok())
372        .unwrap_or("application/octet-stream");
373    let content_type = super::ContentType::from(content_type);
374
375    if !status.is_client_error() && !status.is_server_error() {
376        let content = resp.text().await?;
377        match content_type {
378            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
379            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListLocationBookingProfilesResponse`"))),
380            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListLocationBookingProfilesResponse`")))),
381        }
382    } else {
383        let content = resp.text().await?;
384        let entity: Option<ListLocationBookingProfilesError> = serde_json::from_str(&content).ok();
385        Err(Error::ResponseError(ResponseContent { status, content, entity }))
386    }
387}
388
389/// Lists booking profiles for team members.
390pub async fn list_team_member_booking_profiles(configuration: &configuration::Configuration, bookable_only: Option<bool>, limit: Option<i32>, cursor: Option<&str>, location_id: Option<&str>) -> Result<models::ListTeamMemberBookingProfilesResponse, Error<ListTeamMemberBookingProfilesError>> {
391    // add a prefix to parameters to efficiently prevent name collisions
392    let p_bookable_only = bookable_only;
393    let p_limit = limit;
394    let p_cursor = cursor;
395    let p_location_id = location_id;
396
397    let uri_str = format!("{}/v2/bookings/team-member-booking-profiles", configuration.base_path);
398    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
399
400    if let Some(ref param_value) = p_bookable_only {
401        req_builder = req_builder.query(&[("bookable_only", &param_value.to_string())]);
402    }
403    if let Some(ref param_value) = p_limit {
404        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
405    }
406    if let Some(ref param_value) = p_cursor {
407        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
408    }
409    if let Some(ref param_value) = p_location_id {
410        req_builder = req_builder.query(&[("location_id", &param_value.to_string())]);
411    }
412    if let Some(ref user_agent) = configuration.user_agent {
413        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
414    }
415    if let Some(ref token) = configuration.oauth_access_token {
416        req_builder = req_builder.bearer_auth(token.to_owned());
417    };
418
419    let req = req_builder.build()?;
420    let resp = configuration.client.execute(req).await?;
421
422    let status = resp.status();
423    let content_type = resp
424        .headers()
425        .get("content-type")
426        .and_then(|v| v.to_str().ok())
427        .unwrap_or("application/octet-stream");
428    let content_type = super::ContentType::from(content_type);
429
430    if !status.is_client_error() && !status.is_server_error() {
431        let content = resp.text().await?;
432        match content_type {
433            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
434            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListTeamMemberBookingProfilesResponse`"))),
435            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListTeamMemberBookingProfilesResponse`")))),
436        }
437    } else {
438        let content = resp.text().await?;
439        let entity: Option<ListTeamMemberBookingProfilesError> = serde_json::from_str(&content).ok();
440        Err(Error::ResponseError(ResponseContent { status, content, entity }))
441    }
442}
443
444/// 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.
445pub async fn retrieve_booking(configuration: &configuration::Configuration, booking_id: &str) -> Result<models::RetrieveBookingResponse, Error<RetrieveBookingError>> {
446    // add a prefix to parameters to efficiently prevent name collisions
447    let p_booking_id = booking_id;
448
449    let uri_str = format!("{}/v2/bookings/{booking_id}", configuration.base_path, booking_id=crate::apis::urlencode(p_booking_id));
450    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
451
452    if let Some(ref user_agent) = configuration.user_agent {
453        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
454    }
455    if let Some(ref token) = configuration.oauth_access_token {
456        req_builder = req_builder.bearer_auth(token.to_owned());
457    };
458
459    let req = req_builder.build()?;
460    let resp = configuration.client.execute(req).await?;
461
462    let status = resp.status();
463    let content_type = resp
464        .headers()
465        .get("content-type")
466        .and_then(|v| v.to_str().ok())
467        .unwrap_or("application/octet-stream");
468    let content_type = super::ContentType::from(content_type);
469
470    if !status.is_client_error() && !status.is_server_error() {
471        let content = resp.text().await?;
472        match content_type {
473            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
474            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RetrieveBookingResponse`"))),
475            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RetrieveBookingResponse`")))),
476        }
477    } else {
478        let content = resp.text().await?;
479        let entity: Option<RetrieveBookingError> = serde_json::from_str(&content).ok();
480        Err(Error::ResponseError(ResponseContent { status, content, entity }))
481    }
482}
483
484/// Retrieves a seller's booking profile.
485pub async fn retrieve_business_booking_profile(configuration: &configuration::Configuration, ) -> Result<models::RetrieveBusinessBookingProfileResponse, Error<RetrieveBusinessBookingProfileError>> {
486
487    let uri_str = format!("{}/v2/bookings/business-booking-profile", configuration.base_path);
488    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
489
490    if let Some(ref user_agent) = configuration.user_agent {
491        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
492    }
493    if let Some(ref token) = configuration.oauth_access_token {
494        req_builder = req_builder.bearer_auth(token.to_owned());
495    };
496
497    let req = req_builder.build()?;
498    let resp = configuration.client.execute(req).await?;
499
500    let status = resp.status();
501    let content_type = resp
502        .headers()
503        .get("content-type")
504        .and_then(|v| v.to_str().ok())
505        .unwrap_or("application/octet-stream");
506    let content_type = super::ContentType::from(content_type);
507
508    if !status.is_client_error() && !status.is_server_error() {
509        let content = resp.text().await?;
510        match content_type {
511            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
512            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RetrieveBusinessBookingProfileResponse`"))),
513            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RetrieveBusinessBookingProfileResponse`")))),
514        }
515    } else {
516        let content = resp.text().await?;
517        let entity: Option<RetrieveBusinessBookingProfileError> = serde_json::from_str(&content).ok();
518        Err(Error::ResponseError(ResponseContent { status, content, entity }))
519    }
520}
521
522/// Retrieves a seller's location booking profile.
523pub async fn retrieve_location_booking_profile(configuration: &configuration::Configuration, location_id: &str) -> Result<models::RetrieveLocationBookingProfileResponse, Error<RetrieveLocationBookingProfileError>> {
524    // add a prefix to parameters to efficiently prevent name collisions
525    let p_location_id = location_id;
526
527    let uri_str = format!("{}/v2/bookings/location-booking-profiles/{location_id}", configuration.base_path, location_id=crate::apis::urlencode(p_location_id));
528    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
529
530    if let Some(ref user_agent) = configuration.user_agent {
531        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
532    }
533    if let Some(ref token) = configuration.oauth_access_token {
534        req_builder = req_builder.bearer_auth(token.to_owned());
535    };
536
537    let req = req_builder.build()?;
538    let resp = configuration.client.execute(req).await?;
539
540    let status = resp.status();
541    let content_type = resp
542        .headers()
543        .get("content-type")
544        .and_then(|v| v.to_str().ok())
545        .unwrap_or("application/octet-stream");
546    let content_type = super::ContentType::from(content_type);
547
548    if !status.is_client_error() && !status.is_server_error() {
549        let content = resp.text().await?;
550        match content_type {
551            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
552            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RetrieveLocationBookingProfileResponse`"))),
553            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RetrieveLocationBookingProfileResponse`")))),
554        }
555    } else {
556        let content = resp.text().await?;
557        let entity: Option<RetrieveLocationBookingProfileError> = serde_json::from_str(&content).ok();
558        Err(Error::ResponseError(ResponseContent { status, content, entity }))
559    }
560}
561
562/// Retrieves a team member's booking profile.
563pub async fn retrieve_team_member_booking_profile(configuration: &configuration::Configuration, team_member_id: &str) -> Result<models::RetrieveTeamMemberBookingProfileResponse, Error<RetrieveTeamMemberBookingProfileError>> {
564    // add a prefix to parameters to efficiently prevent name collisions
565    let p_team_member_id = team_member_id;
566
567    let uri_str = format!("{}/v2/bookings/team-member-booking-profiles/{team_member_id}", configuration.base_path, team_member_id=crate::apis::urlencode(p_team_member_id));
568    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
569
570    if let Some(ref user_agent) = configuration.user_agent {
571        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
572    }
573    if let Some(ref token) = configuration.oauth_access_token {
574        req_builder = req_builder.bearer_auth(token.to_owned());
575    };
576
577    let req = req_builder.build()?;
578    let resp = configuration.client.execute(req).await?;
579
580    let status = resp.status();
581    let content_type = resp
582        .headers()
583        .get("content-type")
584        .and_then(|v| v.to_str().ok())
585        .unwrap_or("application/octet-stream");
586    let content_type = super::ContentType::from(content_type);
587
588    if !status.is_client_error() && !status.is_server_error() {
589        let content = resp.text().await?;
590        match content_type {
591            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
592            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RetrieveTeamMemberBookingProfileResponse`"))),
593            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RetrieveTeamMemberBookingProfileResponse`")))),
594        }
595    } else {
596        let content = resp.text().await?;
597        let entity: Option<RetrieveTeamMemberBookingProfileError> = serde_json::from_str(&content).ok();
598        Err(Error::ResponseError(ResponseContent { status, content, entity }))
599    }
600}
601
602/// 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.
603pub async fn search_availability(configuration: &configuration::Configuration, search_availability_request: models::SearchAvailabilityRequest) -> Result<models::SearchAvailabilityResponse, Error<SearchAvailabilityError>> {
604    // add a prefix to parameters to efficiently prevent name collisions
605    let p_search_availability_request = search_availability_request;
606
607    let uri_str = format!("{}/v2/bookings/availability/search", configuration.base_path);
608    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
609
610    if let Some(ref user_agent) = configuration.user_agent {
611        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
612    }
613    if let Some(ref token) = configuration.oauth_access_token {
614        req_builder = req_builder.bearer_auth(token.to_owned());
615    };
616    req_builder = req_builder.json(&p_search_availability_request);
617
618    let req = req_builder.build()?;
619    let resp = configuration.client.execute(req).await?;
620
621    let status = resp.status();
622    let content_type = resp
623        .headers()
624        .get("content-type")
625        .and_then(|v| v.to_str().ok())
626        .unwrap_or("application/octet-stream");
627    let content_type = super::ContentType::from(content_type);
628
629    if !status.is_client_error() && !status.is_server_error() {
630        let content = resp.text().await?;
631        match content_type {
632            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
633            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SearchAvailabilityResponse`"))),
634            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SearchAvailabilityResponse`")))),
635        }
636    } else {
637        let content = resp.text().await?;
638        let entity: Option<SearchAvailabilityError> = serde_json::from_str(&content).ok();
639        Err(Error::ResponseError(ResponseContent { status, content, entity }))
640    }
641}
642
643/// 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*.
644pub async fn update_booking(configuration: &configuration::Configuration, booking_id: &str, update_booking_request: models::UpdateBookingRequest) -> Result<models::UpdateBookingResponse, Error<UpdateBookingError>> {
645    // add a prefix to parameters to efficiently prevent name collisions
646    let p_booking_id = booking_id;
647    let p_update_booking_request = update_booking_request;
648
649    let uri_str = format!("{}/v2/bookings/{booking_id}", configuration.base_path, booking_id=crate::apis::urlencode(p_booking_id));
650    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
651
652    if let Some(ref user_agent) = configuration.user_agent {
653        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
654    }
655    if let Some(ref token) = configuration.oauth_access_token {
656        req_builder = req_builder.bearer_auth(token.to_owned());
657    };
658    req_builder = req_builder.json(&p_update_booking_request);
659
660    let req = req_builder.build()?;
661    let resp = configuration.client.execute(req).await?;
662
663    let status = resp.status();
664    let content_type = resp
665        .headers()
666        .get("content-type")
667        .and_then(|v| v.to_str().ok())
668        .unwrap_or("application/octet-stream");
669    let content_type = super::ContentType::from(content_type);
670
671    if !status.is_client_error() && !status.is_server_error() {
672        let content = resp.text().await?;
673        match content_type {
674            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
675            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateBookingResponse`"))),
676            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateBookingResponse`")))),
677        }
678    } else {
679        let content = resp.text().await?;
680        let entity: Option<UpdateBookingError> = serde_json::from_str(&content).ok();
681        Err(Error::ResponseError(ResponseContent { status, content, entity }))
682    }
683}
684