- Implemented buildUserAgent() method in AllegroApiClient, AllegroOAuthClient, and AllegroTrackingService to include User-Agent header in all HTTP requests to Allegro API. - Updated .env.example to include APP_VERSION and ALLEGRO_USER_AGENT_URL for configuration. - Created public /info page to provide application details required by Allegro, including app name, version, description, and contact information. - Added minimalist layout for public pages to ensure a professional appearance. - Ensured all changes comply with Allegro's API requirements for User-Agent header.
6.5 KiB
6.5 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, delegation
| phase | plan | type | wave | depends_on | files_modified | autonomous | delegation | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 88-allegro-user-agent | 01 | execute | 1 |
|
true | off |
Purpose
Od 1 lipca 2026 Allegro będzie odrzucać requesty bez poprawnego User-Agent. Bez tej zmiany integracja z Allegro przestanie działać.
Output
Wszystkie requesty do Allegro API (REST, OAuth, tracking) będą zawierać nagłówek:
orderPRO/1.0.0 (+https://orderpro.pl/info)
Source Files
@src/Modules/Settings/AllegroApiClient.php — główny klient REST API (4 metody z CURLOPT_HTTPHEADER: linie 216, 281, 345, 393) @src/Modules/Settings/AllegroOAuthClient.php — klient OAuth token exchange (1 metoda: linia 153) @src/Modules/Shipments/AllegroTrackingService.php — tracking przesyłek (2 metody: linie 136, 186) @.env.example — konfiguracja aplikacji (APP_NAME=orderPRO)
<acceptance_criteria>
AC-1: User-Agent w requestach REST API
Given AllegroApiClient wysyła request do Allegro API (GET, POST, PUT, POST binary)
When request jest wykonywany przez dowolną metodę (requestJson, postJson, putJson, postBinary)
Then nagłówek User-Agent jest obecny w formacie "orderPRO/1.0.0 (+https://orderpro.pl/info)"
AC-2: User-Agent w requestach OAuth
Given AllegroOAuthClient wymienia authorization code lub odświeża token
When request OAuth jest wykonywany przez requestToken()
Then nagłówek User-Agent jest obecny w tym samym formacie
AC-3: User-Agent w requestach tracking
Given AllegroTrackingService odpytuje API o status przesyłki
When request jest wykonywany przez edgeApiRequest() lub apiRequest()
Then nagłówek User-Agent jest obecny w tym samym formacie
AC-4: Konfigurowalność User-Agent
Given administrator chce zmienić URL dokumentacji lub wersję w User-Agent
When zmieni wartości ALLEGRO_USER_AGENT_URL i APP_VERSION w .env
Then wszystkie requesty używają zaktualizowanych wartości
</acceptance_criteria>
Task 1: Dodanie stałej User-Agent i konfiguracji .env.example, config/app.php 1. W `.env.example` dodać zmienne: - `APP_VERSION=1.0.0` - `ALLEGRO_USER_AGENT_URL=https://orderpro.pl/info` 2. W `config/app.php` (lub tam gdzie jest odczyt konfiguracji) upewnić się że te zmienne są dostępne. 3. Analogicznie w `.env` (produkcyjne wartości).Format User-Agent: `{APP_NAME}/{APP_VERSION} (+{ALLEGRO_USER_AGENT_URL})`
Przykład: `orderPRO/1.0.0 (+https://orderpro.pl/info)`
Grep .env.example powinien zawierać APP_VERSION i ALLEGRO_USER_AGENT_URL
AC-4 satisfied: zmienne konfiguracyjne zdefiniowane
Task 2: Dodanie User-Agent do AllegroApiClient
src/Modules/Settings/AllegroApiClient.php
1. Dodać prywatną metodę `buildUserAgent(): string` która buduje string User-Agent z ENV:
- `getenv('APP_NAME') ?: 'orderPRO'`
- `getenv('APP_VERSION') ?: '1.0.0'`
- `getenv('ALLEGRO_USER_AGENT_URL') ?: 'https://orderpro.pl/info'`
- Zwraca: `"{name}/{version} (+{url})"`
2. Dodać `'User-Agent: ' . $this->buildUserAgent()` do CURLOPT_HTTPHEADER w 4 metodach:
- `postJson()` (linia ~216)
- `putJson()` (linia ~281)
- `postBinary()` (linia ~345)
- `requestJson()` (linia ~393)
Avoid: nie duplikować logiki budowania stringa — jedna metoda, 4 wywołania.
Grep AllegroApiClient.php za "User-Agent" — powinno być 4 wystąpienia w HTTPHEADER + 1 metoda buildUserAgent
AC-1 satisfied: wszystkie 4 metody REST API wysyłają User-Agent
Task 3: Dodanie User-Agent do AllegroOAuthClient i AllegroTrackingService
src/Modules/Settings/AllegroOAuthClient.php, src/Modules/Shipments/AllegroTrackingService.php
1. W `AllegroOAuthClient.php`:
- Dodać analogiczną metodę `buildUserAgent(): string` (lub wydzielić do traita/helpera jeśli nie nadmiarowe)
- Dodać `'User-Agent: ' . $this->buildUserAgent()` do CURLOPT_HTTPHEADER w `requestToken()` (linia ~153)
2. W `AllegroTrackingService.php`:
- Dodać analogiczną metodę `buildUserAgent(): string`
- Dodać `'User-Agent: ' . $this->buildUserAgent()` do CURLOPT_HTTPHEADER w:
- `edgeApiRequest()` (linia ~136)
- `apiRequest()` (linia ~186)
Uwaga: 3 klasy z tą samą 3-linijkową metodą to akceptowalne — nie tworzyć traita dla tak prostej logiki.
Grep za "User-Agent" w obu plikach — po 1-2 wystąpienia w HTTPHEADER + metoda buildUserAgent
AC-2 i AC-3 satisfied: OAuth i tracking wysyłają User-Agent
DO NOT CHANGE
- Logika biznesowa requestów (payloady, URL-e, obsługa odpowiedzi)
- Inne nagłówki HTTP (Accept, Content-Type, Authorization)
- Klienty API innych providerów (InPost, Apaczka, shopPRO)
SCOPE LIMITS
- Nie refaktoryzować klientów HTTP do wspólnej klasy bazowej (to osobna faza 68)
- Nie zmieniać struktury klas — tylko dodanie metody i nagłówka
- URL dokumentacji (orderpro.pl/info) — strona nie musi istnieć na tym etapie, ale URL musi być poprawny
<success_criteria>
- Wszystkie 7 miejsc wysyłki requestów do Allegro zawiera nagłówek User-Agent
- Format zgodny z wymaganiami:
orderPRO/1.0.0 (+https://orderpro.pl/info) - Konfiguracja URL i wersji przez zmienne środowiskowe
- Brak zmian w logice biznesowej </success_criteria>