Skip to main content

skyblock_rs/objects/
auction.rs

1use crate::objects::profile::PartialProfile;
2use crate::objects::items::Item;
3
4#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
5pub struct Claim {
6	pub claimed: bool,
7	// pub claimed_bidders: Vec<String>, // TODO
8}
9
10#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
11#[serde(transparent)]
12pub struct PartialAuction(pub String);
13
14#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
15pub struct Auction {
16	/// Hypixel's auction UUID, this can be utilized with the in-game command
17	/// `/viewauction <uuid>`.
18	pub uuid: PartialAuction,
19	/// A partial Skyblock profile, it only contains the UUID but can be upgraded through API calls. (TODO)
20	pub auctioneer: PartialProfile,
21	/// A list of co-op members in the auctioneer's Skyblock profile
22	pub coop: Vec<PartialProfile>,
23	/// Unix time (in milliseconds) of when the auction commenced.
24	pub start: i64,
25	/// Unix time (in milliseconds) of when the auction is currently projected to end.
26	/// This is only an estimate as it does not account for last-2-minute bids extending the end time.
27	pub end: i64,
28	/// Fields pertaining to the item itself.
29	#[serde(flatten)]
30	pub item: Item,
31	/// Fields pertaining to the bids on the item
32	#[serde(flatten)]
33	pub bids: Bids,
34	/// Fields related to whether the auction has been claimed
35	/// This does not appear to function correctly.
36	#[serde(flatten)]
37	pub claim: Claim,
38}
39
40/// A collection of bidding data.
41#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
42pub struct Bids {
43	/// The current highest price on the auction item
44	#[serde(rename = "highest_bid_amount")]
45	pub highest: i64,
46	/// The starting price of the auction item
47	#[serde(rename = "starting_bid")]
48	pub starting: i64,
49	/// The list of bids on the item
50	pub bids: Vec<Bid>,
51}
52
53/// A discrete bid on an item.
54#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
55pub struct Bid {
56	/// The auction which this bid belongs to.
57	pub auction_id: PartialAuction,
58	/// The profile-member that had placed a bid on the auction.
59	pub bidder: PartialProfile,
60	/// The amount of coins in the bid
61	pub amount: i64,
62	/// The time of the bid
63	pub timestamp: i64,
64}
65
66/// A page of auctions retrieved by the `skyblock/auctions` endpoint.
67#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)]
68pub struct GlobalAuctions {
69	/// The current page fetched
70	pub page: usize,
71	/// The total number of pages in the system
72	#[serde(rename = "totalPages")]
73	pub total_pages: usize,
74	/// The total number of auctions in the system
75	#[serde(rename = "totalAuctions")]
76	pub total_auctions: usize,
77	/// The timestamp of the last update that has occurred in the dataset
78	#[serde(rename = "lastUpdated")]
79	pub last_update: u64,
80	/// The list of auctions retrieved
81	pub auctions: Vec<Auction>,
82}
83
84/// An auction that had been searched by UUID.
85#[cfg(test)]
86#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)]
87pub struct SearchedAuctions {
88	pub auctions: Vec<Auction>,
89}