wip
This commit is contained in:
25
src/api.rs
25
src/api.rs
@@ -1,5 +1,6 @@
|
||||
use crate::query;
|
||||
|
||||
pub(crate) mod auth;
|
||||
pub(crate) mod repo;
|
||||
pub(crate) mod user;
|
||||
|
||||
@@ -7,16 +8,36 @@ pub(crate) mod user;
|
||||
pub struct QueryContext {
|
||||
pub(crate) http: reqwest::Client,
|
||||
pub(crate) auth: Option<Auth>,
|
||||
pub(crate) github: GithubCredentials,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct Auth {
|
||||
pub(crate) access_token: String,
|
||||
pub(crate) refresh_token: String,
|
||||
pub(crate) access_token: &'static str,
|
||||
pub(crate) refresh_token: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct GithubCredentials {
|
||||
pub(crate) client_id: &'static str,
|
||||
}
|
||||
|
||||
pub enum Error {
|
||||
Unauthenticated,
|
||||
MalformedResponse(serde_json::Error),
|
||||
HttpError(reqwest::Error),
|
||||
}
|
||||
|
||||
impl query::Context for QueryContext {}
|
||||
|
||||
impl From<reqwest::Error> for Error {
|
||||
fn from(value: reqwest::Error) -> Self {
|
||||
Self::HttpError(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
fn from(value: serde_json::Error) -> Self {
|
||||
Self::MalformedResponse(value)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user