(Metrics)
Get metrics about your orders and subscriptions.
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/types"
"github.com/polarsource/polar-go/models/components"
"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.Metrics.Get(ctx, operations.MetricsGetRequest{
StartDate: types.MustDateFromString("2024-02-07"),
EndDate: types.MustDateFromString("2023-09-05"),
Interval: components.IntervalWeek,
})
if err != nil {
log.Fatal(err)
}
if res.MetricsResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.MetricsGetRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.MetricsGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get the interval limits for the metrics endpoint.
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.Metrics.Limits(ctx)
if err != nil {
log.Fatal(err)
}
if res.MetricsLimits != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.MetricsLimitsResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.APIError | 4XX, 5XX | */* |