From d2ee79ade1c219b1e0bff30cd1861ec6cc805c58 Mon Sep 17 00:00:00 2001 From: David Janowski Date: Thu, 11 Jul 2024 12:57:55 +0200 Subject: [PATCH] feat: added example usage --- example/midlevel/dmail.go | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 example/midlevel/dmail.go diff --git a/example/midlevel/dmail.go b/example/midlevel/dmail.go new file mode 100644 index 0000000..35f3d36 --- /dev/null +++ b/example/midlevel/dmail.go @@ -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("----------") +}