artifacts-rs 1.8.0

Rust client for Artifacts
Documentation
use crate::models;
use serde::{Deserialize, Serialize};

/// AccountAchievementSchema : Full achievement data with progress - for API responses.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct AccountAchievementSchema {
    /// Name of the achievement.
    #[serde(rename = "name")]
    pub name: String,
    /// Code of the achievement.
    #[serde(rename = "code")]
    pub code: String,
    /// Description of the achievement.
    #[serde(rename = "description")]
    pub description: String,
    /// Points of the achievement. Used for the leaderboard.
    #[serde(rename = "points")]
    pub points: i32,
    /// List of objectives with progress.
    #[serde(rename = "objectives")]
    pub objectives: Vec<models::AccountAchievementObjectiveSchema>,
    /// Rewards.
    #[serde(rename = "rewards")]
    pub rewards: Box<models::AchievementRewardsSchema>,
    /// Completion timestamp.
    #[serde(rename = "completed_at", skip_serializing_if = "Option::is_none")]
    pub completed_at: Option<String>,
}

impl AccountAchievementSchema {
    /// Full achievement data with progress - for API responses.
    pub fn new(
        name: String,
        code: String,
        description: String,
        points: i32,
        objectives: Vec<models::AccountAchievementObjectiveSchema>,
        rewards: models::AchievementRewardsSchema,
    ) -> AccountAchievementSchema {
        AccountAchievementSchema {
            name,
            code,
            description,
            points,
            objectives,
            rewards: Box::new(rewards),
            completed_at: None,
        }
    }
}