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, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct PublicCreateEndpointBody {
    /// A human-readable name for the webhook 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<models::ProjectEventTypeEnum>,
}

impl PublicCreateEndpointBody {
    pub fn new(
        name: String,
        url: String,
        event_types: Vec<models::ProjectEventTypeEnum>,
    ) -> PublicCreateEndpointBody {
        PublicCreateEndpointBody {
            name,
            url,
            event_types,
        }
    }
}

impl std::fmt::Display for PublicCreateEndpointBody {
    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),
        }
    }
}