2024-07-19 19:40:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
|
2024-08-20 06:07:46 +00:00
|
|
|
"git.anthrove.art/Anthrove/e621-sdk-go/pkg/e621/endpoints"
|
|
|
|
"git.anthrove.art/Anthrove/e621-sdk-go/pkg/e621/model"
|
2024-07-19 19:40:18 +00:00
|
|
|
_ "github.com/joho/godotenv/autoload"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
requestContext := model.RequestContext{
|
|
|
|
Client: http.Client{},
|
|
|
|
Host: "https://e621.net",
|
|
|
|
UserAgent: "Go-e621-SDK (@username)",
|
|
|
|
Username: os.Getenv("API_USER"),
|
|
|
|
APIKey: os.Getenv("API_KEY"),
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Getting a DMail by ID:")
|
|
|
|
dmail, err := endpoints.GetDmail(requestContext, 1)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
} else {
|
|
|
|
log.Println(dmail.Body)
|
|
|
|
}
|
|
|
|
log.Println("----------")
|
|
|
|
|
|
|
|
log.Println("Deleting a DMail by ID:")
|
|
|
|
err = endpoints.DeleteDmail(requestContext, 1)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
log.Println("----------")
|
|
|
|
|
|
|
|
log.Println("Marking a DMail as read by ID:")
|
|
|
|
err = endpoints.MarkAsReadDmail(requestContext, 1)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
log.Println("----------")
|
|
|
|
|
|
|
|
log.Println("Getting all DMails:")
|
|
|
|
query := map[string]string{
|
|
|
|
"limit": "5",
|
|
|
|
}
|
|
|
|
dmails, err := endpoints.GetAllDmails(requestContext, query)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
} else {
|
|
|
|
for _, dmail := range dmails {
|
|
|
|
log.Println(dmail.Body)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Println("----------")
|
|
|
|
|
|
|
|
log.Println("Marking all DMails as read:")
|
|
|
|
err = endpoints.MarkAsReadAllDmails(requestContext)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
log.Println("----------")
|
|
|
|
}
|