From 94a3bb8578795aebea0ccd22c64901165b8fca80 Mon Sep 17 00:00:00 2001 From: Blake Mealey Date: Mon, 3 Mar 2025 21:52:52 -0600 Subject: [PATCH] fix(rbx_api): replace deprecated remove-place api --- mantle/rbx_api/src/helpers.rs | 20 -------------------- mantle/rbx_api/src/places/mod.rs | 17 +++++++---------- mantle/rbx_api/src/places/models.rs | 4 ---- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/mantle/rbx_api/src/helpers.rs b/mantle/rbx_api/src/helpers.rs index f1eab3b..2e599f3 100644 --- a/mantle/rbx_api/src/helpers.rs +++ b/mantle/rbx_api/src/helpers.rs @@ -84,26 +84,6 @@ where serde_json::from_str::(&full).map_err(|e| e.into()) } -pub async fn handle_as_json_with_status( - result: Result, -) -> RobloxApiResult -where - T: de::DeserializeOwned, -{ - let response = handle(result).await?; - let status_code = response.status(); - let data = response.bytes().await?; - if let Ok(error) = serde_json::from_slice::(&data) { - if !error.success.unwrap_or(false) { - return Err(RobloxApiError::Roblox { - status_code, - reason: error.reason().unwrap_or_else(|| "Unknown error".to_owned()), - }); - } - } - Ok(serde_json::from_slice::(&data)?) -} - pub async fn get_file_part(file_path: &Path) -> RobloxApiResult { debug!("stream read {:?}", &file_path); let file = File::open(file_path).await?; diff --git a/mantle/rbx_api/src/places/mod.rs b/mantle/rbx_api/src/places/mod.rs index 03aa62d..0299dd7 100644 --- a/mantle/rbx_api/src/places/mod.rs +++ b/mantle/rbx_api/src/places/mod.rs @@ -4,14 +4,14 @@ use serde_json::json; use crate::{ errors::RobloxApiResult, - helpers::{handle, handle_as_json, handle_as_json_with_status}, + helpers::{handle, handle_as_json}, models::AssetId, RobloxApi, }; use self::models::{ CreatePlaceResponse, GetPlaceResponse, ListPlaceResponse, ListPlacesResponse, - PlaceConfigurationModel, RemovePlaceResponse, + PlaceConfigurationModel, }; impl RobloxApi { @@ -82,17 +82,14 @@ impl RobloxApi { let res = self .csrf_token_store .send_request(|| async { - Ok(self - .client - .post("https://www.roblox.com/universes/removeplace") - .form(&[ - ("universeId", &experience_id.to_string()), - ("placeId", &place_id.to_string()), - ])) + Ok(self.client.post(format!( + "https://apis.roblox.com/universes/v1/universes/{}/places/{}/remove-place", + &experience_id, &place_id + ))) }) .await; - handle_as_json_with_status::(res).await?; + handle(res).await?; Ok(()) } diff --git a/mantle/rbx_api/src/places/models.rs b/mantle/rbx_api/src/places/models.rs index 3606827..53b6116 100644 --- a/mantle/rbx_api/src/places/models.rs +++ b/mantle/rbx_api/src/places/models.rs @@ -61,10 +61,6 @@ impl Default for PlaceConfigurationModel { } } -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct RemovePlaceResponse {} - #[derive(Deserialize)] #[serde(rename_all = "camelCase")] pub struct ListPlacesResponse {