openai-client-base 0.16.0

Auto-generated Rust client for the OpenAI API
/*
 * OpenAI API
 *
 * The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
 *
 * The version of the OpenAPI document: 2.3.0
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct WebhookEndpointBody {
    /// The unique ID of the webhook endpoint.
    #[serde(rename = "id")]
    pub id: String,
    /// The object type, which is always webhook_endpoint.
    #[serde(rename = "object")]
    pub object: Object,
    /// The Unix timestamp when the endpoint was created.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// The Unix timestamp of the last endpoint configuration or signing-secret change. Initialized at creation; tests and unchanged updates do not advance it.
    #[serde(rename = "updated_at", skip_serializing_if = "Option::is_none")]
    pub updated_at: Option<i32>,
    /// The human-readable name of the endpoint.
    #[serde(rename = "name")]
    pub name: String,
    /// The HTTPS URL that receives webhook deliveries.
    #[serde(rename = "url")]
    pub url: String,
    /// The event types that trigger deliveries to this endpoint.
    #[serde(rename = "event_types")]
    pub event_types: Vec<String>,
    /// A masked hint for the endpoint's signing secret.
    #[serde(
        rename = "signing_secret_hint",
        deserialize_with = "Option::deserialize"
    )]
    pub signing_secret_hint: Option<String>,
}

impl WebhookEndpointBody {
    pub fn new(
        id: String,
        object: Object,
        created_at: i32,
        name: String,
        url: String,
        event_types: Vec<String>,
        signing_secret_hint: Option<String>,
    ) -> WebhookEndpointBody {
        WebhookEndpointBody {
            id,
            object,
            created_at,
            updated_at: None,
            name,
            url,
            event_types,
            signing_secret_hint,
        }
    }
}
/// The object type, which is always webhook_endpoint.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "webhook_endpoint")]
    WebhookEndpoint,
}

impl Default for Object {
    fn default() -> Object {
        Self::WebhookEndpoint
    }
}

impl std::fmt::Display for WebhookEndpointBody {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match serde_json::to_string(self) {
            Ok(s) => write!(f, "{}", s),
            Err(_) => Err(std::fmt::Error),
        }
    }
}