This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c84947d34bd4 Make the Stripe Operation an enum (#20315)
c84947d34bd4 is described below
commit c84947d34bd45e2598ce089ce7e697bc70189c04
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Dec 9 13:04:20 2025 +0100
Make the Stripe Operation an enum (#20315)
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../apache/camel/catalog/components/stripe.json | 2 +-
.../org/apache/camel/component/stripe/stripe.json | 2 +-
.../component/stripe/StripeConfiguration.java | 13 +++--
.../camel/component/stripe/StripeOperation.java | 57 ++++++++++++++++++++++
.../camel/component/stripe/StripeProducer.java | 26 +++++-----
.../builder/endpoint/StaticEndpointBuilders.java | 6 +++
.../endpoint/dsl/StripeEndpointBuilderFactory.java | 6 +++
7 files changed, 92 insertions(+), 20 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/stripe.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/stripe.json
index 0ae80144a41a..f2f74b56333b 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/stripe.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/stripe.json
@@ -35,7 +35,7 @@
"CamelStripeObjectId": { "index": 2, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The ID of the object to retrieve, update, or delete",
"constantName": "org.apache.camel.component.stripe.StripeConstants#OBJECT_ID" }
},
"properties": {
- "operation": { "index": 0, "kind": "path", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.stripe.StripeConfiguration", "configurationField":
"configuration", "description": "The Stripe operation to perform" },
+ "operation": { "index": 0, "kind": "path", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"org.apache.camel.component.stripe.StripeOperation", "enum": [ "charges",
"customers", "paymentIntents", "paymentMethods", "refunds", "subscriptions",
"invoices", "products", "prices", "balanceTransactions" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass": "org.apache.camel.compon [...]
"lazyStartProducer": { "index": 1, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produc [...]
"apiBase": { "index": 2, "kind": "parameter", "displayName": "Api Base",
"group": "advanced", "label": "advanced", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.stripe.StripeConfiguration", "configurationField":
"configuration", "description": "Override the default Stripe API base URL (for
testing purposes)" },
"apiKey": { "index": 3, "kind": "parameter", "displayName": "Api Key",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "configurationClass":
"org.apache.camel.component.stripe.StripeConfiguration", "configurationField":
"configuration", "description": "The Stripe API key for authentication" }
diff --git
a/components/camel-stripe/src/generated/resources/META-INF/org/apache/camel/component/stripe/stripe.json
b/components/camel-stripe/src/generated/resources/META-INF/org/apache/camel/component/stripe/stripe.json
index 0ae80144a41a..f2f74b56333b 100644
---
a/components/camel-stripe/src/generated/resources/META-INF/org/apache/camel/component/stripe/stripe.json
+++
b/components/camel-stripe/src/generated/resources/META-INF/org/apache/camel/component/stripe/stripe.json
@@ -35,7 +35,7 @@
"CamelStripeObjectId": { "index": 2, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The ID of the object to retrieve, update, or delete",
"constantName": "org.apache.camel.component.stripe.StripeConstants#OBJECT_ID" }
},
"properties": {
- "operation": { "index": 0, "kind": "path", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.stripe.StripeConfiguration", "configurationField":
"configuration", "description": "The Stripe operation to perform" },
+ "operation": { "index": 0, "kind": "path", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"org.apache.camel.component.stripe.StripeOperation", "enum": [ "charges",
"customers", "paymentIntents", "paymentMethods", "refunds", "subscriptions",
"invoices", "products", "prices", "balanceTransactions" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass": "org.apache.camel.compon [...]
"lazyStartProducer": { "index": 1, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produc [...]
"apiBase": { "index": 2, "kind": "parameter", "displayName": "Api Base",
"group": "advanced", "label": "advanced", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.stripe.StripeConfiguration", "configurationField":
"configuration", "description": "Override the default Stripe API base URL (for
testing purposes)" },
"apiKey": { "index": 3, "kind": "parameter", "displayName": "Api Key",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "configurationClass":
"org.apache.camel.component.stripe.StripeConfiguration", "configurationField":
"configuration", "description": "The Stripe API key for authentication" }
diff --git
a/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeConfiguration.java
b/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeConfiguration.java
index 080db95eb2e7..3256cbc729af 100644
---
a/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeConfiguration.java
+++
b/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeConfiguration.java
@@ -28,9 +28,8 @@ import org.apache.camel.spi.UriPath;
public class StripeConfiguration {
@UriPath
- @Metadata(required = true, description = "The Stripe operation to perform",
- enums =
"charges,customers,paymentIntents,paymentMethods,refunds,subscriptions,invoices,products,prices,balanceTransactions")
- private String operation;
+ @Metadata(required = true, description = "The Stripe operation to perform")
+ private StripeOperation operation;
@UriParam(label = "security", secret = true, description = "The Stripe API
key for authentication")
private String apiKey;
@@ -38,14 +37,18 @@ public class StripeConfiguration {
@UriParam(label = "advanced", description = "Override the default Stripe
API base URL (for testing purposes)")
private String apiBase;
- public String getOperation() {
+ public StripeOperation getOperation() {
return operation;
}
- public void setOperation(String operation) {
+ public void setOperation(StripeOperation operation) {
this.operation = operation;
}
+ public void setOperation(String operation) {
+ this.operation = StripeOperation.fromValue(operation);
+ }
+
public String getApiKey() {
return apiKey;
}
diff --git
a/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeOperation.java
b/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeOperation.java
new file mode 100644
index 000000000000..01903aee158a
--- /dev/null
+++
b/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeOperation.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.stripe;
+
+/**
+ * Stripe operations.
+ */
+public enum StripeOperation {
+ CHARGES("charges"),
+ CUSTOMERS("customers"),
+ PAYMENT_INTENTS("paymentIntents"),
+ PAYMENT_METHODS("paymentMethods"),
+ REFUNDS("refunds"),
+ SUBSCRIPTIONS("subscriptions"),
+ INVOICES("invoices"),
+ PRODUCTS("products"),
+ PRICES("prices"),
+ BALANCE_TRANSACTIONS("balanceTransactions");
+
+ private final String value;
+
+ StripeOperation(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+
+ public static StripeOperation fromValue(String value) {
+ for (StripeOperation operation : StripeOperation.values()) {
+ if (operation.value.equalsIgnoreCase(value)) {
+ return operation;
+ }
+ }
+ throw new IllegalArgumentException("Unknown operation: " + value);
+ }
+}
diff --git
a/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeProducer.java
b/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeProducer.java
index bc0e6c243587..98c8ebc6fc47 100644
---
a/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeProducer.java
+++
b/components/camel-stripe/src/main/java/org/apache/camel/component/stripe/StripeProducer.java
@@ -52,10 +52,10 @@ public class StripeProducer extends DefaultProducer {
@Override
public void process(Exchange exchange) throws Exception {
- String operation = getEndpoint().getConfiguration().getOperation();
+ StripeOperation operation =
getEndpoint().getConfiguration().getOperation();
String method =
exchange.getIn().getHeader(StripeConstants.METHOD_HEADER, String.class);
- if (ObjectHelper.isEmpty(operation)) {
+ if (operation == null) {
throw new IllegalArgumentException("Operation must be specified");
}
@@ -100,27 +100,27 @@ public class StripeProducer extends DefaultProducer {
"Body must be a Map<String, Object> or a JSON String, but was:
" + body.getClass().getName());
}
- private Object performOperation(Exchange exchange, String operation,
String method) throws Exception {
+ private Object performOperation(Exchange exchange, StripeOperation
operation, String method) throws Exception {
switch (operation) {
- case StripeConstants.OPERATION_CHARGES:
+ case CHARGES:
return handleCharges(exchange, method);
- case StripeConstants.OPERATION_CUSTOMERS:
+ case CUSTOMERS:
return handleCustomers(exchange, method);
- case StripeConstants.OPERATION_PAYMENT_INTENTS:
+ case PAYMENT_INTENTS:
return handlePaymentIntents(exchange, method);
- case StripeConstants.OPERATION_PAYMENT_METHODS:
+ case PAYMENT_METHODS:
return handlePaymentMethods(exchange, method);
- case StripeConstants.OPERATION_REFUNDS:
+ case REFUNDS:
return handleRefunds(exchange, method);
- case StripeConstants.OPERATION_SUBSCRIPTIONS:
+ case SUBSCRIPTIONS:
return handleSubscriptions(exchange, method);
- case StripeConstants.OPERATION_INVOICES:
+ case INVOICES:
return handleInvoices(exchange, method);
- case StripeConstants.OPERATION_PRODUCTS:
+ case PRODUCTS:
return handleProducts(exchange, method);
- case StripeConstants.OPERATION_PRICES:
+ case PRICES:
return handlePrices(exchange, method);
- case StripeConstants.OPERATION_BALANCE_TRANSACTIONS:
+ case BALANCE_TRANSACTIONS:
return handleBalanceTransactions(exchange, method);
default:
throw new IllegalArgumentException("Unsupported operation: " +
operation);
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
index 65e91c9bbf09..467f6927460e 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
@@ -15305,6 +15305,9 @@ public class StaticEndpointBuilders {
*
* Path parameter: operation (required)
* The Stripe operation to perform
+ * There are 10 enums and the value can be one of: charges, customers,
+ * paymentIntents, paymentMethods, refunds, subscriptions, invoices,
+ * products, prices, balanceTransactions
*
* @param path operation
* @return the dsl builder
@@ -15324,6 +15327,9 @@ public class StaticEndpointBuilders {
*
* Path parameter: operation (required)
* The Stripe operation to perform
+ * There are 10 enums and the value can be one of: charges, customers,
+ * paymentIntents, paymentMethods, refunds, subscriptions, invoices,
+ * products, prices, balanceTransactions
*
* @param componentName to use a custom component name for the endpoint
* instead of the default name
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StripeEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StripeEndpointBuilderFactory.java
index ba263cdd2dec..b0b89f8dd792 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StripeEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StripeEndpointBuilderFactory.java
@@ -158,6 +158,9 @@ public interface StripeEndpointBuilderFactory {
*
* Path parameter: operation (required)
* The Stripe operation to perform
+ * There are 10 enums and the value can be one of: charges, customers,
+ * paymentIntents, paymentMethods, refunds, subscriptions, invoices,
+ * products, prices, balanceTransactions
*
* @param path operation
* @return the dsl builder
@@ -177,6 +180,9 @@ public interface StripeEndpointBuilderFactory {
*
* Path parameter: operation (required)
* The Stripe operation to perform
+ * There are 10 enums and the value can be one of: charges, customers,
+ * paymentIntents, paymentMethods, refunds, subscriptions, invoices,
+ * products, prices, balanceTransactions
*
* @param componentName to use a custom component name for the endpoint
* instead of the default name