30 lines
677 B
Rust
30 lines
677 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 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
|
||
|
}
|