async_openai_alt/
invites.rs1use serde::Serialize;
2
3use crate::{
4 config::Config,
5 error::OpenAIError,
6 types::{Invite, InviteDeleteResponse, InviteListResponse, InviteRequest},
7 Client,
8};
9
10pub struct Invites<'c, C: Config> {
12 client: &'c Client<C>,
13}
14
15impl<'c, C: Config> Invites<'c, C> {
16 pub fn new(client: &'c Client<C>) -> Self {
17 Self { client }
18 }
19
20 pub async fn list<Q>(&self, query: &Q) -> Result<InviteListResponse, OpenAIError>
22 where
23 Q: Serialize + ?Sized,
24 {
25 self.client
26 .get_with_query("/organization/invites", query)
27 .await
28 }
29
30 pub async fn retrieve(&self, invite_id: &str) -> Result<Invite, OpenAIError> {
32 self.client
33 .get(format!("/organization/invites/{invite_id}").as_str())
34 .await
35 }
36
37 pub async fn create(&self, request: InviteRequest) -> Result<Invite, OpenAIError> {
39 self.client.post("/organization/invites", request).await
40 }
41
42 pub async fn delete(&self, invite_id: &str) -> Result<InviteDeleteResponse, OpenAIError> {
44 self.client
45 .delete(format!("/organization/invites/{invite_id}").as_str())
46 .await
47 }
48}