use serde::Deserialize; use crate::{api, query}; #[derive(Debug, Deserialize)] pub struct Repository { pub id: u64, pub name: String, pub full_name: String, pub private: bool, pub html_url: String, pub description: Option, pub default_branch: String, pub owner: Owner, } #[derive(Debug, Deserialize)] pub struct Owner { pub login: String, pub id: api::user::Id, pub avatar_url: String, pub html_url: String, } #[derive(Clone)] pub struct List; impl query::QueryFn for List { type Data = Vec; type Error = api::Error; type Context = api::QueryContext; fn key(&self) -> query::Key { "repo/list".into() } async fn run(&self, c: &Self::Context) -> Result { #[cfg(debug_assertions)] if c.should_use_fixtures { return super::mock::list_repos(); } let params = [("sort", "updated"), ("per_page", "100")]; let res = c .github_request(reqwest::Method::GET, "/user/repos")? .query(¶ms) .send() .await?; api::parse_response(res).await } }