Repository navigation
Conversation
Implements the account.migros.ch receipt products endpoint
(`GET /ma/api/user/receipt/{transactionId}/product`), which returns the
products of a Cumulus receipt grouped by category as JSON.
This endpoint requires the `X-MA-INITIATOR: migros-online` header in
addition to the CSRF token, otherwise it responds with HTTP 500.
Also fixes a bug in getCumulusReceipt which read the receipt id from
`receiptId` instead of the declared `transactionId` option, causing the
HTML receipt request to hit an `/undefined` URL.
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
Adds support for the store receipt products endpoint:
This returns the products of a Cumulus receipt grouped by category as JSON, complementing the existing
getCumulusReceipts(list) andgetCumulusReceipt(HTML detail) methods.Changes
src/api/cumulus/receipts.ts— newgetCumulusReceiptProducts({ transactionId }, cookies)plus theICumulusReceiptProductsOptionsinterface.src/api/interfaces/receipts.ts— typed response interfaces (ICumulusReceiptProduct,ICumulusReceiptProductsResponse, etc.) matching the observed API payload.src/api/MigrosAPI.ts— instance methodMigrosAPI.account.cumulus.getCumulusReceiptProducts(...).src/index.ts— exportsICumulusReceiptProductsOptions.tests/cumulus-receipt-products.test.ts— integration test following the existing receipt test pattern.README.md— documents the new method with a usage example.Important detail
Unlike the existing receipt endpoints, this
/productendpoint requires theX-MA-INITIATOR: migros-onlineheader in addition to the CSRF token; without it Migros responds with HTTP 500. This was captured from the browser request (HAR) and is now set in the request headers.Bug fix
getCumulusReceiptread the receipt id fromcumulusReceiptOptions.receiptId, but the option is declared (and documented) astransactionId, so the HTML receipt request was hitting an/undefinedURL. Fixed to usetransactionId.Notes
energyEfficiencyandversionare typed asstring | null; both werenullin the captured response, so they are intentionally loose.