gw2lib_model/
authenticated.rs1use std::collections::BTreeSet;
2
3use serde::{Deserialize, Serialize};
4
5use crate::{Endpoint, FixedEndpoint, TimeStamp};
6pub mod account;
7pub mod characters;
8pub mod commerce;
9
10#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
11#[cfg_attr(test, serde(deny_unknown_fields))]
12#[serde(rename_all = "lowercase")]
13pub enum Permissions {
14 Account,
15 Builds,
16 Characters,
17 Guilds,
18 Inventories,
19 Progression,
20 PvP,
21 TradingPost,
22 Unlocks,
23 Wallet,
24}
25
26#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
27#[cfg_attr(test, serde(deny_unknown_fields))]
28pub enum TokenType {
29 APIKey,
30 Subtoken,
31}
32
33#[derive(Clone, Debug, Serialize, Deserialize)]
34#[cfg_attr(test, serde(deny_unknown_fields))]
35pub struct SubtokenDetails {
36 pub expires_at: TimeStamp,
37 pub issued_at: TimeStamp,
38 pub urls: Option<Vec<String>>,
39}
40
41#[derive(Clone, Debug, Serialize, Deserialize)]
42#[cfg_attr(test, serde(deny_unknown_fields))]
43pub struct Tokeninfo {
44 pub id: String,
45 pub name: String,
46 pub permissions: BTreeSet<Permissions>,
47 #[serde(rename = "type")]
48 pub _type: TokenType,
49 #[serde(flatten)]
50 details: Option<SubtokenDetails>,
51}
52
53impl Endpoint for Tokeninfo {
54 const AUTHENTICATED: bool = true;
55 const LOCALE: bool = false;
56 const URL: &'static str = "v2/tokeninfo";
57 const VERSION: &'static str = "2021-01-11T00:00:00.000Z";
58}
59
60impl FixedEndpoint for Tokeninfo {}