cookie.get_user_inventory_page
This commit is contained in:
parent
94792ebf02
commit
ea0239c78b
@ -150,6 +150,38 @@ pub struct CreationsPageResponse{
|
||||
pub data:Vec<CreationsItem>,
|
||||
}
|
||||
|
||||
pub struct UserInventoryPageRequest{
|
||||
pub user_id:u64,
|
||||
pub cursor:Option<String>,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize,serde::Serialize)]
|
||||
#[allow(nonstandard_style,dead_code)]
|
||||
pub struct UserInventoryItemOwner{
|
||||
userId:u64,
|
||||
username:String,
|
||||
buildersClubMembershipType:u64,
|
||||
}
|
||||
#[derive(serde::Deserialize,serde::Serialize)]
|
||||
#[allow(nonstandard_style,dead_code)]
|
||||
pub struct UserInventoryItem{
|
||||
userAssetId:u64,
|
||||
assetId:u64,
|
||||
assetName:String,
|
||||
collectibleItemId:Option<String>,
|
||||
collectibleItemInstanceId:Option<String>,
|
||||
owner:UserInventoryItemOwner,
|
||||
created:chrono::DateTime<chrono::Utc>,
|
||||
updated:chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
#[derive(serde::Deserialize,serde::Serialize)]
|
||||
#[allow(nonstandard_style,dead_code)]
|
||||
pub struct UserInventoryPageResponse{
|
||||
pub previousPageCursor:Option<String>,
|
||||
pub nextPageCursor:Option<String>,
|
||||
pub data:Vec<UserInventoryItem>,
|
||||
}
|
||||
|
||||
//idk how to do this better
|
||||
enum ReaderType<R:std::io::Read>{
|
||||
GZip(flate2::read::GzDecoder<std::io::BufReader<R>>),
|
||||
@ -321,4 +353,18 @@ impl CookieContext{
|
||||
.error_for_status().map_err(PageError::Reqwest)?
|
||||
.json::<CreationsPageResponse>().await.map_err(PageError::Reqwest)
|
||||
}
|
||||
pub async fn get_user_inventory_page(&self,config:&UserInventoryPageRequest)->Result<UserInventoryPageResponse,PageError>{
|
||||
let mut url=reqwest::Url::parse(format!("https://inventory.roblox.com/v2/users/{}/inventory/10?limit=100&sortOrder=Desc",config.user_id).as_str()).map_err(PageError::ParseError)?;
|
||||
//url borrow scope
|
||||
{
|
||||
let mut query=url.query_pairs_mut();//borrow here
|
||||
if let Some(cursor)=config.cursor.as_deref(){
|
||||
query.append_pair("cursor",cursor);
|
||||
}
|
||||
}
|
||||
|
||||
self.get(url).await.map_err(PageError::Reqwest)?
|
||||
.error_for_status().map_err(PageError::Reqwest)?
|
||||
.json::<UserInventoryPageResponse>().await.map_err(PageError::Reqwest)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user