35 lines
1.3 KiB
Go
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)
|
|
}
|