/*
 * Tribufu API
 *
 * API to access Tribufu services.
 *
 * The version of the OpenAPI document: 1.3.0
 * Contact: contact@tribufu.com
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Package {
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    #[serde(rename = "name", deserialize_with = "Option::deserialize")]
    pub name: Option<String>,
    #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub description: Option<Option<String>>,
    #[serde(rename = "author_id", skip_serializing_if = "Option::is_none")]
    pub author_id: Option<String>,
    #[serde(rename = "image_url", deserialize_with = "Option::deserialize")]
    pub image_url: Option<String>,
    #[serde(rename = "application_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub application_id: Option<Option<String>>,
    #[serde(rename = "category_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub category_id: Option<Option<String>>,
    #[serde(rename = "download_count", skip_serializing_if = "Option::is_none")]
    pub download_count: Option<i32>,
    #[serde(rename = "last_download", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub last_download: Option<Option<String>>,
    #[serde(rename = "releases", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub releases: Option<Option<Vec<models::PackageRelease>>>,
    #[serde(rename = "created", skip_serializing_if = "Option::is_none")]
    pub created: Option<String>,
    #[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub updated: Option<Option<String>>,
}

impl Package {
    pub fn new(name: Option<String>, image_url: Option<String>) -> Package {
        Package {
            id: None,
            name,
            description: None,
            author_id: None,
            image_url,
            application_id: None,
            category_id: None,
            download_count: None,
            last_download: None,
            releases: None,
            created: None,
            updated: None,
        }
    }
}

