From 4aa8c21e474924c35d46301e55f43c4b98cc9d9e Mon Sep 17 00:00:00 2001 From: Chloe-Woahie <68732833+Chloe-Woahie@users.noreply.github.com> Date: Sun, 21 May 2023 00:24:58 -0400 Subject: [PATCH 1/7] chore: edit todos --- src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b6857e5..6a6e049 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -226,7 +226,6 @@ pub mod users; /// A module related to validating requests. mod validation; -// todo: endpoints that require premium/robux to test: recent trades, send trade, buy limited item, buy non-limited item // todo: inventory api, groups api, follow api // todo: add usage to readme // todo: every type should have an explanation of the typical means by which the user will construct or fetch it, if the answer isn't “this is a struct literal with public methods”. @@ -235,9 +234,6 @@ mod validation; // todo: maybe post on devforums, reddit, maybe the rust server // todo: put string of parsing error in MalformedResponse // todo: apparently a v2 details api does 500 items at once -// todo: name apis api bedev2 or something -// todo: rename methods and docs to remain consistent over what non-tradable limiteds are called. -// todo: add method to get items from catalog // todo: make ItemDetails include both price and lowest price // todo: replace urls with the form GROUP_ROLES_API.replace("{group_id}", &group_id.to_string()); // todo: maybe add stronger types for stuff like cursors? stuff that can be returned basically From a01e50fc62dd0de1ec6d0d3a9d4c614f54a419c0 Mon Sep 17 00:00:00 2001 From: Chloe-Woahie <68732833+Chloe-Woahie@users.noreply.github.com> Date: Sun, 21 May 2023 14:12:19 -0400 Subject: [PATCH 2/7] docs: add note --- src/thumbnails/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/thumbnails/mod.rs b/src/thumbnails/mod.rs index 359a4f0..0032cf4 100644 --- a/src/thumbnails/mod.rs +++ b/src/thumbnails/mod.rs @@ -77,6 +77,7 @@ impl Client { /// /// # Notes /// * Does not require a valid roblosecurity. + /// * Can handle up to 100 asset ids at once. /// /// # Errors /// * All errors under [Standard Errors](#standard-errors). From c2485f97baf8424162744d3ff1350eee273fe18c Mon Sep 17 00:00:00 2001 From: Chloe-Woahie <68732833+Chloe-Woahie@users.noreply.github.com> Date: Wed, 24 May 2023 18:53:51 -0400 Subject: [PATCH 3/7] feat: add trade_count() --- src/trades/mod.rs | 41 +++++++++++++++++++++++++++++++++++++ src/trades/request_types.rs | 5 +++++ 2 files changed, 46 insertions(+) diff --git a/src/trades/mod.rs b/src/trades/mod.rs index 787c02b..ae87b11 100644 --- a/src/trades/mod.rs +++ b/src/trades/mod.rs @@ -10,6 +10,7 @@ const TRADE_DETAILS_API: &str = "https://trades.roblox.com/v1/trades/{trade_id}" const DECLINE_TRADE_API: &str = "https://trades.roblox.com/v1/trades/{trade_id}/decline"; const SEND_TRADE_API: &str = "https://trades.roblox.com/v1/trades/send"; const ACCEPT_TRADE_API: &str = "https://trades.roblox.com/v1/trades/{trade_id}/accept"; +const TRADE_COUNT_API: &str = "https://trades.roblox.com/v1/trades/inbound/count"; /// For requests related to trades, we use Descending as the sort order. /// This is because there is hardly any use case for using a reverse sort order for trades. @@ -463,6 +464,46 @@ impl Client { }, } } + + /// Retrieves the count of trades the user using . + /// + /// # Notes + /// * Requires a valid roblosecurity. + /// + /// # Errors + /// * All errors under [Standard Errors](#standard-errors). + /// * All errors under [Auth Required Errors](#auth-required-errors). + /// + /// # Examples + /// + /// ```no_run + /// use roboat::Client; + /// use roboat::RoboatError; + /// + /// # #[tokio::main] + /// # async fn main() -> Result<(), RoboatError> { + /// let client = Client::new(); + /// let trade_count = client.trade_count().await?; + /// + /// println!("Total trades: {}", trade_count); + /// # Ok(()) + /// # } + /// ``` + pub async fn trade_count(&self) -> Result { + let cookie_string = self.cookie_string()?; + + let response_result = self + .reqwest_client + .get(TRADE_COUNT_API) + .header(header::COOKIE, cookie_string) + .send() + .await; + + let response = Self::validate_request_result(response_result).await?; + let raw = Self::parse_to_raw::(response).await?; + + Ok(raw.count) + } } mod internal { diff --git a/src/trades/request_types.rs b/src/trades/request_types.rs index 8e17d12..5180d29 100644 --- a/src/trades/request_types.rs +++ b/src/trades/request_types.rs @@ -91,3 +91,8 @@ pub(super) struct SendTradeOffer { pub(super) struct SendTradeResponse { pub id: u64, } + +#[derive(Serialize, Deserialize)] +pub(super) struct TradeCountResponse { + pub count: u64, +} From c4c22225c4693901029ff70d68ce13f3e580bd97 Mon Sep 17 00:00:00 2001 From: Chloe-Woahie <68732833+Chloe-Woahie@users.noreply.github.com> Date: Wed, 24 May 2023 18:54:00 -0400 Subject: [PATCH 4/7] chore: add example for trade_count() --- examples/fetch_trade_count.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/fetch_trade_count.rs diff --git a/examples/fetch_trade_count.rs b/examples/fetch_trade_count.rs new file mode 100644 index 0000000..7124bbf --- /dev/null +++ b/examples/fetch_trade_count.rs @@ -0,0 +1,23 @@ +use clap::Parser; +use roboat::ClientBuilder; +use roboat::RoboatError; + +#[derive(Parser, Debug)] +struct Args { + #[arg(long, short)] + roblosecurity: String, +} + +#[tokio::main] +async fn main() -> Result<(), RoboatError> { + let args = Args::parse(); + let client = ClientBuilder::new() + .roblosecurity(args.roblosecurity) + .build(); + + let trade_count = client.trade_count().await?; + + println!("Total trades: {}", trade_count); + + Ok(()) +} From cd4492b9f934b43b866e42d913a6bc89b708a66d Mon Sep 17 00:00:00 2001 From: Chloe-Woahie <68732833+Chloe-Woahie@users.noreply.github.com> Date: Wed, 24 May 2023 18:57:55 -0400 Subject: [PATCH 5/7] chore: reflect api coverage --- README.md | 1 + src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index ef58620..378a866 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Documentation can be found [here](https://docs.rs/roboat/). - Send Trade - [`Client::send_trade`](https://docs.rs/roboat/latest/roboat/struct.Client.html#method.send_trade) - Fetch Trades List - [`Client::trades`](https://docs.rs/roboat/latest/roboat/struct.Client.html#method.trades) - Fetch Trade Details - [`Client::trade_details`](https://docs.rs/roboat/latest/roboat/struct.Client.html#method.trade_details) + - Fetch Trade Count - [`Client::trade_count`](https://docs.rs/roboat/latest/roboat/struct.Client.html#method.trade_count) * Users API - [`users.roblox.com/*`] - Fetch User ID - [`Client::user_id`](https://docs.rs/roboat/latest/roboat/struct.Client.html#method.user_id) - Fetch Username - [`Client::username`](https://docs.rs/roboat/latest/roboat/struct.Client.html#method.username) diff --git a/src/lib.rs b/src/lib.rs index 6a6e049..c8d73c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,6 +50,7 @@ //! - Send Trade - [`Client::send_trade`] //! - Fetch Trade Details - [`Client::trade_details`] //! - Fetch Trades List - [`Client::trades`] +//! - Fetch Trade Count - [`Client::trade_count`] //! * Users API //! - Fetch User ID - [`Client::user_id`] //! - Fetch Username - [`Client::username`] From 7d53f266893f3e194ecc329a094c98325b541bb4 Mon Sep 17 00:00:00 2001 From: Chloe-Woahie <68732833+Chloe-Woahie@users.noreply.github.com> Date: Wed, 24 May 2023 18:58:06 -0400 Subject: [PATCH 6/7] chore: increase crate version --- Cargo.toml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6745f30..7500750 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" name = "roboat" readme = "README.md" repository = "https://github.com/Chloe-Woahie/roboat" -version = "0.29.0" +version = "0.30.0" [dependencies] reqwest = { version = "0.11.14", default-features=false, features = ["rustls-tls", "json"] } diff --git a/README.md b/README.md index 378a866..07e34e1 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ Alternatively, you can add a specific version of roboat to your project by addin ```toml [dependencies] -roboat = "0.29.0" +roboat = "0.30.0" ``` # Quick Start Examples From f128284f136da692278d00297ec8f50ff51f0186 Mon Sep 17 00:00:00 2001 From: Chloe-Woahie <68732833+Chloe-Woahie@users.noreply.github.com> Date: Wed, 24 May 2023 19:02:00 -0400 Subject: [PATCH 7/7] chore: fix doc test --- src/trades/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/trades/mod.rs b/src/trades/mod.rs index ae87b11..e8325fb 100644 --- a/src/trades/mod.rs +++ b/src/trades/mod.rs @@ -477,12 +477,15 @@ impl Client { /// # Examples /// /// ```no_run - /// use roboat::Client; + /// use roboat::ClientBuilder; /// use roboat::RoboatError; /// + /// const ROBLOSECURITY: &str = "roblosecurity"; + /// /// # #[tokio::main] /// # async fn main() -> Result<(), RoboatError> { - /// let client = Client::new(); + /// let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build(); + /// /// let trade_count = client.trade_count().await?; /// /// println!("Total trades: {}", trade_count);