feat: added example usage
This commit is contained in:
parent
a8a87b83d9
commit
d2ee79ade1
43
example/midlevel/dmail.go
Normal file
43
example/midlevel/dmail.go
Normal 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("----------")
|
||||||
|
}
|
Reference in New Issue
Block a user