Skip to content

fix(shipping-guide): send numeric product codes in price query#64

Merged
crakter merged 2 commits into
masterfrom
claude/express-nordic-price-codes-T9Qzd
Jun 3, 2026
Merged

fix(shipping-guide): send numeric product codes in price query#64
crakter merged 2 commits into
masterfrom
claude/express-nordic-price-codes-T9Qzd

Conversation

@crakter
Copy link
Copy Markdown
Owner

@crakter crakter commented Jun 3, 2026

Problem

Shipping Guide v2 (/shippingguide/v2/products[/price]) prices products by Bring's numeric service code, not the v2 string name. PriceRequest::toQuery() emitted the enum's string value (EXPRESS_NORDIC_0900, …), so Bring returned an empty product list — surfaced in the app as "no price" for Express Nordic 09:00.

This is the inverse of the assumption baked into the earlier purchase-side fix (which resolved the calculator's 4850 into the enum, only for the SDK to serialize it straight back to the string name).

Change

  • Add Product::shippingGuideCode(): ?string — the numeric code Shipping Guide v2 expects, returned as a string so leading zeros survive ('0335'; (int)'0335' would corrupt to 335).
  • PriceRequest::toQuery() serializes through it, falling back to the string value for products without a confirmed numeric code (no regression for unmapped products).
  • Kept distinct from legacyNumericCode(): the SPA sends 4850 for Express (BringCalculator.vue), so input parsing still needs 4850 while output to Bring needs 0335. One shared map could not be correct for both directions.
  • Added PriceRequestTest covering numeric serialization, the 0335 leading-zero case, the string fallback, and the empty-products case.

Verification

  • New + full suite: 206/206 passing
  • PHPStan clean on the changed files

⚠️ Follow-up (not in this PR)

  • Express Nordic 09:00 (0335) is decommissioned by Bring on 2026-09-01; successor is Courier & Express (3620 + VAS 1171) — a product and additional-service change, intentionally not auto-mapped here.
  • bookingProductId() still maps Express Nordic 09:00 → 4850 (Booking API, a different endpoint, unverified). Worth checking separately if express is booked through this SDK.

https://claude.ai/code/session_01TLPjgivGN5mopPrs4vcfBp


Generated by Claude Code

Shipping Guide v2 (/shippingguide/v2/products[/price]) prices by Bring's
numeric service code, not the v2 string name. PriceRequest::toQuery()
emitted the enum string value (EXPRESS_NORDIC_0900, ...), so Bring
returned an empty product list — surfaced in-app as 'no price'.

Add Product::shippingGuideCode() returning the numeric code as a string
(leading-zero safe, e.g. '0335' for Express Nordic 09:00) and serialise
through it, falling back to the string value for products without a
confirmed code. Kept distinct from legacyNumericCode() (the historical
in-app codes, where Express Nordic is 4850) so input parsing on the
caller side is unaffected.

Note: Express Nordic 09:00 (0335) is decommissioned by Bring 2026-09-01;
successor is Courier & Express (3620 + VAS 1171).
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates PriceRequest::toQuery() to serialize products using Bring's numeric service codes (via a new Product::shippingGuideCode() method) instead of v2 string names, falling back to the string value if no numeric code is confirmed. This ensures correct pricing behavior with Shipping Guide v2. A new test suite PriceRequestTest has been added to verify these changes. There are no review comments, so I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

PHPStan (level 8, tests included) inferred the test helper's variadic
$products as array<int|string, Product>, which doesn't satisfy the
constructor's list<Product>. Wrap in array_values() to guarantee a list.
@crakter crakter merged commit e12aaed into master Jun 3, 2026
18 checks passed
@crakter crakter deleted the claude/express-nordic-price-codes-T9Qzd branch June 3, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants