Skip to content

Latest commit

 

History

History
295 lines (219 loc) · 13.7 KB

README.md

File metadata and controls

295 lines (219 loc) · 13.7 KB

CheckoutLinks

(CheckoutLinks)

Overview

Available Operations

  • List - List Checkout Links
  • Create - Create Checkout Link
  • Get - Get Checkout Link
  • Update - Update Checkout Link
  • Delete - Delete Checkout Link

List

List checkout links.

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.CheckoutLinks.List(ctx, operations.CheckoutLinksListRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.ListResourceCheckoutLink != 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.CheckoutLinksListRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CheckoutLinksListResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Create

Create a checkout link.

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.CheckoutLinks.Create(ctx, components.CreateCheckoutLinkCreateCheckoutLinkPriceCreate(
        components.CheckoutLinkPriceCreate{
            ProductPriceID: "<value>",
        },
    ))
    if err != nil {
        log.Fatal(err)
    }
    if res.CheckoutLink != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.CheckoutLinksCreateResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Get

Get a checkout link by ID.

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.CheckoutLinks.Get(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.CheckoutLink != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ The checkout link ID.
opts []operations.Option The options for this request.

Response

*operations.CheckoutLinksGetResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Update

Update a checkout link.

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.CheckoutLinks.Update(ctx, "<value>", components.CheckoutLinkUpdate{})
    if err != nil {
        log.Fatal(err)
    }
    if res.CheckoutLink != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ The checkout link ID.
checkoutLinkUpdate components.CheckoutLinkUpdate ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.CheckoutLinksUpdateResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Delete

Delete a checkout link.

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.CheckoutLinks.Delete(ctx, "<value>")
    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.
id string ✔️ The checkout link ID.
opts []operations.Option The options for this request.

Response

*operations.CheckoutLinksDeleteResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*