use serde::{Deserialize, Serialize};
use steamid::SteamID;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradeOffer {
pub tradeofferid: u64,
pub partner: TradeOfferPartner,
pub active: bool,
pub primary: TradeOfferItems,
pub secondary: TradeOfferItems,
#[serde(default)]
pub banner_text: String,
#[serde(default)]
pub banner_timestamp: Option<i64>,
#[serde(default)]
pub status: TradeOfferStatus,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum TradeOfferStatus {
#[default]
Active,
Accepted,
Unavailable,
Countered,
Inactive,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradeOfferPartner {
#[serde(default)]
pub steamid: Option<SteamID>,
pub name: String,
pub avatar_hash: String,
pub link: String,
pub header: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradeOfferItems {
#[serde(default)]
pub steamid: Option<SteamID>,
pub items: Vec<TradeOfferItem>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradeOfferItem {
pub economy_item: String,
pub img: String,
#[serde(default)]
pub img_hi: String,
#[serde(default)]
pub missing: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradeOffersResponse {
pub incoming_offers: TradeOfferSummary,
pub sent_offers: TradeOfferSummary,
pub trade_hold_count: u32,
pub trade_offers: Vec<TradeOffer>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradeOfferSummary {
pub link: String,
pub count: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradeOfferAsset {
pub appid: u32,
pub contextid: String,
pub amount: u32,
pub assetid: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradeOfferResult {
pub tradeofferid: String,
pub needs_mobile_confirmation: bool,
pub needs_email_confirmation: bool,
pub email_domain: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ParsedTradeURL {
pub account_id: String,
pub steam_id: SteamID,
pub token: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InventoryCursor {
pub time: u64,
pub time_frac: u32,
pub s: u32,
}
impl Default for InventoryCursor {
fn default() -> Self {
use std::time::{SystemTime, UNIX_EPOCH};
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs();
Self { time: now, time_frac: 0, s: 0 }
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InventoryHistoryItem {
pub id: String,
pub timestamp: u64,
pub timestamp_str: String,
pub description: String,
pub plusminus: String,
pub trade_history_items: Vec<serde_json::Value>,
#[serde(default)]
pub steamid: Option<SteamID>,
pub trade_people: Option<TradePeople>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradePeople {
pub name: String,
pub url: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InventoryHistoryResult {
pub cursor: Option<InventoryCursor>,
pub trade_history: Vec<InventoryHistoryItem>,
}