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};

/// WebSearchCallItemResource : A web search call produced by the agent.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct WebSearchCallItemResource {
    /// The item type. Always `web_search_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The ID of the web search call.
    #[serde(rename = "id")]
    pub id: String,
    /// The ID of the turn that contains this item.
    #[serde(rename = "turn_id")]
    pub turn_id: String,
    #[serde(rename = "status")]
    pub status: models::OutputItemStatusResource,
    #[serde(rename = "action", deserialize_with = "Option::deserialize")]
    pub action: Option<Box<models::WebSearchActionResource>>,
}

impl WebSearchCallItemResource {
    /// A web search call produced by the agent.
    pub fn new(
        r#type: Type,
        id: String,
        turn_id: String,
        status: models::OutputItemStatusResource,
        action: Option<models::WebSearchActionResource>,
    ) -> WebSearchCallItemResource {
        WebSearchCallItemResource {
            r#type,
            id,
            turn_id,
            status,
            action: action.map(Box::new),
        }
    }
}
/// The item type. Always `web_search_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "web_search_call")]
    WebSearchCall,
}

impl Default for Type {
    fn default() -> Type {
        Self::WebSearchCall
    }
}

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