2024-09-12 00:11:12 -07:00
|
|
|
use cartographer::libcanvas::CanvasClient;
|
|
|
|
use reqwest::{Error, Url};
|
2024-09-11 01:34:47 -07:00
|
|
|
use std::env;
|
|
|
|
|
2024-09-12 00:11:12 -07:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), Error> {
|
2024-09-11 02:09:50 -07:00
|
|
|
let token =
|
|
|
|
env::var("CANVAS_SECRET").expect("Canvas API key is not defined in the environment.");
|
|
|
|
|
2024-09-12 00:11:12 -07:00
|
|
|
// Base URL must have trailing slash or URL `.join()` will not work
|
|
|
|
let client = CanvasClient::create(
|
|
|
|
token,
|
|
|
|
Url::parse("https://ucsb.instructure.com/api/v1/").expect("Could not parse API URL."),
|
|
|
|
)?;
|
|
|
|
println!("{:?}", client.get_courses().await?);
|
2024-09-11 01:34:47 -07:00
|
|
|
Ok(())
|
|
|
|
}
|