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

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

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

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