API¶
Resources¶
The package onlime/bexio-api-client provides various resource classes to
interact with the bexio api (see namespace Bexio\Resource) where this package
extends some of them and adds additional ones (see namespace
Buepro\Bexio\Api\Resource). Resource objects are instantiated with a client
object that can be obtained by the ApiService object:
use Buepro\Bexio\Service\ApiService;
// Get the ApiService with the GeneralUtility or by dependency injection
$apiService = GeneralUtility::makeInstance(ApiService::class);
// Initialize the service for a site and get the client
$client = $apiService->initialize($site)->getClient();
// Or get the client from an already initialized service
$clientInOtherScope = (GeneralUtility::makeInstance(ApiService::class))->getClient();
// @link https://github.com/onlime/bexio-api-client/tree/main/src/Bexio/Resource
use Bexio\Resource\Contact
$bexioContact = new Contact($client);
$contacts = $bexioContact->getContacts();
Tasks¶
User¶
// use Buepro\Bexio\Task\User\UpdateUsers;
$result = GeneralUtility::makeInstance(UpdateUsers::class)
->initialize($site)
->process();
// use Buepro\Bexio\Task\User\UpdateUsers;
$options = [
UpdateUsers::OPTION_CREATE => true,
];
$result = GeneralUtility::makeInstance(UpdateUsers::class)
->initialize($site, $options)
->process();
Invoice¶
// use Buepro\Bexio\Task\Invoice\CreateInvoice;
$invoice = [
'title' => 'Test invoice',
'positions' => [
'text' => 'Some service',
'amount' => 3.2,
'unitPrice' => 90,
],
];
$result = GeneralUtility::makeInstance(CreateInvoice::class)
->initialize($site, $invoice)
->process();
// use Buepro\Bexio\Task\Invoice\UpdateInvoices;
$result = GeneralUtility::makeInstance(UpdateInvoices::class)
->initialize($site)
->process();
// use Buepro\Bexio\Task\Invoice\ProcessPayments;
$result = GeneralUtility::makeInstance(ProcessPaymentsTask::class)
->initialize($site)
->process();
Events¶
InvoicePaymentEvent¶
\Buepro\Bexio\Event\InvoicePaymentEvent
Event to listen to after an invoice payment has been detected.
- getSite()
Returns the
TYPO3\CMS\Core\Site\Entity\Sitethe invoice belongs to.- getInvoice()
Returns the
\Buepro\Bexio\Domain\Model\Invoicethat has been paid.- requestProcessing(string $reason)
Use this method to request this event to be emitted again.
- getReprocessingRequested()
Returns
booleanindicating that one event. handler requested this event to be emitted again.- getReprocessingRequestReasons()
Returns a string array. Each event handler can add its reason.
Event listeners¶
EmailInvoicePayment¶
\Buepro\Bexio\EventListener\EmailInvoicePayment
To use this event listener add the following to Configuration/Services.yaml:
services:
Buepro\Bexio\EventListener\EmailInvoicePayment:
tags:
- name: event.listener
identifier: 'bexio-email-invoice-payment-event-listener'
event: Buepro\Bexio\Event\InvoicePaymentEvent