Skip to content

Latest commit

 

History

History
374 lines (247 loc) · 13.3 KB

File metadata and controls

374 lines (247 loc) · 13.3 KB

Metrics

Overview

Available Operations

get

Get metrics about your orders and subscriptions.

Currency values are output in cents.

Scopes: metrics:read

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Brick\DateTime\LocalDate;
use Polar;
use Polar\Models\Components;
use Polar\Models\Operations;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Operations\MetricsGetRequest(
    startDate: LocalDate::parse('2025-03-14'),
    endDate: LocalDate::parse('2025-03-18'),
    interval: Components\TimeInterval::Hour,
    organizationId: '1dbfc517-0bbf-4301-9ba8-555ca42b9737',
);

$response = $sdk->metrics->get(
    request: $request
);

if ($response->metricsResponse !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Operations\MetricsGetRequest ✔️ The request object to use for the request.

Response

?Operations\MetricsGetResponse

Errors

Error Type Status Code Content Type
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

limits

Get the interval limits for the metrics endpoint.

Scopes: metrics:read

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->metrics->limits(

);

if ($response->metricsLimits !== null) {
    // handle response
}

Response

?Operations\MetricsLimitsResponse

Errors

Error Type Status Code Content Type
Errors\APIException 4XX, 5XX */*

listDashboards

List user-defined metric dashboards.

Scopes: metrics:read

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->metrics->listDashboards(
    organizationId: '1dbfc517-0bbf-4301-9ba8-555ca42b9737'
);

if ($response->responseMetricsListDashboards !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
organizationId string|array|null Filter by organization ID.

Response

?Operations\MetricsListDashboardsResponse

Errors

Error Type Status Code Content Type
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

createDashboard

Create a user-defined metric dashboard.

Scopes: metrics:write

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Components;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Components\MetricDashboardCreate(
    name: '<value>',
    organizationId: '1dbfc517-0bbf-4301-9ba8-555ca42b9737',
);

$response = $sdk->metrics->createDashboard(
    request: $request
);

if ($response->metricDashboardSchema !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Components\MetricDashboardCreate ✔️ The request object to use for the request.

Response

?Operations\MetricsCreateDashboardResponse

Errors

Error Type Status Code Content Type
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

getDashboard

Get a user-defined metric dashboard by ID.

Scopes: metrics:read

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->metrics->getDashboard(
    id: '<value>'
);

if ($response->metricDashboardSchema !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
id string ✔️ The metric dashboard ID.

Response

?Operations\MetricsGetDashboardResponse

Errors

Error Type Status Code Content Type
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

deleteDashboard

Delete a user-defined metric dashboard.

Scopes: metrics:write

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->metrics->deleteDashboard(
    id: '<value>'
);

if ($response->statusCode === 200) {
    // handle response
}

Parameters

Parameter Type Required Description
id string ✔️ The metric dashboard ID.

Response

?Operations\MetricsDeleteDashboardResponse

Errors

Error Type Status Code Content Type
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

updateDashboard

Update a user-defined metric dashboard.

Scopes: metrics:write

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Components;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$metricDashboardUpdate = new Components\MetricDashboardUpdate();

$response = $sdk->metrics->updateDashboard(
    id: '<value>',
    metricDashboardUpdate: $metricDashboardUpdate

);

if ($response->metricDashboardSchema !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
id string ✔️ The metric dashboard ID.
metricDashboardUpdate Components\MetricDashboardUpdate ✔️ N/A

Response

?Operations\MetricsUpdateDashboardResponse

Errors

Error Type Status Code Content Type
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*