Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add whatsapp starter #900

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ vm
weather
web3j
webhook
whatsapp
wordpress
workday
xchange
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"component": {
"kind": "component",
"name": "whatsapp",
"title": "WhatsApp",
"description": "Send messages to WhatsApp.",
"deprecated": false,
"firstVersion": "3.19.0",
"label": "cloud,api,chat",
"javaType": "org.apache.camel.component.whatsapp.WhatsAppComponent",
"supportLevel": "Stable",
"groupId": "org.apache.camel.springboot",
"artifactId": "camel-whatsapp-starter",
"version": "4.0.0-SNAPSHOT",
"scheme": "whatsapp",
"extendsScheme": "",
"syntax": "whatsapp:phoneNumberId",
"async": false,
"api": false,
"consumerOnly": false,
"producerOnly": true,
"lenientProperties": false
},
"componentProperties": {
"lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "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 producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." },
"phoneNumberId": { "index": 1, "kind": "property", "displayName": "Phone Number Id", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Phone Number ID taken from WhatsApp Meta for Developers Dashboard" },
"apiVersion": { "index": 2, "kind": "property", "displayName": "Api Version", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "v13.0", "description": "WhatsApp Cloud API version" },
"autowiredEnabled": { "index": 3, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." },
"baseUri": { "index": 4, "kind": "property", "displayName": "Base Uri", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "https:\/\/graph.facebook.com", "description": "Can be used to set an alternative base URI, e.g. when you want to test the component against a mock WhatsApp API" },
"client": { "index": 5, "kind": "property", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.net.http.HttpClient", "deprecated": false, "autowired": false, "secret": false, "description": "Java 11 HttpClient implementation" },
"webhookVerifyToken": { "index": 6, "kind": "property", "displayName": "Webhook Verify Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Webhook verify token" },
"authorizationToken": { "index": 7, "kind": "property", "displayName": "Authorization Token", "group": "security", "label": "security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Authorization Token taken from WhatsApp Meta for Developers Dashboard" }
},
"headers": {
"CamelWhatsAppPhoneNumberId": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Phone Number ID taken from WhatsApp Meta for Developers Dashboard", "constantName": "org.apache.camel.component.whatsapp.WhatsAppConstants#WHATSAPP_PHONE_NUMBER_ID" },
"CamelWhatsAppRecipientPhoneNumberId": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Recipient phone number associated with Phone Number ID", "constantName": "org.apache.camel.component.whatsapp.WhatsAppConstants#WHATSAPP_RECIPIENT_PHONE_NUMBER_ID" }
},
"properties": {
"phoneNumberId": { "index": 0, "kind": "path", "displayName": "Phone Number Id", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.whatsapp.WhatsAppConfiguration", "configurationField": "configuration", "description": "The phone number ID taken from whatsapp-business dashboard." },
"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 producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." },
"apiVersion": { "index": 2, "kind": "parameter", "displayName": "Api Version", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.whatsapp.WhatsAppConfiguration", "configurationField": "configuration", "description": "Facebook graph api version." },
"baseUri": { "index": 3, "kind": "parameter", "displayName": "Base Uri", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.whatsapp.WhatsAppConfiguration", "configurationField": "configuration", "description": "Can be used to set an alternative base URI, e.g. when you want to test the component against a mock WhatsApp API" },
"httpClient": { "index": 4, "kind": "parameter", "displayName": "Http Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.net.http.HttpClient", "deprecated": false, "autowired": false, "secret": false, "description": "HttpClient implementation" },
"webhookPath": { "index": 5, "kind": "parameter", "displayName": "Webhook Path", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "webhook", "configurationClass": "org.apache.camel.component.whatsapp.WhatsAppConfiguration", "configurationField": "configuration", "description": "Webhook path" },
"webhookVerifyToken": { "index": 6, "kind": "parameter", "displayName": "Webhook Verify Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.whatsapp.WhatsAppConfiguration", "configurationField": "configuration", "description": "Webhook verify token" },
"whatsappService": { "index": 7, "kind": "parameter", "displayName": "Whatsapp Service", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.whatsapp.WhatsAppService", "deprecated": false, "autowired": false, "secret": false, "description": "WhatsApp service implementation" },
"authorizationToken": { "index": 8, "kind": "parameter", "displayName": "Authorization Token", "group": "security", "label": "security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.whatsapp.WhatsAppConfiguration", "configurationField": "configuration", "description": "The authorization access token taken from whatsapp-business dashboard." }
}
}
49 changes: 49 additions & 0 deletions components-starter/camel-whatsapp-starter/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>components-starter</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>camel-whatsapp-starter</artifactId>
<packaging>jar</packaging>
<name>Camel SB Starters :: Whatsapp</name>
<description>Spring-Boot Starter for Camel Whatsapp support</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-whatsapp</artifactId>
<version>${camel-version}</version>
</dependency>
<!--START OF GENERATED CODE-->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-core-starter</artifactId>
</dependency>
<!--END OF GENERATED CODE-->
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"groups": [
{
"name": "camel.component.whatsapp",
"type": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration"
},
{
"name": "camel.component.whatsapp.customizer",
"type": "org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon$CustomizerProperties",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration",
"sourceMethod": "getCustomizer()"
}
],
"properties": [
{
"name": "camel.component.whatsapp.api-version",
"type": "java.lang.String",
"description": "WhatsApp Cloud API version",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration",
"defaultValue": "v13.0"
},
{
"name": "camel.component.whatsapp.authorization-token",
"type": "java.lang.String",
"description": "Authorization Token taken from WhatsApp Meta for Developers Dashboard",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration"
},
{
"name": "camel.component.whatsapp.autowired-enabled",
"type": "java.lang.Boolean",
"description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration",
"defaultValue": true
},
{
"name": "camel.component.whatsapp.base-uri",
"type": "java.lang.String",
"description": "Can be used to set an alternative base URI, e.g. when you want to test the component against a mock WhatsApp API",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration",
"defaultValue": "https:\/\/graph.facebook.com"
},
{
"name": "camel.component.whatsapp.client",
"type": "java.net.http.HttpClient",
"description": "Java 11 HttpClient implementation. The option is a java.net.http.HttpClient type.",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration"
},
{
"name": "camel.component.whatsapp.customizer.enabled",
"type": "java.lang.Boolean",
"sourceType": "org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon$CustomizerProperties"
},
{
"name": "camel.component.whatsapp.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable auto configuration of the whatsapp component. This is enabled by default.",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration"
},
{
"name": "camel.component.whatsapp.lazy-start-producer",
"type": "java.lang.Boolean",
"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 producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration",
"defaultValue": false
},
{
"name": "camel.component.whatsapp.phone-number-id",
"type": "java.lang.String",
"description": "Phone Number ID taken from WhatsApp Meta for Developers Dashboard",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration"
},
{
"name": "camel.component.whatsapp.webhook-verify-token",
"type": "java.lang.String",
"description": "Webhook verify token",
"sourceType": "org.apache.camel.component.whatsapp.springboot.WhatsAppComponentConfiguration"
}
],
"hints": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.whatsapp.springboot;

import org.apache.camel.CamelContext;
import org.apache.camel.Component;
import org.apache.camel.component.whatsapp.WhatsAppComponent;
import org.apache.camel.spi.ComponentCustomizer;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.apache.camel.spring.boot.ComponentConfigurationProperties;
import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
import org.apache.camel.spring.boot.util.ConditionalOnHierarchicalProperties;
import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Configuration(proxyBeanMethods = false)
@Conditional(ConditionalOnCamelContextAndAutoConfigurationBeans.class)
@EnableConfigurationProperties({ComponentConfigurationProperties.class,WhatsAppComponentConfiguration.class})
@ConditionalOnHierarchicalProperties({"camel.component", "camel.component.whatsapp"})
@AutoConfigureAfter({CamelAutoConfiguration.class, WhatsAppComponentConverter.class})
public class WhatsAppComponentAutoConfiguration {

@Autowired
private ApplicationContext applicationContext;
private final CamelContext camelContext;
@Autowired
private WhatsAppComponentConfiguration configuration;

public WhatsAppComponentAutoConfiguration(
org.apache.camel.CamelContext camelContext) {
this.camelContext = camelContext;
}

@Lazy
@Bean
public ComponentCustomizer configureWhatsAppComponent() {
return new ComponentCustomizer() {
@Override
public void configure(String name, Component target) {
CamelPropertiesHelper.copyProperties(camelContext, configuration, target);
}
@Override
public boolean isEnabled(String name, Component target) {
return HierarchicalPropertiesEvaluator.evaluate(
applicationContext,
"camel.component.customizer",
"camel.component.whatsapp.customizer")
&& target instanceof WhatsAppComponent;
}
};
}
}
Loading