splatoon3_rs/endpoints/stages/
regular.rs1use reqwest::StatusCode;
2
3use crate::{
4 client::SplaClient,
5 models::stages::{Schedule, StagesResponse},
6};
7
8const REGULAR_NOW_ENDPOINT: &str = "regular/now";
9
10impl SplaClient {
11 pub async fn get_now_regular_open_stages(
12 &self,
13 ) -> Result<Vec<Schedule>, Box<dyn std::error::Error>> {
14 let base_url = &self.base_url;
15
16 let response = self
17 .client
18 .get(format!("{base_url}/{REGULAR_NOW_ENDPOINT}"))
19 .send()
20 .await?;
21
22 match response.status() {
23 StatusCode::OK => {
24 let regular_stages: StagesResponse = response.json().await?;
25 Ok(regular_stages.results)
26 }
27 status_code => {
28 Err(format!("API request failed with status code: {}", status_code).into())
29 }
30 }
31 }
32}