Rewrite SDK in the economic-php-sdk style#5
Open
loevgaard wants to merge 2 commits into
Open
Conversation
Re-architect the SDK to mirror setono/economic-php-sdk while preserving exactly the currently supported functionality (payment gateways, pickup points, sales orders, shipment templates, webhooks + the shipment template resolver). Highlights: - Immutable, constructor-injected Client with a sandbox flag (replaces setters/setDebug); HTTP Basic auth; typed exception hierarchy under ShipmondoException with match-based status mapping. - Base-class endpoints (Endpoint/ResourceEndpoint/CollectionEndpoint) replace the per-endpoint interfaces and capability traits. - Resource responses carrying $raw (stamped by RawStamper, outside Valinor's converter pipeline); Payload requests serialized via the Valinor Normalizer (null-strip + camelCase->snake_case + date->ISO + native enums). - Header-based Collection pagination; pickup points returns a bare list; payment gateways/shipment templates look up by ?id=. Tooling: PHP >=8.1 retained; switch Psalm -> PHPStan level max; cuyz/valinor pinned ^2.2.2 <2.4 (2.4 drops 8.1); PHPUnit ^10.5; drop psr/log. README + CLAUDE.md updated. Verified: PHPUnit 60 tests green, PHPStan max clean, ECS clean, Rector clean, composer validate/normalize clean, Infection MSI 58%/covered 69%.
loevgaard
commented
Jun 17, 2026
| "php": ">=8.1", | ||
| "cuyz/valinor": "^1.10", | ||
| "php-http/discovery": "^1.14", | ||
| "cuyz/valinor": "^2.2.2 <2.4", |
Member
Author
There was a problem hiding this comment.
Suggested change
| "cuyz/valinor": "^2.2.2 <2.4", | |
| "cuyz/valinor": "^2.2.2", |
loevgaard
commented
Jun 17, 2026
|
|
||
| /** | ||
| * Takes a response and returns a Valinor Source representation | ||
| * Recursively convert snake_case array keys to camelCase so they match DTO property names. |
Member
Author
There was a problem hiding this comment.
I think the valinor library can do this. Else the Symfony string component also has this capability I think: https://symfony.com/doc/6.4/components/string.html
loevgaard
commented
Jun 17, 2026
|
|
||
| abstract class ShipmondoTestCase extends TestCase | ||
| { | ||
| protected const BASE = 'https://sandbox.shipmondo.com/api/public/v3'; |
Member
Author
There was a problem hiding this comment.
What is this used for?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-architects the SDK to mirror
setono/economic-php-sdk, preserving exactly the functionality already supported — no new endpoints. Targets the2.xmajor.Scope preserved:
paymentGateways(list +getById),pickupPoints(search),salesOrders(list/getById/create),shipmentTemplates(list +getById),webhooks(list/create/delete/deleteAll), and theShipmentTemplateResolver.Architecture
Client— collaborators constructor-injected,sandbox: trueflag (replacessetDebug()and all setters), HTTP Basic auth, host/port credential guard,match-based exception mapping.get/post/deletereturn decoded arrays;request()is the PSR-7 escape hatch.Endpoint→ResourceEndpoint→CollectionEndpoint) replace every*EndpointInterfaceand capability trait.Resourceresponses with$raw, stamped byRawStamperoutside Valinor's converter pipeline (avoids the per-node reflection leak).Payloadrequests serialized via the Valinor Normalizer (null-strip + camelCase→snake_case +DateTime→ISO; native enums insrc/Enum/).Collectioncarries theX-*header values;paginate()walks pages).pickupPointsreturns a barelist<PickupPoint>;paymentGateways/shipmentTemplateslook up via?id=.ShipmondoException, exposinggetError()for Shipmondo's{"error": "..."}body.Tooling
max(+ strict-rules / phpunit / webmozart-assert).cuyz/valinorpinned^2.2.2 <2.4— 2.4 drops PHP 8.1 (CI 8.1 matrix guards this).^10.5(attribute-based tests;ScriptedHttpClientfake PSR-18, no mocking framework).psr/log— consumers add logging via PSR-18 middleware.Behavior changes / BC breaks (appropriate for the 2.x major)
get()/post()/delete()returnarray(wasResponseInterface).pickupPoints()->search(PickupPointSearch): list<PickupPoint>(wasget(): Collection).Collection::first()returnsnull(wasfalse);CollectiongainstotalCount.SalesOrder.orderIdnow required.Verification
composer phpunit— 60 tests, 132 assertions (3 live tests skipped)composer analyse— PHPStan level max, no errorscomposer check-style,vendor/bin/rector --dry-run,composer validate --strict,composer normalize— cleanvendor/bin/infection— MSI 58% / covered 69% (thresholds 50/60)