(Advertisements)
List active advertisement campaigns for a benefit.
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.Advertisements.List(ctx, "<value>", nil, nil, nil)
if err != nil {
log.Fatal(err)
}
if res.AdvertisementCampaignListResource != 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. |
benefitID |
string | ✔️ | N/A |
page |
*int64 | ➖ | Page number, defaults to 1. |
limit |
*int64 | ➖ | Size of a page, defaults to 10. Maximum is 100. |
sorting |
[]components.AdvertisementSortProperty | ➖ | 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.AdvertisementsListResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get an advertisement campaign 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.Advertisements.Get(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.AdvertisementCampaign != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | The advertisement campaign ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.AdvertisementsGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |