openai-client-base 0.12.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};

/// CostsResult : The aggregated costs details of the specific time bucket.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CostsResult {
    #[serde(rename = "object")]
    pub object: Object,
    #[serde(rename = "amount", skip_serializing_if = "Option::is_none")]
    pub amount: Option<Box<models::CostsResultAmount>>,
    /// When `group_by=line_item`, this field provides the line item of the grouped costs result.
    #[serde(
        rename = "line_item",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub line_item: Option<Option<String>>,
    /// When `group_by=project_id`, this field provides the project ID of the grouped costs result.
    #[serde(
        rename = "project_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub project_id: Option<Option<String>>,
}

impl CostsResult {
    /// The aggregated costs details of the specific time bucket.
    pub fn new(object: Object) -> CostsResult {
        CostsResult {
            object,
            amount: None,
            line_item: None,
            project_id: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "organization.costs.result")]
    OrganizationCostsResult,
}

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

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