37 lines
865 B
Rust
37 lines
865 B
Rust
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 repository_url: String,
|
|
pub number: u32,
|
|
pub title: String,
|
|
pub state: String,
|
|
pub pull_request: GithubPullRequest,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct GithubPullRequest {
|
|
pub html_url: String,
|
|
pub merged_at: Option<String>,
|
|
}
|
|
|
|
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
|
|
}
|