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.
- PHP 8.3
- Composer
- Abacus API Token
composer require memurame/abacus-php-rest-api
You can find example code within the directory examples.
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'
]);
To read all objects without filtering:
use AbacusAPIClient\ResourceType;
$addresses = $abacusClient->resource(ResourceType::ADDRESSES)->run();
To read a single objects by Id:
use AbacusAPIClient\ResourceType;
$address = $abacusClient->resource(ResourceType::ADDRESSES)->id('02b95ac0-e9ed-e201-175a-c2d220524153')->run();
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::ADDRESSES)
->filter('SubjectId', 'eq', 8)
->limit(3)
->order('Id', 'desc')
->select('FirstName')
->expand('Subject')
->run();
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
You can specify how many results you want. https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptiontop
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
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
You can attach related entities here. https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptionexpand
To get all available Values of the Address:
$values = $address->getValues();
This returns an array of all data.
Returns a single value based on its key:
$values = $address->getValue('SubjectId');
This returns an string.
Set a new value for one or more keys.
$address->setValue('City', 'Solothurn');
OR
$address->setValues([
'City' => 'Solothurn',
'PostCode' => 3232
]);
Saves the changes made with getValue or getValues.
$address->save();
use AbacusAPIClient\ResourceType;
$address = $abacusClient->resource(ResourceType::ADDRESSES);
$address->setValues({
'SubjectId' => 0,
'Street' => 'Hausenstrasse',
...
...
})
$address->save();
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 | Implemented & tested |
---|---|---|
ACCOUNTDOCUMENTS | Finance | ✔ |
ACCOUNTS | Finance | ✔ |
ADDRESSES | CRM | ✔ |
COMMUNICATIONS | CRM | ✔ |
COSTCENTREDOCUMENTS | Finance | ✔ |
COSTCENTRES | Finance | ✔ |
GENERALLEDGERENTRIES | Finance | ✔ |
GENERALLEDGERENTRYDOCUMENTS | Finance | ✔ |
JOURNALS | Finance | ✔ |
LINKDOCUMENTS | CRM | ✔ |
LINKTYPES | CRM | ✔ |
LINKS | CRM | ✔ |
SUBJECTDOCUMENTS | CRM | ✔ |
SUBJECTGROUPINGENTRIES | CRM | ✔ |
SUBJECTGROUPINGS | CRM | ✔ |
SUBJECTS | CRM | ✔ |