pub struct Client { /* private fields */ }Expand description
A client for interacting with the OpenScheduleAPI.
The Client provides methods to query colleges, campuses, groups, and schedules.
It can be configured with a default college for convenience.
§Examples
use osars::Client;
let client = Client::new("https://api.example.com")
.with_college(1);Implementations§
Source§impl Client
impl Client
Sourcepub fn builder(base_url: impl Into<String>) -> ClientBuilder
pub fn builder(base_url: impl Into<String>) -> ClientBuilder
Create a new builder for constructing a Client.
Sourcepub fn default_college_id(&self) -> Option<u32>
pub fn default_college_id(&self) -> Option<u32>
Returns the default college ID if set.
Sourcepub fn with_college(self, college_id: u32) -> Self
pub fn with_college(self, college_id: u32) -> Self
Sourcepub fn colleges(&self) -> CollegesQuery<'_>
pub fn colleges(&self) -> CollegesQuery<'_>
Creates a query to list all colleges.
§Examples
use osars::Client;
let client = Client::new("https://api.example.com");
let colleges_query = client.colleges();Sourcepub fn college(&self) -> Result<CollegeQuery<'_>>
pub fn college(&self) -> Result<CollegeQuery<'_>>
Creates a query for the default college.
§Errors
Returns Error::Validation if no default college is set.
Sourcepub fn campuses(&self) -> Result<CampusesQuery<'_>>
pub fn campuses(&self) -> Result<CampusesQuery<'_>>
Creates a query to list campuses for the default college.
§Errors
Returns Error::Validation if no default college is set.
Sourcepub fn campus(&self, campus_id: u32) -> CampusQuery<'_>
pub fn campus(&self, campus_id: u32) -> CampusQuery<'_>
Creates a query for a specific campus.
Note: This does not require a default college to be set.
Sourcepub fn groups(&self, campus_id: u32) -> GroupsQuery<'_>
pub fn groups(&self, campus_id: u32) -> GroupsQuery<'_>
Sourcepub fn schedule(&self, group_id: u32) -> ScheduleQuery<'_>
pub fn schedule(&self, group_id: u32) -> ScheduleQuery<'_>
Sourcepub fn today(&self, group_id: u32) -> ScheduleQuery<'_>
pub fn today(&self, group_id: u32) -> ScheduleQuery<'_>
Sourcepub fn tomorrow(&self, group_id: u32) -> ScheduleQuery<'_>
pub fn tomorrow(&self, group_id: u32) -> ScheduleQuery<'_>
Creates a query for tomorrow’s schedule of a group.
§Arguments
group_id- The ID of the student group
Sourcepub fn authenticated(self) -> AuthenticatedClient
pub fn authenticated(self) -> AuthenticatedClient
Create an authenticated client for private endpoints.
Sourcepub async fn get_json<T>(&self, path: &str) -> Result<T>where
T: DeserializeOwned,
pub async fn get_json<T>(&self, path: &str) -> Result<T>where
T: DeserializeOwned,
Perform a GET request and deserialize the JSON response.