speedfin/speedfin-wrapper

Speedfin 2.0 API wrapper for Finance Admin (clients, documents, etc.)

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

pkg:composer/speedfin/speedfin-wrapper

dev-main 2025-10-15 13:01 UTC

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)

  1. Zainstaluj paczkę lub dołącz repozytorium jako path repository (jeśli monorepo).
  2. 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'
  1. 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