From 7063b20c20d4a1e064b2f188a4c114e1fd849934 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 16 Jul 2024 10:10:05 -0700 Subject: [PATCH] use cloud api for get_asset in cloud api module --- rbx_asset/src/cloud.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/rbx_asset/src/cloud.rs b/rbx_asset/src/cloud.rs index dc276c8..03ac425 100644 --- a/rbx_asset/src/cloud.rs +++ b/rbx_asset/src/cloud.rs @@ -279,16 +279,11 @@ impl CloudContext{ Ok(resp.json::().await.map_err(UpdateError::Reqwest)?) } pub async fn get_asset(&self,config:GetAssetRequest)->Result,GetError>{ - let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?; - //url borrow scope - { - let mut query=url.query_pairs_mut();//borrow here - query.append_pair("ID",config.asset_id.to_string().as_str()); - if let Some(version)=config.version{ - query.append_pair("version",version.to_string().as_str()); - } - } - let resp=self.get(url).await.map_err(GetError::Reqwest)?; + let raw_url=match config.version{ + Some(version)=>format!("https://apis.roblox.com/assets/v1/assets/{}/versions/{version}",config.asset_id), + None=>format!("https://apis.roblox.com/assets/v1/assets/{}",config.asset_id), + }; + let url=reqwest::Url::parse(raw_url.as_str()).map_err(GetError::ParseError)?; let body=self.get(url).await.map_err(GetError::Reqwest)? .error_for_status().map_err(GetError::Reqwest)?