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

/// WebSearchLocationParam : Approximate user location used to localize web search results.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct WebSearchLocationParam {
    /// The two-letter ISO country code, such as `US`.
    #[serde(
        rename = "country",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub country: Option<Option<String>>,
    /// The region or state name.
    #[serde(
        rename = "region",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub region: Option<Option<String>>,
    /// The city name.
    #[serde(
        rename = "city",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub city: Option<Option<String>>,
    /// The IANA timezone, such as `America/Los_Angeles`.
    #[serde(
        rename = "timezone",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub timezone: Option<Option<String>>,
}

impl WebSearchLocationParam {
    /// Approximate user location used to localize web search results.
    pub fn new() -> WebSearchLocationParam {
        WebSearchLocationParam {
            country: None,
            region: None,
            city: None,
            timezone: None,
        }
    }
}

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