use crate::{
config::Config,
error::OpenAIError,
types::admin::invites::{Invite, InviteDeleteResponse, InviteListResponse, InviteRequest},
Client, RequestOptions,
};
pub struct Invites<'c, C: Config> {
client: &'c Client<C>,
pub(crate) request_options: RequestOptions,
}
impl<'c, C: Config> Invites<'c, C> {
pub fn new(client: &'c Client<C>) -> Self {
Self {
client,
request_options: RequestOptions::new(),
}
}
#[crate::byot(R = serde::de::DeserializeOwned)]
pub async fn list(&self) -> Result<InviteListResponse, OpenAIError> {
self.client
.get("/organization/invites", &self.request_options)
.await
}
#[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
pub async fn retrieve(&self, invite_id: &str) -> Result<Invite, OpenAIError> {
self.client
.get(
format!("/organization/invites/{invite_id}").as_str(),
&self.request_options,
)
.await
}
#[crate::byot(T0 = serde::Serialize, R = serde::de::DeserializeOwned)]
pub async fn create(&self, request: InviteRequest) -> Result<Invite, OpenAIError> {
self.client
.post("/organization/invites", request, &self.request_options)
.await
}
#[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
pub async fn delete(&self, invite_id: &str) -> Result<InviteDeleteResponse, OpenAIError> {
self.client
.delete(
format!("/organization/invites/{invite_id}").as_str(),
&self.request_options,
)
.await
}
}