Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxyw authored Jul 17, 2022
1 parent 5bea956 commit 4ff506a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
19 changes: 19 additions & 0 deletions example/get_resource_detail.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package example

import (
"context"
"fmt"

"github.com/sunxyw/go-spiget/spiget"
)

func GetResourceDetail() {
client := spiget.NewClient(nil)

resource, _, err := client.Resources.Get(context.Background(), 6245) // Get resource with ID 6245, PlaceholderAPI
if err != nil {
panic(err)
}

fmt.Println(resource)
}
5 changes: 3 additions & 2 deletions main.go → example/register_webhook.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package example

import (
"context"
Expand All @@ -7,7 +7,7 @@ import (
"github.com/sunxyw/go-spiget/spiget"
)

func main() {
func RegisterWebhook() {
client := spiget.NewClient(nil)

webhook, _, err := client.Webhook.Register(context.Background(), "https://example.com/webhook", []string{"resource-update"})
Expand All @@ -16,4 +16,5 @@ func main() {
}

fmt.Printf("%+v\n", webhook)
// &{ID:2a34ebef22f24ff4d... Secret:d8740a0663a193d4...}
}

0 comments on commit 4ff506a

Please sign in to comment.