mylloon.fr/src/misc/github.rs

38 lines
865 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 {
2023-04-11 23:08:45 +02:00
pub repository_url: String,
pub number: u32,
2023-04-11 22:45:44 +02:00
pub title: String,
2023-04-11 23:08:45 +02:00
pub state: String,
pub pull_request: GithubPullRequest,
}
#[derive(Deserialize)]
pub struct GithubPullRequest {
2023-04-11 22:45:44 +02:00
pub html_url: String,
2023-04-11 23:08:45 +02:00
pub merged_at: Option<String>,
2023-04-11 22:45:44 +02:00
}
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
}