Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rustemon-static-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ async fn get_data(rc: &RustemonClient) -> anyhow::Result<Vec<(String, String, St
get_json_body(|| items::item_category::get_by_id(3, rc)).await?,
get_json_body(|| items::item_fling_effect::get_by_id(3, rc)).await?,
get_json_body(|| items::item_pocket::get_by_id(3, rc)).await?,
get_json_body(|| items::currency::get_by_id(1, rc)).await?,
// Locations endpoints
get_json_body(|| locations::location::get_by_id(5, rc)).await?,
get_json_body(|| locations::location_area::get_by_id(5, rc)).await?,
Expand Down
1 change: 1 addition & 0 deletions rustemon/examples/check_static_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async fn main() {
static_resources::get_item_category();
static_resources::get_item_fling_effect();
static_resources::get_item_pocket();
static_resources::get_currency();
static_resources::get_location();
static_resources::get_location_area();
static_resources::get_pal_park_area();
Expand Down
5 changes: 5 additions & 0 deletions rustemon/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ pub mod item_fling_effect {
pub mod item_pocket {
crate::endpoint!(crate::model::items::ItemPocket; for "item-pocket");
}

/// Currencies are forms of money used throughout the Pokémon games to purchase items, services, and participate in various game mechanics.
pub mod currency {
crate::endpoint!(crate::model::items::Currency; for "currency");
}
34 changes: 31 additions & 3 deletions rustemon/src/model/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use super::{
evolution::EvolutionChain,
games::Version,
games::{Version, VersionGroup},
pokemon::Pokemon,
resource::{
ApiResource, Description, Effect, GenerationGameIndex, MachineVersionDetail, Name,
Expand All @@ -18,8 +18,6 @@ pub struct Item {
pub id: i64,
/// The name for this resource.
pub name: String,
/// The price of this item in stores.
pub cost: i64,
/// The power of the move Fling when used with this item.
pub fling_power: Option<i64>,
/// The effect of the move Fling when used with this item.
Expand All @@ -34,6 +32,8 @@ pub struct Item {
pub flavor_text_entries: Vec<VersionGroupFlavorText>,
/// A list of game indices relevent to this item by generation.
pub game_indices: Vec<GenerationGameIndex>,
/// The purchase and sell prices of this item for each version group.
pub prices: Vec<ItemPrice>,
/// The name of this item listed in different languages.
pub names: Vec<Name>,
/// A set of sprites used to depict this item in the game.
Expand Down Expand Up @@ -133,3 +133,31 @@ pub struct ItemPocket {
/// The name of this resource listed in different languages.
pub names: Vec<Name>,
}

/// [Currency official documentation](https://pokeapi.co/docs/v2#currency)
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
pub struct Currency {
/// The identifier for this resource.
pub id: i64,
/// The name for this resource.
pub name: String,
/// The name of this resource listed in different languages.
pub names: Vec<Name>,
}

/// [ItemPrice official documentation](https://pokeapi.co/docs/v2#itemprice)
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
pub struct ItemPrice {
/// The currency used for this price.
pub currency: NamedApiResource<Currency>,
/// The purchase price of this item in this version group.
/// Null if the item cannot be purchased.
pub purchase_price: Option<i64>,
/// The sell price of this item in this version group.
/// Null if the item cannot be sold.
pub sell_price: Option<i64>,
/// The version group these prices apply to.
pub version_group: NamedApiResource<VersionGroup>,
}
Loading