(Events)
List events.
Scopes: events:read
events:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Events.List(ctx, operations.EventsListRequest{
OrganizationID: polargo.Pointer(operations.CreateEventsListQueryParamOrganizationIDFilterArrayOfStr(
[]string{
"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
},
)),
})
if err != nil {
log.Fatal(err)
}
if res.ListResourceEvent != 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.EventsListRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.EventsListResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get an event by ID.
Scopes: events:read
events:write
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.Events.Get(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.Event != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | The event ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.EventsGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Ingest batch of events.
Scopes: events:write
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.Events.Ingest(ctx, components.EventsIngest{
Events: []components.Events{
components.CreateEventsEventCreateCustomer(
components.EventCreateCustomer{
Name: "<value>",
OrganizationID: polargo.String("1dbfc517-0bbf-4301-9ba8-555ca42b9737"),
CustomerID: "<value>",
},
),
components.CreateEventsEventCreateExternalCustomer(
components.EventCreateExternalCustomer{
Name: "<value>",
OrganizationID: polargo.String("1dbfc517-0bbf-4301-9ba8-555ca42b9737"),
ExternalCustomerID: "<id>",
},
),
},
})
if err != nil {
log.Fatal(err)
}
if res.EventsIngestResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.EventsIngest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.EventsIngestResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |