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