(Organizations)
- List - List Organizations
- Create - Create Organization
- Get - Get Organization
- Update - Update Organization
List organizations.
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.Organizations.List(ctx, nil, nil, nil, nil)
if err != nil {
log.Fatal(err)
}
if res.ListResourceOrganization != 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. |
slug |
*string | ➖ | Filter by slug. |
page |
*int64 | ➖ | Page number, defaults to 1. |
limit |
*int64 | ➖ | Size of a page, defaults to 10. Maximum is 100. |
sorting |
[]components.OrganizationSortProperty | ➖ | Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.OrganizationsListResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Create an organization.
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.Organizations.Create(ctx, components.OrganizationCreate{
Name: "<value>",
Slug: "<value>",
})
if err != nil {
log.Fatal(err)
}
if res.Organization != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.OrganizationCreate | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.OrganizationsCreateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get an organization by ID.
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.Organizations.Get(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.Organization != 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.OrganizationsGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Update an organization.
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.Organizations.Update(ctx, "<value>", components.OrganizationUpdate{})
if err != nil {
log.Fatal(err)
}
if res.Organization != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | N/A |
organizationUpdate |
components.OrganizationUpdate | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.OrganizationsUpdateResponse, 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 | */* |