speedfin / speedfin-wrapper
Speedfin 2.0 API wrapper for Finance Admin (clients, documents, etc.)
dev-main
2025-10-15 13:01 UTC
Requires
- php: >=8.2
- psr/log: ^3.0
- symfony/cache: ^6.4 || ^7.0
- symfony/http-client: ^6.4 || ^7.0
- symfony/serializer: ^6.4 || ^7.0
This package is not auto-updated.
Last update: 2025-10-18 07:01:49 UTC
README
A lightweight wrapper layer to communicate with Speedfin 2.0 API from external applications (e.g., Finance Admin).
Modules
- ClientService (CRUD dla klientów: getAll, getById, create, update, delete)
Instalacja
composer install
Konfiguracja i użycie (przykład w Finance Admin)
- Zainstaluj paczkę lub dołącz repozytorium jako path repository (jeśli monorepo).
- Skonfiguruj serwis w Symfony:
# services.yaml (fragment)
services:
SpeedfinWrapper\Client\SpeedfinApiClient:
arguments:
$baseUrl: '%env(SPEEDFIN_API_URL)%'
$timeout: 30
SpeedfinWrapper\Service\ClientService:
arguments:
$client: '@SpeedfinWrapper\\Client\\SpeedfinApiClient'
- Użycie w kodzie:
use SpeedfinWrapper\Service\ClientService;
use SpeedfinWrapper\Dto\Client\ClientDto;
$clientService = $container->get(ClientService::class);
// Pobranie listy
$clients = $clientService->getAll();
// Pobranie po ID
$client = $clientService->getById(123);
// Utworzenie klienta
$new = new ClientDto(name: 'Jan', surname: 'Kowalski', email: 'jan@example.com');
$created = $clientService->create($new);
// Aktualizacja klienta
$created->comment = 'Ważny klient';
$updated = $clientService->save($created);
// Usunięcie
$clientService->delete($updated->id);
Uwagi
- Endpointy oparte na Api Platform (prefiks
/api
). - PATCH używa
application/merge-patch+json
. - Autoryzacja Bearer przez przekazanie tokena po logowaniu.
Ustawienie tokena po logowaniu
Przekaż token uzyskany przy logowaniu bezpośrednio do klienta:
use SpeedfinWrapper\Client\SpeedfinApiClient;
$apiClient = $container->get(SpeedfinApiClient::class);
$apiClient->setToken($tokenUzyskanyPrzyLogowaniu);
// Od tego momentu wszystkie wywołania będą używać ustawionego tokena