1use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum OrganizationSponsorshipRedeemPostError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdDeleteError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdRemovePostError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterprisePostError {
44 UnknownValue(serde_json::Value),
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterpriseResendPostError {
52 UnknownValue(serde_json::Value),
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum OrganizationSponsorshipSponsoringOrgIdSyncStatusGetError {
59 UnknownValue(serde_json::Value),
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum OrganizationSponsorshipSponsoringOrganizationIdDeleteError {
66 UnknownValue(serde_json::Value),
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum OrganizationSponsorshipSponsoringOrganizationIdDeletePostError {
74 UnknownValue(serde_json::Value),
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum OrganizationSponsorshipSyncPostError {
81 UnknownValue(serde_json::Value),
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum OrganizationSponsorshipValidateTokenPostError {
88 UnknownValue(serde_json::Value),
89}
90
91pub async fn organization_sponsorship_redeem_post(
92 configuration: &configuration::Configuration,
93 sponsorship_token: Option<&str>,
94 organization_sponsorship_redeem_request_model: Option<
95 models::OrganizationSponsorshipRedeemRequestModel,
96 >,
97) -> Result<(), Error<OrganizationSponsorshipRedeemPostError>> {
98 let p_sponsorship_token = sponsorship_token;
100 let p_organization_sponsorship_redeem_request_model =
101 organization_sponsorship_redeem_request_model;
102
103 let uri_str = format!(
104 "{}/organization/sponsorship/redeem",
105 configuration.base_path
106 );
107 let mut req_builder = configuration
108 .client
109 .request(reqwest::Method::POST, &uri_str);
110
111 if let Some(ref param_value) = p_sponsorship_token {
112 req_builder = req_builder.query(&[("sponsorshipToken", ¶m_value.to_string())]);
113 }
114 if let Some(ref user_agent) = configuration.user_agent {
115 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
116 }
117 if let Some(ref token) = configuration.oauth_access_token {
118 req_builder = req_builder.bearer_auth(token.to_owned());
119 };
120 req_builder = req_builder.json(&p_organization_sponsorship_redeem_request_model);
121
122 let req = req_builder.build()?;
123 let resp = configuration.client.execute(req).await?;
124
125 let status = resp.status();
126
127 if !status.is_client_error() && !status.is_server_error() {
128 Ok(())
129 } else {
130 let content = resp.text().await?;
131 let entity: Option<OrganizationSponsorshipRedeemPostError> =
132 serde_json::from_str(&content).ok();
133 Err(Error::ResponseError(ResponseContent {
134 status,
135 content,
136 entity,
137 }))
138 }
139}
140
141pub async fn organization_sponsorship_sponsored_sponsored_org_id_delete(
142 configuration: &configuration::Configuration,
143 sponsored_org_id: uuid::Uuid,
144) -> Result<(), Error<OrganizationSponsorshipSponsoredSponsoredOrgIdDeleteError>> {
145 let p_sponsored_org_id = sponsored_org_id;
147
148 let uri_str = format!(
149 "{}/organization/sponsorship/sponsored/{sponsoredOrgId}",
150 configuration.base_path,
151 sponsoredOrgId = crate::apis::urlencode(p_sponsored_org_id.to_string())
152 );
153 let mut req_builder = configuration
154 .client
155 .request(reqwest::Method::DELETE, &uri_str);
156
157 if let Some(ref user_agent) = configuration.user_agent {
158 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
159 }
160 if let Some(ref token) = configuration.oauth_access_token {
161 req_builder = req_builder.bearer_auth(token.to_owned());
162 };
163
164 let req = req_builder.build()?;
165 let resp = configuration.client.execute(req).await?;
166
167 let status = resp.status();
168
169 if !status.is_client_error() && !status.is_server_error() {
170 Ok(())
171 } else {
172 let content = resp.text().await?;
173 let entity: Option<OrganizationSponsorshipSponsoredSponsoredOrgIdDeleteError> =
174 serde_json::from_str(&content).ok();
175 Err(Error::ResponseError(ResponseContent {
176 status,
177 content,
178 entity,
179 }))
180 }
181}
182
183pub async fn organization_sponsorship_sponsored_sponsored_org_id_remove_post(
184 configuration: &configuration::Configuration,
185 sponsored_org_id: uuid::Uuid,
186) -> Result<(), Error<OrganizationSponsorshipSponsoredSponsoredOrgIdRemovePostError>> {
187 let p_sponsored_org_id = sponsored_org_id;
189
190 let uri_str = format!(
191 "{}/organization/sponsorship/sponsored/{sponsoredOrgId}/remove",
192 configuration.base_path,
193 sponsoredOrgId = crate::apis::urlencode(p_sponsored_org_id.to_string())
194 );
195 let mut req_builder = configuration
196 .client
197 .request(reqwest::Method::POST, &uri_str);
198
199 if let Some(ref user_agent) = configuration.user_agent {
200 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
201 }
202 if let Some(ref token) = configuration.oauth_access_token {
203 req_builder = req_builder.bearer_auth(token.to_owned());
204 };
205
206 let req = req_builder.build()?;
207 let resp = configuration.client.execute(req).await?;
208
209 let status = resp.status();
210
211 if !status.is_client_error() && !status.is_server_error() {
212 Ok(())
213 } else {
214 let content = resp.text().await?;
215 let entity: Option<OrganizationSponsorshipSponsoredSponsoredOrgIdRemovePostError> =
216 serde_json::from_str(&content).ok();
217 Err(Error::ResponseError(ResponseContent {
218 status,
219 content,
220 entity,
221 }))
222 }
223}
224
225pub async fn organization_sponsorship_sponsoring_org_id_families_for_enterprise_post(
226 configuration: &configuration::Configuration,
227 sponsoring_org_id: uuid::Uuid,
228 organization_sponsorship_create_request_model: Option<
229 models::OrganizationSponsorshipCreateRequestModel,
230 >,
231) -> Result<(), Error<OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterprisePostError>> {
232 let p_sponsoring_org_id = sponsoring_org_id;
234 let p_organization_sponsorship_create_request_model =
235 organization_sponsorship_create_request_model;
236
237 let uri_str = format!(
238 "{}/organization/sponsorship/{sponsoringOrgId}/families-for-enterprise",
239 configuration.base_path,
240 sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string())
241 );
242 let mut req_builder = configuration
243 .client
244 .request(reqwest::Method::POST, &uri_str);
245
246 if let Some(ref user_agent) = configuration.user_agent {
247 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
248 }
249 if let Some(ref token) = configuration.oauth_access_token {
250 req_builder = req_builder.bearer_auth(token.to_owned());
251 };
252 req_builder = req_builder.json(&p_organization_sponsorship_create_request_model);
253
254 let req = req_builder.build()?;
255 let resp = configuration.client.execute(req).await?;
256
257 let status = resp.status();
258
259 if !status.is_client_error() && !status.is_server_error() {
260 Ok(())
261 } else {
262 let content = resp.text().await?;
263 let entity: Option<OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterprisePostError> =
264 serde_json::from_str(&content).ok();
265 Err(Error::ResponseError(ResponseContent {
266 status,
267 content,
268 entity,
269 }))
270 }
271}
272
273pub async fn organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post(
274 configuration: &configuration::Configuration,
275 sponsoring_org_id: uuid::Uuid,
276) -> Result<(), Error<OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterpriseResendPostError>> {
277 let p_sponsoring_org_id = sponsoring_org_id;
279
280 let uri_str = format!(
281 "{}/organization/sponsorship/{sponsoringOrgId}/families-for-enterprise/resend",
282 configuration.base_path,
283 sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string())
284 );
285 let mut req_builder = configuration
286 .client
287 .request(reqwest::Method::POST, &uri_str);
288
289 if let Some(ref user_agent) = configuration.user_agent {
290 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
291 }
292 if let Some(ref token) = configuration.oauth_access_token {
293 req_builder = req_builder.bearer_auth(token.to_owned());
294 };
295
296 let req = req_builder.build()?;
297 let resp = configuration.client.execute(req).await?;
298
299 let status = resp.status();
300
301 if !status.is_client_error() && !status.is_server_error() {
302 Ok(())
303 } else {
304 let content = resp.text().await?;
305 let entity: Option<
306 OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterpriseResendPostError,
307 > = serde_json::from_str(&content).ok();
308 Err(Error::ResponseError(ResponseContent {
309 status,
310 content,
311 entity,
312 }))
313 }
314}
315
316pub async fn organization_sponsorship_sponsoring_org_id_sync_status_get(
317 configuration: &configuration::Configuration,
318 sponsoring_org_id: uuid::Uuid,
319) -> Result<(), Error<OrganizationSponsorshipSponsoringOrgIdSyncStatusGetError>> {
320 let p_sponsoring_org_id = sponsoring_org_id;
322
323 let uri_str = format!(
324 "{}/organization/sponsorship/{sponsoringOrgId}/sync-status",
325 configuration.base_path,
326 sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string())
327 );
328 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
329
330 if let Some(ref user_agent) = configuration.user_agent {
331 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
332 }
333 if let Some(ref token) = configuration.oauth_access_token {
334 req_builder = req_builder.bearer_auth(token.to_owned());
335 };
336
337 let req = req_builder.build()?;
338 let resp = configuration.client.execute(req).await?;
339
340 let status = resp.status();
341
342 if !status.is_client_error() && !status.is_server_error() {
343 Ok(())
344 } else {
345 let content = resp.text().await?;
346 let entity: Option<OrganizationSponsorshipSponsoringOrgIdSyncStatusGetError> =
347 serde_json::from_str(&content).ok();
348 Err(Error::ResponseError(ResponseContent {
349 status,
350 content,
351 entity,
352 }))
353 }
354}
355
356pub async fn organization_sponsorship_sponsoring_organization_id_delete(
357 configuration: &configuration::Configuration,
358 sponsoring_organization_id: uuid::Uuid,
359) -> Result<(), Error<OrganizationSponsorshipSponsoringOrganizationIdDeleteError>> {
360 let p_sponsoring_organization_id = sponsoring_organization_id;
362
363 let uri_str = format!(
364 "{}/organization/sponsorship/{sponsoringOrganizationId}",
365 configuration.base_path,
366 sponsoringOrganizationId = crate::apis::urlencode(p_sponsoring_organization_id.to_string())
367 );
368 let mut req_builder = configuration
369 .client
370 .request(reqwest::Method::DELETE, &uri_str);
371
372 if let Some(ref user_agent) = configuration.user_agent {
373 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
374 }
375 if let Some(ref token) = configuration.oauth_access_token {
376 req_builder = req_builder.bearer_auth(token.to_owned());
377 };
378
379 let req = req_builder.build()?;
380 let resp = configuration.client.execute(req).await?;
381
382 let status = resp.status();
383
384 if !status.is_client_error() && !status.is_server_error() {
385 Ok(())
386 } else {
387 let content = resp.text().await?;
388 let entity: Option<OrganizationSponsorshipSponsoringOrganizationIdDeleteError> =
389 serde_json::from_str(&content).ok();
390 Err(Error::ResponseError(ResponseContent {
391 status,
392 content,
393 entity,
394 }))
395 }
396}
397
398pub async fn organization_sponsorship_sponsoring_organization_id_delete_post(
399 configuration: &configuration::Configuration,
400 sponsoring_organization_id: uuid::Uuid,
401) -> Result<(), Error<OrganizationSponsorshipSponsoringOrganizationIdDeletePostError>> {
402 let p_sponsoring_organization_id = sponsoring_organization_id;
404
405 let uri_str = format!(
406 "{}/organization/sponsorship/{sponsoringOrganizationId}/delete",
407 configuration.base_path,
408 sponsoringOrganizationId = crate::apis::urlencode(p_sponsoring_organization_id.to_string())
409 );
410 let mut req_builder = configuration
411 .client
412 .request(reqwest::Method::POST, &uri_str);
413
414 if let Some(ref user_agent) = configuration.user_agent {
415 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
416 }
417 if let Some(ref token) = configuration.oauth_access_token {
418 req_builder = req_builder.bearer_auth(token.to_owned());
419 };
420
421 let req = req_builder.build()?;
422 let resp = configuration.client.execute(req).await?;
423
424 let status = resp.status();
425
426 if !status.is_client_error() && !status.is_server_error() {
427 Ok(())
428 } else {
429 let content = resp.text().await?;
430 let entity: Option<OrganizationSponsorshipSponsoringOrganizationIdDeletePostError> =
431 serde_json::from_str(&content).ok();
432 Err(Error::ResponseError(ResponseContent {
433 status,
434 content,
435 entity,
436 }))
437 }
438}
439
440pub async fn organization_sponsorship_sync_post(
441 configuration: &configuration::Configuration,
442 organization_sponsorship_sync_request_model: Option<
443 models::OrganizationSponsorshipSyncRequestModel,
444 >,
445) -> Result<
446 models::OrganizationSponsorshipSyncResponseModel,
447 Error<OrganizationSponsorshipSyncPostError>,
448> {
449 let p_organization_sponsorship_sync_request_model = organization_sponsorship_sync_request_model;
451
452 let uri_str = format!("{}/organization/sponsorship/sync", configuration.base_path);
453 let mut req_builder = configuration
454 .client
455 .request(reqwest::Method::POST, &uri_str);
456
457 if let Some(ref user_agent) = configuration.user_agent {
458 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
459 }
460 if let Some(ref token) = configuration.oauth_access_token {
461 req_builder = req_builder.bearer_auth(token.to_owned());
462 };
463 req_builder = req_builder.json(&p_organization_sponsorship_sync_request_model);
464
465 let req = req_builder.build()?;
466 let resp = configuration.client.execute(req).await?;
467
468 let status = resp.status();
469 let content_type = resp
470 .headers()
471 .get("content-type")
472 .and_then(|v| v.to_str().ok())
473 .unwrap_or("application/octet-stream");
474 let content_type = super::ContentType::from(content_type);
475
476 if !status.is_client_error() && !status.is_server_error() {
477 let content = resp.text().await?;
478 match content_type {
479 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
480 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSponsorshipSyncResponseModel`"))),
481 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::OrganizationSponsorshipSyncResponseModel`")))),
482 }
483 } else {
484 let content = resp.text().await?;
485 let entity: Option<OrganizationSponsorshipSyncPostError> =
486 serde_json::from_str(&content).ok();
487 Err(Error::ResponseError(ResponseContent {
488 status,
489 content,
490 entity,
491 }))
492 }
493}
494
495pub async fn organization_sponsorship_validate_token_post(
496 configuration: &configuration::Configuration,
497 sponsorship_token: Option<&str>,
498) -> Result<
499 models::PreValidateSponsorshipResponseModel,
500 Error<OrganizationSponsorshipValidateTokenPostError>,
501> {
502 let p_sponsorship_token = sponsorship_token;
504
505 let uri_str = format!(
506 "{}/organization/sponsorship/validate-token",
507 configuration.base_path
508 );
509 let mut req_builder = configuration
510 .client
511 .request(reqwest::Method::POST, &uri_str);
512
513 if let Some(ref param_value) = p_sponsorship_token {
514 req_builder = req_builder.query(&[("sponsorshipToken", ¶m_value.to_string())]);
515 }
516 if let Some(ref user_agent) = configuration.user_agent {
517 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
518 }
519 if let Some(ref token) = configuration.oauth_access_token {
520 req_builder = req_builder.bearer_auth(token.to_owned());
521 };
522
523 let req = req_builder.build()?;
524 let resp = configuration.client.execute(req).await?;
525
526 let status = resp.status();
527 let content_type = resp
528 .headers()
529 .get("content-type")
530 .and_then(|v| v.to_str().ok())
531 .unwrap_or("application/octet-stream");
532 let content_type = super::ContentType::from(content_type);
533
534 if !status.is_client_error() && !status.is_server_error() {
535 let content = resp.text().await?;
536 match content_type {
537 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
538 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PreValidateSponsorshipResponseModel`"))),
539 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::PreValidateSponsorshipResponseModel`")))),
540 }
541 } else {
542 let content = resp.text().await?;
543 let entity: Option<OrganizationSponsorshipValidateTokenPostError> =
544 serde_json::from_str(&content).ok();
545 Err(Error::ResponseError(ResponseContent {
546 status,
547 content,
548 entity,
549 }))
550 }
551}