---
phase: 07-pre-expansion-fixes
plan: 05
subsystem: shipments
tags: [inpost, shipx-api, shipment-provider, ftp-deploy]

requires:
  - phase: 01-allegro-token-manager
    provides: ShipmentProviderInterface pattern from AllegroShipmentService

provides:
  - InpostShipmentService implementing ShipmentProviderInterface (native ShipX API)
  - Workaround remap inpost→allegro_wza removed from ShipmentController
  - vendor/ excluded from ftp-kr auto-upload (prevents dev deps on server)
  - 2 broken use-statement fixes in ShipmentController and AllegroShipmentService

affects: [future-carriers, inpost-configuration, ci-cd]

tech-stack:
  added: []
  patterns: [ShipX API integration via cURL, ShipmentProviderInterface for new carriers]

key-files:
  created:
    - src/Modules/Shipments/InpostShipmentService.php
  modified:
    - src/Modules/Shipments/ShipmentController.php
    - src/Modules/Shipments/AllegroShipmentService.php
    - routes/web.php
    - .vscode/ftp-kr.json

key-decisions:
  - "ShipX API (natywne InPost) zamiast Allegro WZA — pełna niezależność od Allegro"
  - "vendor/ w ftp-kr ignore — zapobiega auto-upload dev deps na serwer"

patterns-established:
  - "Nowy carrier = nowy XxxShipmentService implements ShipmentProviderInterface + rejestracja w web.php"
  - "vendor/ deploy: ręcznie przez skrypt FTP po composer install --no-dev"

duration: ~20min
completed: 2026-03-15T13:00:00Z
---

# Phase 7 Plan 05: InPost ShipmentProviderInterface Summary

**InpostShipmentService z natywnym ShipX API zastąpił workaround remap inpost→allegro_wza. InPost działa niezależnie od Allegro.**

## Performance

| Metric | Value |
|--------|-------|
| Duration | ~20min |
| Completed | 2026-03-15 |
| Tasks | 3 completed (2 auto + 1 checkpoint) |
| Files created | 1 |
| Files modified | 4 |

## Acceptance Criteria Results

| Criterion | Status | Notes |
|-----------|--------|-------|
| AC-1: InpostShipmentService implementuje ShipmentProviderInterface | Pass | php -l clean, implements ShipmentProviderInterface, 5 metod interfejsu |
| AC-2: InPost shipments przez InPost API, nie Allegro WZA | Pass | Workaround usunięty, InpostShipmentService zarejestrowany pod kluczem 'inpost' |
| AC-3: Brak regresji Allegro WZA | Pass | Human-verify approved — formularz ładuje się bez błędów, Allegro WZA nadal dostępne |

## Accomplishments

- InpostShipmentService z pełną implementacją ShipX API: createShipment, checkCreationStatus, downloadLabel, getDeliveryServices
- Workaround `if ($providerCode === 'inpost') { $providerCode = 'allegro_wza'; }` usunięty z ShipmentController
- InpostShipmentService zarejestrowany w ShipmentProviderRegistry (routes/web.php)
- vendor/ dodany do ftp-kr ignore — rozwiązanie problemu auto-upload dev dependencies na serwer

## Files Created/Modified

| File | Change | Purpose |
|------|--------|---------|
| `src/Modules/Shipments/InpostShipmentService.php` | Created | Natywna implementacja ShipX API — create, status, label |
| `src/Modules/Shipments/ShipmentController.php` | Modified | Usunięty remap inpost→allegro_wza; fix use ShipmentException |
| `src/Modules/Shipments/AllegroShipmentService.php` | Modified | Fix broken use-statements (IntegrationConfigException, ShipmentException) |
| `routes/web.php` | Modified | Dodano use InpostShipmentService, wiring w ShipmentProviderRegistry |
| `.vscode/ftp-kr.json` | Modified | Dodano vendor/, tests/, phpunit.xml, composer.* do ignore |

## Decisions Made

| Decision | Rationale | Impact |
|----------|-----------|--------|
| ShipX API (natywne InPost) | InpostIntegrationRepository ma pola ShipX (organization_id, locker_size, dispatch_method) — jest pod ShipX, nie Allegro WZA | InPost działa bez Allegro; InPost-only użytkownicy odblokwani |
| vendor/ w ftp-kr ignore | Auto-upload wrzucał dev deps (phpunit, deep-copy) na serwer powodując Fatal Error | Deploy vendor/ ręcznie; dev deps nigdy nie trafią na serwer |

## Deviations from Plan

### Summary

| Type | Count | Impact |
|------|-------|--------|
| Auto-fixed | 2 | Broken use-statements w ShipmentController i AllegroShipmentService |
| Scope additions | 1 | ftp-kr.json ignore (konieczne — auto-upload powodował crash na serwerze) |
| Deferred | 0 | — |

**Total impact:** Niezbędne poprawki. Bez fix use-statements ShipmentException nigdy nie byłby łapany prawidłowo.

### Auto-fixed Issues

**1. Broken use-statement: ShipmentController**
- **Found during:** Task 2
- **Issue:** `use AppCorexceptionsShipmentException` — brak backslashy
- **Fix:** `use App\Core\Exceptions\ShipmentException`
- **Files:** src/Modules/Shipments/ShipmentController.php

**2. Broken use-statements: AllegroShipmentService**
- **Found during:** Task 2
- **Issue:** `use AppCoreExceptionsIntegrationConfigException` i `use AppCoreExceptionsShipmentException`
- **Fix:** Poprawione backslashe w obu use-statements
- **Files:** src/Modules/Shipments/AllegroShipmentService.php

## Skill Audit

| Oczekiwany | Wywołany | Uwagi |
|------------|---------|-------|
| sonar-scanner | ○ | Zainstalowany (v4.3.5) ale nie uruchomiony w tym planie |

## Issues Encountered

| Issue | Resolution |
|-------|------------|
| Auto-upload vendor/ z dev deps → Fatal Error na serwerze | Dodano vendor/ do ftp-kr ignore; deploy vendor/ ręcznie przez FTP skrypt |
| Wiring nie w Application.php (jak zakładał plan) ale w routes/web.php | Znalezione przez grep; dodano wiring w tym samym pliku co inne providery |

## Next Phase Readiness

**Ready:**
- Wzorzec ShipmentProviderInterface sprawdzony na 3 providerach (Allegro WZA, Apaczka, InPost)
- Dodanie nowego carrieru: 1 klasa + 1 linia w web.php
- sonar-scanner zainstalowany (v4.3.5), gotowy do uruchomienia

**Concerns:**
- InPost ShipX wymaga testów z prawdziwym tokenem sandbox — nie testowano API calls
- 5+ broken use-statements naprawionych w fazach 07-04 i 07-05 — mogą być więcej w innych plikach

**Blockers:**
- Brak

---
*Phase: 07-pre-expansion-fixes, Plan: 05*
*Completed: 2026-03-15*
