openai-client-base 0.8.1

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

/// ResponseItemList : A list of Response items.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ResponseItemList {
    #[serde(rename = "object", deserialize_with = "Option::deserialize")]
    pub object: Option<serde_json::Value>,
    /// A list of items used to generate this response.
    #[serde(rename = "data")]
    pub data: Vec<models::ItemResource>,
    /// Whether there are more items available.
    #[serde(rename = "has_more")]
    pub has_more: bool,
    /// The ID of the first item in the list.
    #[serde(rename = "first_id")]
    pub first_id: String,
    /// The ID of the last item in the list.
    #[serde(rename = "last_id")]
    pub last_id: String,
}

impl ResponseItemList {
    /// A list of Response items.
    pub fn new(
        object: Option<serde_json::Value>,
        data: Vec<models::ItemResource>,
        has_more: bool,
        first_id: String,
        last_id: String,
    ) -> ResponseItemList {
        ResponseItemList {
            object,
            data,
            has_more,
            first_id,
            last_id,
        }
    }
}

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