rbx_asset keep typed UploadResponse
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Quaternions 2024-12-13 19:49:56 -08:00
parent 485e2c1c3a
commit f983655908

View File

@ -58,7 +58,12 @@ impl std::fmt::Display for UploadError{
}
}
impl std::error::Error for UploadError{}
type UploadResponse=u64;
type RobloxUploadResponse=u64;
#[derive(Debug,serde::Deserialize,serde::Serialize)]
#[allow(nonstandard_style,dead_code)]
pub struct UploadResponse{
pub AssetId:u64,
}
#[allow(nonstandard_style,dead_code)]
pub struct GetAssetRequest{
@ -267,11 +272,14 @@ impl CookieContext{
query.append_pair("groupId",group_id.to_string().as_str());
}
}
crate::response_ok(
let asset_id=crate::response_ok(
self.post(url,body).await.map_err(CreateError::PostError)?
).await.map_err(CreateError::Response)?
.json::<UploadResponse>().await.map_err(CreateError::Reqwest)
.json::<RobloxUploadResponse>().await.map_err(CreateError::Reqwest)?;
Ok(UploadResponse{
AssetId:asset_id,
})
}
pub async fn upload(&self,config:UploadRequest,body:impl Into<reqwest::Body>+Clone)->Result<UploadResponse,UploadError>{
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1").map_err(UploadError::ParseError)?;
@ -299,11 +307,14 @@ impl CookieContext{
query.append_pair("groupId",group_id.to_string().as_str());
}
}
crate::response_ok(
let asset_id=crate::response_ok(
self.post(url,body).await.map_err(UploadError::PostError)?
).await.map_err(UploadError::Response)?
.json::<UploadResponse>().await.map_err(UploadError::Reqwest)
.json::<RobloxUploadResponse>().await.map_err(UploadError::Reqwest)?;
Ok(UploadResponse{
AssetId:asset_id,
})
}
pub async fn get_asset(&self,config:GetAssetRequest)->Result<Vec<u8>,GetError>{
let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?;