Skip to content

Latest commit

 

History

History
689 lines (543 loc) · 39.1 KB

README.md

File metadata and controls

689 lines (543 loc) · 39.1 KB

Links

(Links)

Overview

Available Operations

Create

Create a new link for the authenticated workspace.

Example Usage

package main

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

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

    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
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.CreateLinkRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*components.LinkSchema, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

List

Retrieve a paginated list of links for the authenticated workspace.

Example Usage

package main

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

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

    res, err := s.Links.List(ctx, operations.GetLinksRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetLinksRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.GetLinksResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

Count

Retrieve the number of links for the authenticated workspace.

Example Usage

package main

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

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

    res, err := s.Links.Count(ctx, operations.GetLinksCountRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetLinksCountRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*float64, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

Get

Retrieve the info for a link.

Example Usage

package main

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

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

    res, err := s.Links.Get(ctx, operations.GetLinkInfoRequest{
        LinkID: dubgo.String("clux0rgak00011..."),
        ExternalID: dubgo.String("123456"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetLinkInfoRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*components.LinkSchema, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

Update

Update a link for the authenticated workspace. If there's no change, returns it as it is.

Example Usage

package main

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

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

    res, err := s.Links.Update(ctx, "<id>", &operations.UpdateLinkRequestBody{
        URL: dubgo.String("https://google.com"),
        ExternalID: dubgo.String("123456"),
        TagIds: dubgo.Pointer(operations.CreateUpdateLinkTagIdsArrayOfStr(
            []string{
                "clux0rgak00011...",
            },
        )),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
linkID string ✔️ The id of the link to update. You may use either linkId (obtained via /links/info endpoint) or externalId prefixed with ext_.
requestBody *operations.UpdateLinkRequestBody N/A
opts []operations.Option The options for this request.

Response

*components.LinkSchema, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

Delete

Delete a link for the authenticated workspace.

Example Usage

package main

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

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

    res, err := s.Links.Delete(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
linkID string ✔️ The id of the link to delete. You may use either linkId (obtained via /links/info endpoint) or externalId prefixed with ext_.
opts []operations.Option The options for this request.

Response

*operations.DeleteLinkResponseBody, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

CreateMany

Bulk create up to 100 links for the authenticated workspace.

Example Usage

package main

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

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

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

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request []operations.RequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

[]operations.ResponseBody, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

UpdateMany

Bulk update up to 100 links with the same data for the authenticated workspace.

Example Usage

package main

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

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

    res, err := s.Links.UpdateMany(ctx, &operations.BulkUpdateLinksRequestBody{
        Data: operations.Data{
            URL: dubgo.String("https://google.com"),
            TagIds: dubgo.Pointer(operations.CreateBulkUpdateLinksTagIdsArrayOfStr(
                []string{
                    "clux0rgak00011...",
                },
            )),
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.BulkUpdateLinksRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

[]components.LinkSchema, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

DeleteMany

Bulk delete up to 100 links for the authenticated workspace.

Example Usage

package main

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

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

    res, err := s.Links.DeleteMany(ctx, operations.BulkDeleteLinksRequest{
        LinkIds: []string{
            "clux0rgak00011...",
            "clux0rgak00022...",
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.BulkDeleteLinksRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.BulkDeleteLinksResponseBody, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

Upsert

Upsert a link for the authenticated workspace by its URL. If a link with the same URL already exists, return it (or update it if there are any changes). Otherwise, a new link will be created.

Example Usage

package main

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

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

    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
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.UpsertLinkRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*components.LinkSchema, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*