42 karma · joined Jan 12, 2021 (5y ago) · 3 submissions
comment 4y ago · link · parent
But it was relatively easy to prevent problems with this. When the user clicked the button to place the order, we sent along the expected order total, the expected item IDs to purchase, the expected tax, etc. In the backend, one of the last validation step before the order was finalized was just to compare the final order details against those expected values. If there were any differences, the order was rejected with an error message to try again. There were then monitors on these types of errors which would go off if there was a higher-than-normal frequency of these sorts of errors, so we could track down any bugs causing price discrepancies.
I'm kind of surprised that UberEats doesn't seem to have a similar validation step.
comment 5y ago · link · parent
That said, REST API endpoint are effectively just functions--you pass in params, you get a response. They only have a single operation possible on them, unlike ORM models which can do many things.
Whenever I've implemented a custom API client in PHP, boring old OOP seems to solve the problems stated in the article reasonably well:
class ApiConsumer {
function __construct($baseUrl, $credentials);
function operationFoo($paramOne, $paramTwo): FooResponse;
function operationBar($paramOne, $paramTwo): BarResponse;
}