use crate::option::UpdateIssueOptions;
use crate::{
Result,
option::{
CommitListOptions, CreateIssueOptions, IssueListOptions, OrgRepoListOptions,
ReposListOptions,
},
types::{
collaborator::{CollaboratorPermission, CollaboratorResult},
commit::CommitInfo,
issue::IssueInfo,
org::OrgInfo,
repo::RepoInfo,
user::{ContributionResult, UserInfo},
},
};
use async_trait::async_trait;
#[async_trait]
pub trait Client: Send + Sync {
fn set_token(&mut self, token: &str) -> Result<()>;
fn set_proxy(&mut self, proxy: &str) -> Result<()>;
async fn get_user_info(&self) -> Result<UserInfo>;
async fn get_user_info_with_name(&self, user_name: &str) -> Result<UserInfo>;
async fn get_user_avatar_url(&self, user_name: &str) -> Result<String>;
async fn get_user_contribution(&self, user_name: &str) -> Result<ContributionResult>;
async fn get_org_info(&self, org_name: &str) -> Result<OrgInfo>;
async fn get_org_repos(
&self,
org_name: &str,
options: Option<OrgRepoListOptions>,
) -> Result<Vec<RepoInfo>>;
async fn get_org_avatar_url(&self, org_name: &str) -> Result<String>;
async fn get_repo_info(&self, repo_path: (&str, &str)) -> Result<RepoInfo>;
async fn get_user_repos(&self, option: Option<ReposListOptions>) -> Result<Vec<RepoInfo>>;
async fn get_user_repos_with_name(
&self,
user_name: &str,
option: Option<ReposListOptions>,
) -> Result<Vec<RepoInfo>>;
async fn get_commit_info(
&self,
repo_path: (&str, &str),
sha: Option<&str>,
) -> Result<CommitInfo>;
async fn get_commit_infos(
&self,
repo_path: (&str, &str),
option: Option<CommitListOptions>,
) -> Result<Vec<CommitInfo>>;
async fn add_repo_collaborator(
&self,
repo_path: (&str, &str),
user_name: &str,
permission: Option<CollaboratorPermission>,
) -> Result<CollaboratorResult>;
async fn create_issue(
&self,
repo_path: (&str, &str),
title: &str,
body: Option<&str>,
option: Option<CreateIssueOptions>,
) -> Result<IssueInfo>;
async fn get_issue_info(
&self,
repo_path: (&str, &str),
issue_number: &str,
) -> Result<IssueInfo>;
async fn get_issue_list(
&self,
repo_path: (&str, &str),
options: Option<IssueListOptions>,
) -> Result<Vec<IssueInfo>>;
async fn update_issue(
&self,
repo_path: (&str, &str),
issue_number: &str,
options: Option<UpdateIssueOptions>,
) -> Result<IssueInfo>;
}