Skip to content

Analytics (categories)

These resources cover the categories used to tag treasury and analytical records, and the groups that organize them.

Categories ($client->categories)

Categories used to tag treasury and analytical records.

Method HTTP Scope Description
list($cursor = null, $limit = null, $filter = null, $sort = null) GET /categories categories:readonly List categories.
create($label, $categoryGroupId, $direction = null, $analyticalCode = null) POST /categories categories:all Create a category. direction only applies to treasury categories ("cash_in" or "cash_out", defaults to "cash_out").
get($categoryId) GET /categories/{categoryId} categories:readonly Retrieve a category by its identifier.
update($categoryId, $label = null, $direction = null, $analyticalCode = null) PUT /categories/{categoryId} categories:all Update a category.

CategoryGroups ($client->categoryGroups)

Groups that organize categories.

Method HTTP Scope Description
list($cursor = null, $limit = null) GET /category_groups categories:readonly List category groups.
get($categoryGroupId) GET /category_groups/{categoryGroupId} categories:readonly Retrieve a category group by its identifier.
listCategories($categoryGroupId, $cursor = null, $limit = null) GET /category_groups/{categoryGroupId}/categories categories:readonly List the categories that belong to a category group.

Example

<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

use Pennylane\Sdk\Pennylane;

$client = new Pennylane();

$group = $client->categoryGroups->get(42);

$category = $client->categories->create(
    label: 'Travel expenses',
    categoryGroupId: $group->id,
    direction: 'cash_out',
);

foreach ($client->categoryGroups->listCategories($group->id) as $groupCategory) {
    echo "{$groupCategory->id}: {$groupCategory->label}\n";
}