Search by

memurame / abacus-php-rest-api

Memurame

Abacus REST API Client

Package info

github.com/Memurame/abacus-php-rest-api

pkg:composer/memurame/abacus-php-rest-api

Statistics

Installs: 18

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

0.6.0 2025-01-21 15:09 UTC

This package is auto-updated.

Last update: 2026-11-01 08:20:30 UTC


README

This repository addresses the Abacus REST API and thus simplifies the handling of requests. This was developed by me for my own purposes. You are also welcome to use it yourself and help develop it further.

This repository is still in its infancy. It will therefore not yet have many functions.

Requirements

  • PHP 8.3
  • Composer
  • Abacus API Token

Install

composer require memurame/abacus-php-rest-api

How to use the API client

Example code

You can find example code within the directory examples.

The Client object

Your starting point is the AbacusClient object:

use AbacusAPIClient\AbacusClient;

$abacusClient = new AbacusClient([
    'base_url'      => 'https://abacus.domain.ch',
    'client_id'     => '',
    'client_secret' => '',
    'mandant'       => '7777'
]);

Fetching all Resource object

To read all objects without filtering:

use AbacusAPIClient\ResourceType;
$addresses = $abacusClient->resource(ResourceType::ADDRESSES)->run();

Fetching a single Resource object

To read a single objects by Id:

use AbacusAPIClient\ResourceType;
$address = $abacusClient->resource(ResourceType::ADDRESSES)->id('02b95ac0-e9ed-e201-175a-c2d220524153')->run();

Query builder

You have the option to include various queries with the request. You can attach any of these functions to a request. As an example, I have listed all possible queries for you

use AbacusAPIClient\ResourceType;
$addresses = $abacusClient->resource(ResourceType::SUBJECTS)
    ->filter('SubjectId', 'eq', 8)
    ->limit(3)
    ->order('Id', 'desc')
    ->select('FirstName')
    ->expand('Addresses', 'Communications')
    ->all()
    ->run();

filter

You can search for a key and its value. You can see how the string is structured in the link below https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptionfilter

limit

You can specify how many results you want. Does not work together with all() https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptiontop

order

Define which key to sort by and in which direction. https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptionorderby

select

Define which values you want back. The ID is always included. https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptionselect

expand

You can attach related entities here. https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptionexpand

all

Abacus does not output all data records, it works with [@odata.nextLink]. As long as @odata.nextLink exists, it has data records that can still be retrieved. A request is made with the all() function until all data records have been retrieved.

Get all Values of the object

To get all available Values of the Address:

$values = $address->getValues();

This returns an array of all data.

Get a single value of the object

Returns a single value based on its key:

$values = $address->getValue('SubjectId');

This returns an string.

Change values

Set a new value for one or more keys.

$address->setValue('City', 'Solothurn');
OR
$address->setValues([
    'City' => 'Solothurn', 
    'PostCode' => 3232
]);

Save changes

Saves the changes made with getValue or getValues.

$address->save();

create new object

use AbacusAPIClient\ResourceType;
$address = $abacusClient->resource(ResourceType::ADDRESSES);
$address->setValues({
    'SubjectId' => 0,
    'Street'    => 'Hausenstrasse',
    ...
    ...
})

$address->save();

Available resource types and their access methods

To be able to use the 'short form' for the resource type, add a

use AbacusAPIClient\ResourceType;

to your code. You then can reference the resource type like

$abacusClient->resource( ResourceType::ADDRESSES );
Resource type Category Expand Implemented & tested
ACCOUNTDOCUMENTS Finance Account, Storage ✔
ACCOUNTS Finance Currency, Enterprise, ReferenceAccount, Documents ✔
ADDRESSES CRM Subject ✔
COMMUNICATIONS CRM Link, Subject ✔
COSTCENTREDOCUMENTS Finance CostCentre, Storage ✔
COSTCENTRES Finance Enterprise, Documents ✔
GENERALLEDGERENTRIES Finance CrossDivisionHeader, FollowUpHeader,CollectiveHeader, Division, Journal, AccrualHeader, CrossDivisionPositions, FollowUpPositions, CollectivePositions, AccrualPositions, Documents ✔
GENERALLEDGERENTRYDOCUMENTS Finance GeneralLedgerEntry, Storage ✔
JOURNALS Finance Enterprise, GeneralLedgerEntries ✔
LINKDOCUMENTS CRM Link, Storage ✔
LINKTYPES CRM Links ✔
LINKS CRM TargetSubject, LinkType, SourceSubject, Communications, Documents, SubjectGroupingEntries ✔
SUBJECTDOCUMENTS CRM Subject, Storage ✔
SUBJECTGROUPINGENTRIES CRM ContactPersonReference, SubjectReference, ContainingSubjectGrouping ✔
SUBJECTGROUPINGS CRM Entries ✔
SUBJECTS CRM Projects, BeneficiaryAccounts, Divisions, Enterprises, Customers, CustomerInvoicesForReminder, CustomerInvoicesForSubject, Employee, Addresses, Communications, TargetLinks, SourceLinks, Documents, SubjectGroupingEntries ✔