feat: impl dashboard & issue list
This commit is contained in:
21
src/api.rs
21
src/api.rs
@@ -1,11 +1,11 @@
|
||||
use std::fmt::format;
|
||||
|
||||
use reqwest::{Response, dns::Resolving};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::query;
|
||||
|
||||
pub(crate) mod auth;
|
||||
pub(crate) mod issues;
|
||||
#[cfg(debug_assertions)]
|
||||
mod mock;
|
||||
pub(crate) mod repo;
|
||||
pub(crate) mod user;
|
||||
|
||||
@@ -14,6 +14,9 @@ pub struct QueryContext {
|
||||
pub(crate) http: reqwest::Client,
|
||||
pub(crate) auth: Option<AuthTokens>,
|
||||
pub(crate) github: GithubCredentials,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub(crate) should_use_fixtures: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
@@ -30,6 +33,8 @@ pub(crate) struct GithubCredentials {
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum Error {
|
||||
Unauthenticated,
|
||||
#[cfg(debug_assertions)]
|
||||
MissingMockFixture(String),
|
||||
Github(GithubError),
|
||||
MalformedResponse(serde_json::Error),
|
||||
HttpError(reqwest::Error),
|
||||
@@ -63,6 +68,16 @@ impl QueryContext {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub(crate) fn use_github_fixtures() -> bool {
|
||||
mock::is_enabled()
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub(crate) fn use_github_fixtures() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
impl query::Context for QueryContext {}
|
||||
|
||||
impl From<reqwest::Error> for Error {
|
||||
|
||||
Reference in New Issue
Block a user