(LicenseKeys)
- List - List License Keys
- Get - Get License Key
- Update - Update License Key
- GetActivation - Get Activation
Get license keys connected to the given organization & filters.
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.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.LicenseKeysListQueryParamOrganizationIDFilter | ➖ | Filter by organization ID. |
benefitID |
*operations.QueryParamBenefitIDFilter | ➖ | Filter by benefit ID. |
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.LicenseKeysListResponse, 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.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.LicenseKeysGetResponse, 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 | */* |
Update 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.LicenseKeys.Update(ctx, "<value>", components.LicenseKeyUpdate{})
if err != nil {
log.Fatal(err)
}
if res.LicenseKeyRead != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | N/A |
licenseKeyUpdate |
components.LicenseKeyUpdate | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.LicenseKeysUpdateResponse, 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 activation.
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.LicenseKeys.GetActivation(ctx, "<value>", "<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. |
id |
string | ✔️ | N/A |
activationID |
string | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.LicenseKeysGetActivationResponse, 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 | */* |