Added DMail support #5

Merged
fenpaws merged 11 commits from develop/dm into main 2024-07-11 11:58:03 +00:00
Showing only changes of commit d2ee79ade1 - Show all commits

43
example/midlevel/dmail.go Normal file
View File

@ -0,0 +1,43 @@
package main
import (
"log"
"net/http"
"os"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "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 DMails API user: ")
getDMails := builder.NewGetDMailsBuilder(requestContext)
dMails, err := getDMails.SetLimit(5).Execute()
if err != nil {
log.Println(err)
} else {
log.Println(dMails[0].Title)
}
log.Println("----------")
log.Println("Getting DMails for user: ")
dMails, err = getDMails.SetLimit(5).ByToName("specificUser").Execute()
if err != nil {
log.Println(err)
} else {
log.Println(dMails[0].Title)
}
log.Println("----------")
}