1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use serde::Deserialize;

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
/// Represents a Minehut product response from the API. It 
/// contains most information about a product. Due to the response
/// body from the API, many fields are optional.
pub struct Product {
    /// The sku, no idea what this is.
    pub sku: String,
    /// Credits to buy the product.
    pub price: usize,
    /// Sale price to buy product, can be different from price and may not exist.
    pub sale_price: Option<usize>,
    /// Title of the product.
    pub title: String,
    /// Shorter title of the product, may not exist.
    pub short_title: Option<String>,
    /// Description of the product.
    pub description: String,
    /// Short description of the product, may not exist.
    pub short_description: Option<String>,
    /// Category of the product.
    pub category: String,
    /// Type of the product, might not exist.
    #[serde(rename = "type")]
    pub product_type: Option<String>,
    /// Tags of the product, usually does not exist.
    pub tags: Option<Vec<ProductTag>>,
    /// Whether product is visible.
    pub visible: bool,
    /// Other details of the product.
    pub details: ProductDetails,
    /// When the product was last updates.
    pub updated_at: String,
    /// When the product was created.
    pub created_at: String,
    /// Status of the product.
    pub status: String,
    /// When product was released, if it was.
    pub release_date: Option<String>,
    /// If it is unpublished, may not exist.
    pub unpublished: Option<bool>,
    /// On wishlist, does not make sense.
    pub on_wishlist: bool, 
    /// Is owned. Still does not make sense.
    pub is_owned: bool 
}


#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
/// Represents more details for Product struct such as supported
/// languages, contributors and links.
pub struct ProductDetails {
    /// Promotional discount option.
    #[serde(rename = "promotionalDiscountOptIn")]
    pub promo_disc_opt_in: Option<bool>,
    /// All supported languages.
    pub supported_languages: Vec<String>,
    /// Contributors.
    pub contributors: Vec<String>,
    /// Wether product is managed.
    pub managed: bool,
    /// Product related links.
    pub links: Vec<ProductLinks>,
    /// ID of the publisher.
    pub publisher_id: String,
    /// Name of the publisher.
    pub publisher_name: String,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
/// Links for the ProductDetails struct seen in ProductDetails. It
/// contains information about the link URL.
pub struct ProductLinks {
    #[serde(rename = "_id")]
    _id: String,
    /// Link text.
    pub link_text: String, 
    // Attached URL.
    pub link_url: String
}

#[derive(Debug, Deserialize)]
/// Tags used in Product struct, only contains a tag string.
pub struct ProductTag {
    _id: String,
    /// Tag name.
    pub tag: String
}