davsclaus opened a new pull request, #28944:
URL: https://github.com/apache/camel/pull/28944

   Fixes [CAMEL-26166](https://issues.apache.org/jira/browse/CAMEL-26166).
   
   ### 1. A bytes or stream body was not converted
   
   `StripeProducer.getParametersFromBody` accepted only a `Map` or a `String` 
(by `instanceof`) and threw "Body must be a Map<String, Object> or a JSON 
String" for anything else. JSON as `byte[]` or an `InputStream`, such as the 
body of a `rest` or `platform-http` route, failed.
   
   Now any other body is converted with `getBody(String.class)` and parsed as 
JSON. A POJO still fails (its text is not JSON).
   
   ### 2. The CamelStripeOperation header was never read
   
   `StripeConstants.OPERATION_HEADER` was documented as "The operation to 
perform", but `process` took the operation only from the endpoint. The header 
now overrides the endpoint operation. It can be a String (`customers`, 
`paymentIntents`, ...) or a `StripeOperation`. Without the header, the endpoint 
operation is used as before.
   
   ### 3. update, capture, delete and cancel made an extra GET first
   
   Each of these retrieved the object first and then called the method on it, 
so every call made two HTTP requests. Now the producer creates an empty Stripe 
model object with only the id set (and the global response getter, as 
`retrieve` gives it) and calls the method on it. The SDK builds the same URL 
from the id, so the request is the same, minus the GET.
   
   I did not switch to the `StripeClient` service API proposed in the issue: 
its `update`/`capture`/`cancel` methods take typed params 
(`CustomerUpdateParams`, ...), not a `Map`, so the body handling would have to 
change for every resource.
   
   ### Tests
   
   New `StripeProducerRequestTest` runs the producer against a local JDK 
`HttpServer` as the Stripe API and checks the requests it receives: create from 
bytes and from a stream, the operation header as a String and as an enum, and 
that update, delete, capture and cancel (payment intent and subscription) send 
one request each. All 8 tests fail without the fix and pass with it. Module: 53 
tests, 0 failures (41 integration tests skipped, they need a real Stripe key).
   
   ### Docs and generated files
   
   - Component doc: the REST example no longer needs 
`convertBodyTo(String.class)`; a line notes that the header overrides the 
operation.
   - `@BodyTypes` of the endpoint: producer in now lists bytes and stream; 
description updated.
   - Header description updated; regenerated `stripe.json`, the catalog copies 
and `StripeEndpointBuilderFactory`.
   - Upgrade guide 4.24: short `camel-stripe` entry, since a message that 
carried the header by accident now goes to another operation.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to