Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions mantle/rbx_api/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,6 @@ where
serde_json::from_str::<T>(&full).map_err(|e| e.into())
}

pub async fn handle_as_json_with_status<T>(
result: Result<reqwest::Response, CsrfTokenRequestError>,
) -> RobloxApiResult<T>
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::<RobloxApiErrorResponse>(&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::<T>(&data)?)
}

pub async fn get_file_part(file_path: &Path) -> RobloxApiResult<Part> {
debug!("stream read {:?}", &file_path);
let file = File::open(file_path).await?;
Expand Down
17 changes: 7 additions & 10 deletions mantle/rbx_api/src/places/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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::<RemovePlaceResponse>(res).await?;
handle(res).await?;

Ok(())
}
Expand Down
4 changes: 0 additions & 4 deletions mantle/rbx_api/src/places/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down