(CustomerPortal.LicenseKeys)
- List - List License Keys
- Get - Get License Key
- Validate - Validate License Key
- Activate - Activate License Key
- Deactivate - Deactivate License Key
List License Keys
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.CustomerPortal.LicenseKeys.List(ctx, nil, 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
}
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context 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. |
*operations.CustomerPortalLicenseKeysListResponse, error
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 a license key.
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.CustomerPortal.LicenseKeys.Get(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.LicenseKeyWithActivations != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalLicenseKeysGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Validate a license key.
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.CustomerPortal.LicenseKeys.Validate(ctx, components.LicenseKeyValidate{
Key: "<key>",
OrganizationID: "<value>",
})
if err != nil {
log.Fatal(err)
}
if res.ValidatedLicenseKey != nil {
// handle response
}
}
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. |
*operations.CustomerPortalLicenseKeysValidateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Activate a license key instance.
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.CustomerPortal.LicenseKeys.Activate(ctx, components.LicenseKeyActivate{
Key: "<key>",
OrganizationID: "<value>",
Label: "<value>",
})
if err != nil {
log.Fatal(err)
}
if res.LicenseKeyActivationRead != nil {
// handle response
}
}
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. |
*operations.CustomerPortalLicenseKeysActivateResponse, error
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 a license key instance.
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.CustomerPortal.LicenseKeys.Deactivate(ctx, components.LicenseKeyDeactivate{
Key: "<key>",
OrganizationID: "<value>",
ActivationID: "<value>",
})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
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. |
*operations.CustomerPortalLicenseKeysDeactivateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |