58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
|
"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{
|
|
Host: "https://e621.net",
|
|
UserAgent: "Go-e621-SDK (@username)",
|
|
Username: "", // Replace with your username
|
|
APIKey: "", // Replace with your API key
|
|
}
|
|
|
|
// Log: Getting a single pool.
|
|
log.Println("Getting single pool: ")
|
|
|
|
// Initialize an http.Client.
|
|
client := http.Client{}
|
|
|
|
// Specify the pool ID for retrieval.
|
|
poolID := "36957" // Replace with the desired pool's ID.
|
|
|
|
// Call the GetPool function to retrieve the specified pool.
|
|
pool, err := endpoints.GetPool(client, requestContext, poolID)
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
} else {
|
|
// Log the name of the retrieved pool.
|
|
log.Println(pool.Name)
|
|
}
|
|
log.Println("----------")
|
|
|
|
// Log: Getting a list of pools.
|
|
log.Println("Getting a list of pools: ")
|
|
|
|
// Define query parameters for retrieving a list of pools.
|
|
query := map[string]string{
|
|
"limit": "5",
|
|
}
|
|
|
|
// Call the GetPools function to retrieve a list of pools based on the query parameters.
|
|
pools, err := endpoints.GetPools(client, requestContext, query)
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
} else {
|
|
// Log the number of pools retrieved.
|
|
log.Println(len(pools))
|
|
}
|
|
log.Println("----------")
|
|
}
|