submissions-api: add create internal endpoints

This commit is contained in:
Quaternions 2025-04-02 15:31:15 -07:00
parent 31bc5f91b0
commit 53b3769094
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131
2 changed files with 60 additions and 2 deletions
validation/api/src

@ -150,6 +150,17 @@ impl Context{
).await.map_err(Error::Response)?
.json().await.map_err(Error::ReqwestJson)
}
pub async fn create_submission<'a>(&self,config:CreateSubmissionRequest<'a>)->Result<SubmissionIDResponse,Error>{
let url_raw=format!("{}/submissions",self.0.base_url);
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
response_ok(
self.0.post(url,body).await.map_err(Error::Reqwest)?
).await.map_err(Error::Response)?
.json().await.map_err(Error::ReqwestJson)
}
// simple submission endpoints
action!("submissions",action_submission_validated,config,SubmissionID,"validator-validated",config.0,);
action!("submissions",update_submission_validated_model,config,UpdateSubmissionModelRequest,"validated-model",config.SubmissionID,
@ -162,6 +173,17 @@ impl Context{
action!("submissions",action_submission_accepted,config,ActionSubmissionAcceptedRequest,"validator-failed",config.SubmissionID,
("StatusMessage",config.StatusMessage.as_str())
);
pub async fn create_mapfix<'a>(&self,config:CreateMapfixRequest<'a>)->Result<MapfixIDResponse,Error>{
let url_raw=format!("{}/mapfixes",self.0.base_url);
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
response_ok(
self.0.post(url,body).await.map_err(Error::Reqwest)?
).await.map_err(Error::Response)?
.json().await.map_err(Error::ReqwestJson)
}
// simple mapfixes endpoints
action!("mapfixes",action_mapfix_validated,config,MapfixID,"validator-validated",config.0,);
action!("mapfixes",update_mapfix_validated_model,config,UpdateMapfixModelRequest,"validated-model",config.MapfixID,

@ -61,6 +61,42 @@ pub async fn response_ok(response:reqwest::Response)->Result<reqwest::Response,R
}
}
#[allow(nonstandard_style)]
#[derive(Clone,Debug,serde::Serialize)]
pub struct CreateMapfixRequest<'a>{
pub OperationID:i32,
pub AssetOwner:i64,
pub DisplayName:&'a str,
pub Creator:&'a str,
pub GameID:i32,
pub AssetID:u64,
pub AssetVersion:u64,
pub TargetAssetID:u64,
}
#[allow(nonstandard_style)]
#[derive(Clone,Debug,serde::Deserialize)]
pub struct MapfixIDResponse{
pub ID:MapfixID,
}
#[allow(nonstandard_style)]
#[derive(Clone,Debug,serde::Serialize)]
pub struct CreateSubmissionRequest<'a>{
pub OperationID:i32,
pub AssetOwner:i64,
pub DisplayName:&'a str,
pub Creator:&'a str,
pub GameID:i32,
pub AssetID:u64,
pub AssetVersion:u64,
}
#[allow(nonstandard_style)]
#[derive(Clone,Debug,serde::Deserialize)]
pub struct SubmissionIDResponse{
pub ID:SubmissionID,
}
#[derive(Clone,Copy,Debug,PartialEq,Eq,serde::Serialize,serde::Deserialize)]
pub struct ScriptID(pub(crate)i64);
#[derive(Clone,Copy,Debug,serde::Serialize,serde::Deserialize)]
@ -200,7 +236,7 @@ pub struct ActionSubmissionAcceptedRequest{
pub StatusMessage:String,
}
#[derive(Clone,Copy,Debug)]
#[derive(Clone,Copy,Debug,serde::Deserialize)]
pub struct SubmissionID(pub i64);
#[allow(nonstandard_style)]
@ -224,5 +260,5 @@ pub struct ActionMapfixAcceptedRequest{
pub StatusMessage:String,
}
#[derive(Clone,Copy,Debug)]
#[derive(Clone,Copy,Debug,serde::Deserialize)]
pub struct MapfixID(pub i64);