mylloon.fr/src/misc/github.rs

30 lines
677 B
Rust
Raw Normal View History

2023-04-11 22:45:44 +02:00
use reqwest::{header::ACCEPT, Error};
use serde::Deserialize;
use crate::utils::get_reqwest_client;
#[derive(Deserialize)]
pub struct GithubResponse {
pub total_count: u32,
pub items: Vec<GithubProject>,
}
#[derive(Deserialize)]
pub struct GithubProject {
pub title: String,
pub html_url: String,
pub number: u32,
}
pub async fn fetch_pr() -> Result<GithubResponse, Error> {
let client = get_reqwest_client();
client
.get("https://api.github.com/search/issues?q=is:pr%20author:Mylloon")
.header(ACCEPT, "application/vnd.github.text-match+json")
.send()
.await?
.json::<GithubResponse>()
.await
}