Skip to content

Commit

Permalink
add /get_examdetails endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
greybaron committed Aug 13, 2024
1 parent f2efb4b commit afb48a1
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 44 deletions.
65 changes: 33 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub async fn app() -> Router {
.route("/get_grades", get(services::get_grades))
.route("/get_examsignup", get(services::get_examsignup))
.route("/registerexam", post(services::post_registerexam))
.route("/get_examdetails", get(services::get_examdetails))
.route("/cancelexam", post(services::post_cancelexam))
.route("/get_examverfahren", get(services::get_examverfahren))
.route("/get_ects", get(services::get_ects))
Expand Down
33 changes: 26 additions & 7 deletions src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use crate::{
color_stuff::hex_to_luminance,
types::{
CampusDualGrade, CampusDualSignupOption, CampusDualVerfahrenOption, CampusLoginData,
CampusReminders, CampusTimeline, CampusTimelineEvent, CdAuthData, CdExamStats,
ExamRegistrationMetadata, ExportTimelineEvent, ExportTimelineEvents, LoginResponse,
ResponseError, StundenplanItem,
CampusReminders, CampusTimeline, CampusTimelineEvent, CdAuthData, CdExamDetails,
CdExamStats, ExamRegistrationMetadata, ExportTimelineEvent, ExportTimelineEvents,
LoginResponse, ResponseError, StundenplanItem,
},
};

Expand Down Expand Up @@ -124,11 +124,32 @@ pub async fn post_registerexam(
.await?
.error_for_status()?;

dbg!(exam_regist_resp.status());

Ok(exam_regist_resp.text().await?)
}

pub async fn get_examdetails(
Extension(cd_auth_data): Extension<CdAuthData>,
Json(examregist_meta): Json<ExamRegistrationMetadata>,
) -> Result<Json<CdExamDetails>, ResponseError> {
let client = get_client_default();
let exam_details: CdExamDetails = client
.get(format!(
"https://selfservice.campus-dual.de/acwork/offerdetail?user={}&objidexm=undefined&evob_objid={}&peryr={}&perid={}&offerno={}",
cd_auth_data.user,
examregist_meta.assessment,
examregist_meta.peryr,
examregist_meta.perid,
examregist_meta.offerno,
))
.send()
.await?
.error_for_status()?
.json()
.await?;

Ok(Json(exam_details))
}

pub async fn post_cancelexam(
Extension(cd_auth_data): Extension<CdAuthData>,
Json(examregist_meta): Json<ExamRegistrationMetadata>,
Expand All @@ -143,8 +164,6 @@ pub async fn post_cancelexam(
.await?
.error_for_status()?;

dbg!(exam_regist_resp.status());

Ok(exam_regist_resp.text().await?)
}

Expand Down
57 changes: 52 additions & 5 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,6 @@ pub struct CampusReminders {
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CampusTimeline {
// #[serde(rename = "wiki-url")]
// pub wiki_url: String,
// #[serde(rename = "wiki-section")]
// pub wiki_section: String,
// pub date_time_format: String,
pub events: Vec<CampusTimelineEvent>,
}

Expand Down Expand Up @@ -260,3 +255,55 @@ pub struct ExportTimelineEvent {
pub start: String,
pub end: String,
}

#[derive(Serialize, Deserialize)]
pub struct CdExamDetails {
#[serde(rename(deserialize = "EV_AGRTYPE_TEXT"))]
pub ev_agrtype_text: String,
#[serde(rename(deserialize = "EV_AUDTYPE_TEXT"))]
pub ev_audtype_text: String,
#[serde(rename(deserialize = "EV_CONTINUE_INDICATOR"))]
pub ev_continue_indicator: String,
#[serde(rename(deserialize = "EV_DEREG_END"))]
pub ev_dereg_end: String,
#[serde(rename(deserialize = "EV_DEREG_ENDTIME"))]
pub ev_dereg_endtime: String,
#[serde(rename(deserialize = "EV_DURATION"))]
pub ev_duration: String,
#[serde(rename(deserialize = "EV_DURUNIT"))]
pub ev_durunit: String,
#[serde(rename(deserialize = "EV_EXAMBEGTIME"))]
pub ev_exambegtime: String,
#[serde(rename(deserialize = "EV_EXAMDATE"))]
pub ev_examdate: String,
#[serde(rename(deserialize = "EV_EXAMENDTIME"))]
pub ev_examendtime: String,
#[serde(rename(deserialize = "EV_EXAMORG_TEXT"))]
pub ev_examorg_text: String,
#[serde(rename(deserialize = "EV_INSTRUCTOR"))]
pub ev_instructor: String,
#[serde(rename(deserialize = "EV_LOCATION_SHORT"))]
pub ev_location_short: String,
#[serde(rename(deserialize = "EV_LOCATION_STEXT"))]
pub ev_location_stext: String,
#[serde(rename(deserialize = "EV_OBTYPE_TEXT"))]
pub ev_obtype_text: String,
#[serde(rename(deserialize = "EV_REASON"))]
pub ev_reason: String,
#[serde(rename(deserialize = "EV_REGIS_BEGIN"))]
pub ev_regis_begin: String,
#[serde(rename(deserialize = "EV_REGIS_BEGTIME"))]
pub ev_regis_begtime: String,
#[serde(rename(deserialize = "EV_REGIS_END"))]
pub ev_regis_end: String,
#[serde(rename(deserialize = "EV_REGIS_ENDTIME"))]
pub ev_regis_endtime: String,
#[serde(rename(deserialize = "EV_ROOM_SHORT"))]
pub ev_room_short: String,
#[serde(rename(deserialize = "EV_ROOM_STEXT"))]
pub ev_room_stext: String,
#[serde(rename(deserialize = "EV_SHORT"))]
pub ev_short: String,
#[serde(rename(deserialize = "EV_STEXT"))]
pub ev_stext: String,
}

0 comments on commit afb48a1

Please sign in to comment.