Skip to content

Latest commit

 

History

History
309 lines (232 loc) · 20.5 KB

README.md

File metadata and controls

309 lines (232 loc) · 20.5 KB

PolarLicenseKeys

(CustomerPortal.LicenseKeys)

Overview

Available Operations

List

Scopes: customer_portal:read customer_portal:write

Example Usage

package main

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

func main() {
    ctx := context.Background()

    s := polargo.New()

    res, err := s.CustomerPortal.LicenseKeys.List(ctx, operations.CustomerPortalLicenseKeysListSecurity{
        CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
    }, polargo.Pointer(operations.CreateCustomerPortalLicenseKeysListQueryParamOrganizationIDFilterArrayOfStr(
        []string{
            "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
        },
    )), nil, nil, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.ListResourceLicenseKeyRead != 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.
security operations.CustomerPortalLicenseKeysListSecurity ✔️ The security requirements to use for the request.
organizationID *operations.CustomerPortalLicenseKeysListQueryParamOrganizationIDFilter Filter by organization ID.
benefitID *string Filter by a specific benefit
page *int64 Page number, defaults to 1.
limit *int64 Size of a page, defaults to 10. Maximum is 100.
opts []operations.Option The options for this request.

Response

*operations.CustomerPortalLicenseKeysListResponse, error

Errors

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

Get

Get a license key.

Scopes: customer_portal:read customer_portal:write

Example Usage

package main

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

func main() {
    ctx := context.Background()

    s := polargo.New()

    res, err := s.CustomerPortal.LicenseKeys.Get(ctx, operations.CustomerPortalLicenseKeysGetSecurity{
        CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
    }, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.LicenseKeyWithActivations != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
security operations.CustomerPortalLicenseKeysGetSecurity ✔️ The security requirements to use for the request.
id string ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.CustomerPortalLicenseKeysGetResponse, error

Errors

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

Validate

Validate a license key.

Example Usage

package main

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

func main() {
    ctx := context.Background()

    s := polargo.New()

    res, err := s.CustomerPortal.LicenseKeys.Validate(ctx, components.LicenseKeyValidate{
        Key: "<key>",
        OrganizationID: "<value>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.ValidatedLicenseKey != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.CustomerPortalLicenseKeysValidateResponse, error

Errors

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

Activate

Activate a license key instance.

Example Usage

package main

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

func main() {
    ctx := context.Background()

    s := polargo.New()

    res, err := s.CustomerPortal.LicenseKeys.Activate(ctx, components.LicenseKeyActivate{
        Key: "<key>",
        OrganizationID: "<value>",
        Label: "<value>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.LicenseKeyActivationRead != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.CustomerPortalLicenseKeysActivateResponse, error

Errors

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

Deactivate

Deactivate a license key instance.

Example Usage

package main

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

func main() {
    ctx := context.Background()

    s := polargo.New()

    res, err := s.CustomerPortal.LicenseKeys.Deactivate(ctx, components.LicenseKeyDeactivate{
        Key: "<key>",
        OrganizationID: "<value>",
        ActivationID: "<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.
request components.LicenseKeyDeactivate ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CustomerPortalLicenseKeysDeactivateResponse, error

Errors

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