This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
e621-sdk-go/pkg/e621/endpoints/user.go
SoXX 9669eb8ddf refactor: removed code duplication
Signed-off-by: SoXX <soxx@fenpa.ws>
2023-11-15 14:02:15 +01:00

35 lines
1.3 KiB
Go

package endpoints
import (
"fmt"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
)
// GetUser retrieves user information from e621.net based on the provided username.
//
// Parameters:
// - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - username: The username of the user to retrieve.
//
// Returns:
// - model.User: The retrieved user.
// - error: An error, if any, encountered during the API request or response handling.
func GetUser(requestContext model.RequestContext, username string) (model.User, error) {
endpoint := fmt.Sprintf("users/%s.json", username)
return getRequest[model.User](requestContext, endpoint, nil)
}
// GetUsers retrieves a list of users from e621.net based on query parameters.
//
// Parameters:
// - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - query: A map containing additional query parameters for the API request.
//
// Returns:
// - []model.User: A slice of users.
// - error: An error, if any, encountered during the API request or response handling.
func GetUsers(requestContext model.RequestContext, query map[string]string) ([]model.User, error) {
endpoint := "users.json"
return getRequest[[]model.User](requestContext, endpoint, query)
}