splatoon3_rs/endpoints/stages/
bankara.rs1use reqwest::StatusCode;
2
3use crate::{
4 client::SplaClient,
5 models::stages::{Schedule, StagesResponse},
6};
7
8const BANKARA_OPEN_NEXT_ENDPOINT: &str = "bankara-open/next";
9const BANKARA_CHALLENGE_SCHEDULE_ENDPOINT: &str = "bankara-challenge/schedule";
10
11impl SplaClient {
12 pub async fn get_next_bankara_open_stages(
13 &self,
14 ) -> Result<Vec<Schedule>, Box<dyn std::error::Error>> {
15 let base_url = &self.base_url;
16
17 let response = self
18 .client
19 .get(format!("{base_url}/{BANKARA_OPEN_NEXT_ENDPOINT}"))
20 .send()
21 .await?;
22
23 match response.status() {
24 StatusCode::OK => {
25 let bankara_open_stages: StagesResponse = response.json().await?;
26 Ok(bankara_open_stages.results)
27 }
28 status_code => {
29 Err(format!("API request failed with status code: {}", status_code).into())
30 }
31 }
32 }
33
34 pub async fn get_bankara_challenge_schedule(
35 &self,
36 ) -> Result<Vec<Schedule>, Box<dyn std::error::Error>> {
37 let base_url = &self.base_url;
38
39 let response = self
40 .client
41 .get(format!("{base_url}/{BANKARA_CHALLENGE_SCHEDULE_ENDPOINT}"))
42 .send()
43 .await?;
44
45 match response.status() {
46 StatusCode::OK => {
47 let bankara_challenge_stages: StagesResponse = response.json().await?;
48 Ok(bankara_challenge_stages.results)
49 }
50 status_code => {
51 Err(format!("API request failed with status code: {}", status_code).into())
52 }
53 }
54 }
55}