53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
|
|
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
// Define the request context with essential information.
|
|
requestContext := model.RequestContext{
|
|
Client: http.Client{},
|
|
Host: "https://e621.net",
|
|
UserAgent: "Go-e621-SDK (@username)",
|
|
Username: "", // Replace with your username
|
|
APIKey: "", // Replace with your API key
|
|
}
|
|
|
|
// Log: Getting a single user.
|
|
log.Println("Getting a single user: ")
|
|
|
|
// Specify the username for retrieval.
|
|
username := "selloo" // Replace with the desired username.
|
|
|
|
// Call the GetUser function to retrieve the specified user.
|
|
userBuilder := builder.NewGetUserBuilder(requestContext)
|
|
user, err := userBuilder.SetUsername(username).Execute()
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
} else {
|
|
// Log the ID of the retrieved user.
|
|
log.Println(user.ID)
|
|
}
|
|
log.Println("----------")
|
|
|
|
// Log: Getting a list of users.
|
|
log.Println("Getting a list of users: ")
|
|
|
|
// Call the GetUsers function to retrieve a list of users based on the query parameters.
|
|
usersBuilder := builder.NewGetUsersBuilder(requestContext)
|
|
userList, err := usersBuilder.SetLimit(5).Execute()
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
} else {
|
|
// Log the number of users retrieved.
|
|
log.Println(len(userList))
|
|
}
|
|
log.Println("----------")
|
|
}
|