Skip to content

Latest commit

 

History

History
71 lines (62 loc) · 1.2 KB

USAGE.md

File metadata and controls

71 lines (62 loc) · 1.2 KB
package main

import (
	"context"
	dubgo "github.com/dubinc/dub-go"
	"github.com/dubinc/dub-go/models/operations"
	"log"
)

func main() {
	s := dubgo.New(
		dubgo.WithSecurity("DUB_API_KEY"),
	)

	ctx := context.Background()
	res, err := s.Links.Create(ctx, &operations.CreateLinkRequestBody{
		URL:        "https://google.com",
		ExternalID: dubgo.String("123456"),
		TagIds: dubgo.Pointer(operations.CreateTagIdsArrayOfStr(
			[]string{
				"clux0rgak00011...",
			},
		)),
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}
package main

import (
	"context"
	dubgo "github.com/dubinc/dub-go"
	"github.com/dubinc/dub-go/models/operations"
	"log"
)

func main() {
	s := dubgo.New(
		dubgo.WithSecurity("DUB_API_KEY"),
	)

	ctx := context.Background()
	res, err := s.Links.Upsert(ctx, &operations.UpsertLinkRequestBody{
		URL:        "https://google.com",
		ExternalID: dubgo.String("123456"),
		TagIds: dubgo.Pointer(operations.CreateUpsertLinkTagIdsArrayOfStr(
			[]string{
				"clux0rgak00011...",
			},
		)),
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}