args-cli 0.1.1

Command-line interface for args
Documentation
use anyhow::Result;

use args_api::endpoint::user::{
    get_current_user::{GetCurrentUserRequest, GetCurrentUserResponse},
    get_user::{GetUserRequest, GetUserResponse},
    has_user::HasUserApiRequest,
    list_user_memberships::{ListUserMembershipsRequest, ListUserMembershipsResponse},
    list_user_repositories::{ListUserRepositoriesRequest, ListUserRepositoriesResponse},
    list_user_reviews::{ListUserReviewsRequest, ListUserReviewsResponse},
    update_current_user::{UpdateCurrentUserRequest, UpdateCurrentUserResponse},
};

use crate::client::ArgsClient;

#[allow(dead_code)]
impl ArgsClient {
    pub async fn get_current_user(
        &self,
        request: GetCurrentUserRequest,
    ) -> Result<GetCurrentUserResponse> {
        self.get("user".to_string(), request).await
    }

    pub async fn get_user(
        &self,
        user_name: &str,
        request: GetUserRequest,
    ) -> Result<GetUserResponse> {
        self.get(format!("user/{}", user_name), request).await
    }

    pub async fn has_user(&self, user_name: &str, request: HasUserApiRequest) -> Result<()> {
        self.head(format!("user/{}", user_name), request).await
    }

    pub async fn list_user_repositories(
        &self,
        user_name: &str,
        request: ListUserRepositoriesRequest,
    ) -> Result<ListUserRepositoriesResponse> {
        self.get(format!("user/{}/repositories", user_name), request)
            .await
    }

    pub async fn list_user_memberships(
        &self,
        user_name: &str,
        request: ListUserMembershipsRequest,
    ) -> Result<ListUserMembershipsResponse> {
        self.get(format!("user/{}/memberships", user_name), request)
            .await
    }

    pub async fn list_user_reviews(
        &self,
        user_name: &str,
        request: ListUserReviewsRequest,
    ) -> Result<ListUserReviewsResponse> {
        self.get(format!("user/{}/reviews", user_name), request)
            .await
    }

    pub async fn update_current_user(
        &self,
        request: UpdateCurrentUserRequest,
    ) -> Result<UpdateCurrentUserResponse> {
        self.patch("user".to_string(), request).await
    }
}