1pub type RecipeId = u32;
2
3use std::collections::BTreeSet;
4
5use serde::{Deserialize, Serialize};
6
7pub use crate::authenticated::characters::Discipline;
8use crate::{
9 guild::upgrades::GuildUpgradeId, items::ItemId, misc::currencies::CurrencyId, BulkEndpoint,
10 Endpoint, EndpointWithId,
11};
12
13#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
14#[cfg_attr(test, serde(deny_unknown_fields))]
15pub enum RecipeType {
16 Axe,
17 Dagger,
18 Focus,
19 Greatsword,
20 Hammer,
21 Harpoon,
22 LongBow,
23 Mace,
24 Pistol,
25 Rifle,
26 Scepter,
27 Shield,
28 ShortBow,
29 Speargun,
30 Staff,
31 Sword,
32 Torch,
33 Trident,
34 Warhorn,
35 Boots,
36 Coat,
37 Gloves,
38 Helm,
39 Leggings,
40 Shoulders,
41 Amulet,
42 Earring,
43 Ring,
44 Dessert,
45 Feast,
46 IngredientCooking,
47 Meal,
48 Seasoning,
49 Snack,
50 Soup,
51 Food,
52 Component,
53 Inscription,
54 Insignia,
55 LegendaryComponent,
56 Refinement,
57 RefinementEctoplasm,
58 RefinementObsidian,
59 GuildConsumable,
60 GuildDecoration,
61 GuildConsumableWvw,
62 Backpack,
63 Bag,
64 Bulk,
65 Consumable,
66 Dye,
67 Potion,
68 UpgradeComponent,
69}
70
71#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
72#[cfg_attr(test, serde(deny_unknown_fields))]
73pub enum RecipeFlag {
74 AutoLearned,
75 LearnedFromItem,
76}
77
78#[derive(Clone, Debug, Serialize, Deserialize)]
79#[serde(tag = "type")]
80#[cfg_attr(test, serde(deny_unknown_fields))]
81pub enum Ingredient {
82 Currency { id: CurrencyId, count: u16 },
83 Item { id: ItemId, count: u16 },
84 GuildUpgrade { id: GuildUpgradeId, count: u16 },
85}
86
87#[derive(Clone, Debug, Serialize, Deserialize)]
88#[cfg_attr(test, serde(deny_unknown_fields))]
89pub struct Recipe {
90 pub id: RecipeId,
91 #[serde(rename = "type")]
92 pub _type: RecipeType,
93 pub output_item_id: ItemId,
94 pub output_item_count: u16,
95 pub time_to_craft_ms: u16,
96 pub disciplines: BTreeSet<Discipline>,
97 pub min_rating: u16,
98 pub flags: BTreeSet<RecipeFlag>,
99 pub ingredients: Vec<Ingredient>,
100 pub output_upgrade_id: Option<u32>,
101 pub chat_link: String,
102}
103
104impl EndpointWithId for Recipe {
105 type IdType = RecipeId;
106}
107impl Endpoint for Recipe {
108 const AUTHENTICATED: bool = false;
109 const LOCALE: bool = false;
110 const URL: &'static str = "v2/recipes";
111 const VERSION: &'static str = "2023-03-20T13:00:00.000Z";
112}
113
114impl BulkEndpoint for Recipe {
115 const ALL: bool = false;
116
117 fn id(&self) -> &Self::IdType {
118 &self.id
119 }
120}