roblox_api/api/toolbox_service/
v1.rs1use crate::{AssetTypeId, DateTime, Paging, endpoint};
2
3pub const URL: &str = "https://apis.roblox.com/toolbox-service/v1";
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
8pub struct CreationObject {
9 pub id: u64,
10 pub name: String,
11}
12
13#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
14#[serde(rename_all = "camelCase")]
15pub struct Creations {
16 #[serde(rename = "totalResults")]
17 pub results: u16,
18 pub filtered_keyword: String,
19 #[serde(rename = "data")]
20 pub objects: Vec<CreationObject>,
21}
22
23#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
24#[serde(rename_all = "camelCase")]
25pub struct ItemDetailAsset {
26 pub id: u64,
27 pub name: String,
28 pub description: String,
29 pub type_id: u32,
30 pub duration: u32,
31 #[serde(rename = "visibilityStatus")]
32 pub visibility: u32,
33 pub is_endorsed: bool,
34 pub has_scripts: bool,
35 pub is_asset_hash_approved: bool,
36 #[serde(rename = "createdUtc")]
37 pub created: DateTime,
38 #[serde(rename = "updatedUtc")]
39 pub updated: DateTime,
40 #[serde(rename = "assetGenres")]
41 pub genres: Vec<String>,
42}
43
44#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
45pub struct ItemDetailCreator {
46 pub id: u64,
47 pub name: String,
48 #[serde(rename = "type")]
49 pub kind: u64,
50 #[serde(rename = "isVerifiedCreator")]
51 pub is_verified: bool,
52}
53
54#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
55#[serde(rename_all = "camelCase")]
56pub struct ItemDetailVotes {
57 #[serde(rename = "upVotes")]
58 pub likes: u32,
59 #[serde(rename = "downVotes")]
60 pub dislikes: u32,
61 #[serde(rename = "voteCount")]
62 pub votes: u32,
63 #[serde(rename = "upVotePercent")]
64 pub like_ratio: f32,
65 pub show_votes: bool,
66 pub can_vote: bool,
67 pub has_voted: bool,
68}
69
70#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
71pub struct FiatProductPriceQuantity {
72 pub significand: u32,
73 pub exponent: u32,
74}
75
76#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
77#[serde(rename_all = "camelCase")]
78pub struct FiatProductPrice {
79 pub currency_code: String,
80 pub quantity: FiatProductPriceQuantity,
81}
82
83#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
84pub struct FiatProduct {
85 #[serde(rename = "purchasePrice")]
86 pub price: FiatProductPrice,
87 pub published: bool,
88 pub purchasable: bool,
89}
90
91#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
92#[serde(rename_all = "camelCase")]
93pub struct ItemDetail {
94 pub asset: ItemDetailAsset,
95 pub creator: ItemDetailCreator,
96 #[serde(default, rename = "voting")]
97 pub votes: Option<ItemDetailVotes>,
98 pub fiat_product: FiatProduct,
99}
100
101endpoint! {
102 item_details(ids: &[u64]) -> Vec<ItemDetail> {
103 GET "{URL}/items/details";
104 types {
105 Response {
106 data: Vec<ItemDetail>,
107 }
108 }
109 prelude {
110 let ids = ids.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",");
111 }
112 query { "assetIds" => &ids }
113 map |r: Response| r.data
114 }
115
116 creations(id: u64, asset_type: AssetTypeId, paging: Paging<'_>) -> Creations {
117 GET "{URL}/creations/user/{id}/{asset_type_id}";
118 paging_query { paging, limit = 30 }
119 prelude {
120 let asset_type_id = asset_type as u8;
121 }
122 }
123}