dynamo_async_openai/types/
invites.rs

1// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Based on https://github.com/64bit/async-openai/ by Himanshu Neema
5// Original Copyright (c) 2022 Himanshu Neema
6// Licensed under MIT License (see ATTRIBUTIONS-Rust.md)
7//
8// Modifications Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
9// Licensed under Apache 2.0
10
11use crate::types::OpenAIError;
12use derive_builder::Builder;
13use serde::{Deserialize, Serialize};
14
15use super::OrganizationRole;
16
17#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
18#[serde(rename_all = "lowercase")]
19pub enum InviteStatus {
20    Accepted,
21    Expired,
22    Pending,
23}
24
25#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Builder)]
26#[builder(name = "InviteRequestArgs")]
27#[builder(pattern = "mutable")]
28#[builder(setter(into, strip_option))]
29#[builder(derive(Debug))]
30#[builder(build_fn(error = "OpenAIError"))]
31pub struct InviteRequest {
32    pub email: String,
33    pub role: OrganizationRole,
34}
35
36#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
37pub struct InviteListResponse {
38    pub object: String,
39    pub data: Vec<Invite>,
40    pub first_id: Option<String>,
41    pub last_id: Option<String>,
42    pub has_more: Option<bool>,
43}
44
45#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
46pub struct InviteDeleteResponse {
47    /// The object type, which is always `organization.invite.deleted`
48    pub object: String,
49    pub id: String,
50    pub deleted: bool,
51}
52
53/// Represents an individual `invite` to the organization.
54#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
55pub struct Invite {
56    /// The object type, which is always `organization.invite`
57    pub object: String,
58    /// The identifier, which can be referenced in API endpoints
59    pub id: String,
60    /// The email address of the individual to whom the invite was sent
61    pub email: String,
62    /// `owner` or `reader`
63    pub role: OrganizationRole,
64    /// `accepted`, `expired`, or `pending`
65    pub status: InviteStatus,
66    /// The Unix timestamp (in seconds) of when the invite was sent.
67    pub invited_at: u32,
68    /// The Unix timestamp (in seconds) of when the invite expires.
69    pub expires_at: u32,
70    /// The Unix timestamp (in seconds) of when the invite was accepted.
71    pub accepted_at: Option<u32>,
72}