(CustomerPortal.Subscriptions)
- List - List Subscriptions
- Get - Get Subscription
- Update - Update Subscription
- Cancel - Cancel Subscription
List subscriptions of the authenticated customer.
Scopes: customer_portal:read
customer_portal:write
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.Subscriptions.List(ctx, operations.CustomerPortalSubscriptionsListRequest{
OrganizationID: polargo.Pointer(operations.CreateCustomerPortalSubscriptionsListQueryParamOrganizationIDFilterArrayOfStr(
[]string{
"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
},
)),
}, operations.CustomerPortalSubscriptionsListSecurity{
CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
})
if err != nil {
log.Fatal(err)
}
if res.ListResourceCustomerSubscription != 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. |
request |
operations.CustomerPortalSubscriptionsListRequest | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalSubscriptionsListSecurity | ✔️ | The security requirements to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalSubscriptionsListResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get a subscription for the authenticated customer.
Scopes: customer_portal:read
customer_portal:write
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.Subscriptions.Get(ctx, operations.CustomerPortalSubscriptionsGetSecurity{
CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
}, "<value>")
if err != nil {
log.Fatal(err)
}
if res.CustomerSubscription != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
security |
operations.CustomerPortalSubscriptionsGetSecurity | ✔️ | The security requirements to use for the request. |
id |
string | ✔️ | The subscription ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalSubscriptionsGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Update a subscription of the authenticated customer.
Scopes: customer_portal:write
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"os"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.CustomerPortal.Subscriptions.Update(ctx, operations.CustomerPortalSubscriptionsUpdateSecurity{
CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
}, "<value>", components.CreateCustomerSubscriptionUpdateCustomerSubscriptionCancel(
components.CustomerSubscriptionCancel{},
))
if err != nil {
log.Fatal(err)
}
if res.CustomerSubscription != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
security |
operations.CustomerPortalSubscriptionsUpdateSecurity | ✔️ | The security requirements to use for the request. |
id |
string | ✔️ | The subscription ID. |
customerSubscriptionUpdate |
components.CustomerSubscriptionUpdate | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalSubscriptionsUpdateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.AlreadyCanceledSubscription | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Cancel a subscription of the authenticated customer.
Scopes: customer_portal:write
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.Subscriptions.Cancel(ctx, operations.CustomerPortalSubscriptionsCancelSecurity{
CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
}, "<value>")
if err != nil {
log.Fatal(err)
}
if res.CustomerSubscription != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
security |
operations.CustomerPortalSubscriptionsCancelSecurity | ✔️ | The security requirements to use for the request. |
id |
string | ✔️ | The subscription ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalSubscriptionsCancelResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.AlreadyCanceledSubscription | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |