Skip to content

Commit a10be95

Browse files
committed
Merge branch 'develop' into update-from-template-merged
2 parents f9b2fee + b52c895 commit a10be95

File tree

409 files changed

+148484
-53
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

409 files changed

+148484
-53
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ body:
1515
attributes:
1616
label: "Checklist"
1717
options:
18-
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)"
18+
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/brevo-java-client/releases/latest)"
1919
required: true
20-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
20+
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/brevo-java-client/issues) or [closed](https://github.com/xdev-software/brevo-java-client/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
2121
required: true
2222
- label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise."
2323
required: true

.github/ISSUE_TEMPLATE/enhancement.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ body:
1313
attributes:
1414
label: "Checklist"
1515
options:
16-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
16+
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/brevo-java-client/issues) or [closed](https://github.com/xdev-software/brevo-java-client/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
1717
required: true
1818
- label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise."
1919
required: true

.github/ISSUE_TEMPLATE/question.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ body:
1212
attributes:
1313
label: "Checklist"
1414
options:
15-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
15+
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/brevo-java-client/issues) or [closed](https://github.com/xdev-software/brevo-java-client/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
1616
required: true
1717
- label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise."
1818
required: true

.run/Run Demo.run.xml

-16
This file was deleted.

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 1.0.3
2+
* Updated dependencies
3+
* Updated to OpenAPI Generator 7.12
4+
5+
# 1.0.2
6+
* Updated dependencies
7+
* Updated to OpenAPI Generator 7.8
8+
9+
# 1.0.1
10+
* Updated dependencies
11+
* Updated to OpenAPI Generator 7.4
12+
13+
# 1.0.0
14+
Initial release

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ You should have the following things installed:
3434
* Ensure that the JDK/Java-Version is correct
3535

3636

37-
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/release.yml?branch=master)](https://github.com/xdev-software/template-placeholder/actions/workflows/release.yml)
37+
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/brevo-java-client/release.yml?branch=master)](https://github.com/xdev-software/brevo-java-client/actions/workflows/release.yml)
3838

3939
Before releasing:
40-
* Consider doing a [test-deployment](https://github.com/xdev-software/template-placeholder/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
40+
* Consider doing a [test-deployment](https://github.com/xdev-software/brevo-java-client/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
4141
* Check the [changelog](CHANGELOG.md)
4242

4343
If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes

README.md

+32-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
1-
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
2-
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/check-build.yml?branch=develop)](https://github.com/xdev-software/template-placeholder/actions/workflows/check-build.yml?query=branch%3Adevelop)
3-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_template-placeholder&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_template-placeholder)
4-
[![API Specification Editor](https://img.shields.io/badge/API--Spec-Editor-85ea2d?logo=swagger)](https://editor.swagger.io/?url=https://raw.githubusercontent.com/xdev-software/template-placeholder/develop/openapi/openapi.yml)
1+
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/brevo-java-client?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/brevo-java-client)
2+
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/brevo-java-client/check-build.yml?branch=develop)](https://github.com/xdev-software/brevo-java-client/actions/workflows/check-build.yml?query=branch%3Adevelop)
3+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_brevo-java-client&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_brevo-java-client)
4+
[![API Specification Editor](https://img.shields.io/badge/API--Spec-Editor-85ea2d?logo=swagger)](https://editor.swagger.io/?url=https://raw.githubusercontent.com/xdev-software/brevo-java-client/develop/openapi/openapi.yml)
55

6-
# template-placeholder
6+
# <img src="https://corp-backend.brevo.com/wp-content/uploads/2023/05/favicon.svg" height="28" /> [brevo](https://www.brevo.com/?r=t)-java-client
77

8-
This client [is generated](./template-placeholder/pom.xml) from an [``openapi.yml``](./openapi/openapi.yml) using [OpenAPI Generator](https://openapi-generator.tech/).
8+
A Java client for the [Brevo](https://www.brevo.com/?r=t) (formerly SendinBlue) API
9+
10+
> [!IMPORTANT]
11+
> An API-Key is required.<br/>
12+
> You can get it at https://app.brevo.com/settings/keys/api
13+
14+
This client [is generated](./brevo-java-client/pom.xml) from an [``openapi.yml``](./openapi/openapi.yml) using [OpenAPI Generator](https://openapi-generator.tech/).
15+
16+
> [!NOTE]
17+
> <details><summary>Why did you create this API client and not use <a href="https://github.com/sendinblue/APIv3-java-library">the official one</a>?</summary>
18+
>
19+
> We had some problems (as of March 2024) with the "official" client:
20+
> * The client looks seriously outdated:
21+
> * it is still called "SendinBlue"
22+
> * was last updated over a year ago and there was no activity (on issues/PR) since then
23+
> * There is at least one CVE in the underlying HTTP client
24+
> * It looks like there are problems with the underlying dependencies:
25+
> * ``maven-gpg-plugin`` is declared as compile dependency
26+
> * There is a [dependency for Java 7](https://www.threeten.org/threetenbp/) however the client is built for Java 8+
27+
> * ...
28+
>
29+
> </details>
930
1031
## Installation
11-
[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#Installation)
32+
[Installation guide for the latest release](https://github.com/xdev-software/brevo-java-client/releases/latest#Installation)
1233

1334
## Demo
14-
A minimal demo is also available [here](./template-placeholder-demo/src/main/java/software/xdev/Application.java).
35+
A minimal demo is also available [here](./brevo-java-client-demo/src/main/java/software/xdev/Application.java).
1536

1637
## Support
1738
If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).
@@ -20,4 +41,6 @@ If you need support as soon as possible and you can't wait for any pull request,
2041
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
2142

2243
## Dependencies and Licenses
23-
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/template-placeholder/dependencies)
44+
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/brevo-java-client/dependencies)
45+
46+
<sub>Disclaimer: This is not an official Brevo product and not associated with Brevo</sub>

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## Reporting a Vulnerability
44

5-
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new).
5+
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/brevo-java-client/security/advisories/new).

template-placeholder-demo/pom.xml renamed to brevo-java-client-demo/pom.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
<parent>
88
<groupId>software.xdev</groupId>
9-
<artifactId>template-placeholder-root</artifactId>
10-
<version>1.0.0-SNAPSHOT</version>
9+
<artifactId>brevo-java-client-root</artifactId>
10+
<version>1.0.4-SNAPSHOT</version>
1111
</parent>
1212

13-
<artifactId>template-placeholder-demo</artifactId>
14-
<version>1.0.0-SNAPSHOT</version>
13+
<artifactId>brevo-java-client-demo</artifactId>
14+
<version>1.0.4-SNAPSHOT</version>
1515
<packaging>jar</packaging>
1616

1717
<organization>
@@ -34,7 +34,7 @@
3434
<dependencies>
3535
<dependency>
3636
<groupId>software.xdev</groupId>
37-
<artifactId>template-placeholder</artifactId>
37+
<artifactId>brevo-java-client</artifactId>
3838
<version>${project.version}</version>
3939
</dependency>
4040

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package software.xdev;
2+
3+
import java.util.List;
4+
import java.util.Optional;
5+
import java.util.Scanner;
6+
import java.util.function.Function;
7+
8+
import org.apache.hc.core5.http.HttpStatus;
9+
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
11+
12+
import software.xdev.brevo.api.ContactsApi;
13+
import software.xdev.brevo.client.ApiClient;
14+
import software.xdev.brevo.client.ApiException;
15+
import software.xdev.brevo.model.CreateContact;
16+
import software.xdev.brevo.model.CreateUpdateContactModel;
17+
import software.xdev.brevo.model.GetContactInfoIdentifierParameter;
18+
import software.xdev.brevo.model.GetExtendedContactDetails;
19+
import software.xdev.brevo.model.UpdateContact;
20+
21+
22+
public final class Application
23+
{
24+
private static final Logger LOG = LoggerFactory.getLogger(Application.class);
25+
26+
static Scanner scanner = new Scanner(System.in);
27+
28+
// Tries to add an email/contact to a list
29+
public static void main(final String[] args)
30+
{
31+
final ApiClient apiClient = new ApiClient();
32+
apiClient.setApiKey(getProperty("API-KEY", Function.identity()));
33+
apiClient.setUserAgent("Brevo Java Client");
34+
35+
final long listId = getProperty("LIST-ID", Long::parseLong);
36+
final String email = getProperty("EMAIL-FOR-LIST", Function.identity());
37+
38+
final ContactsApi contactsApi = new ContactsApi(apiClient);
39+
try
40+
{
41+
final GetContactInfoIdentifierParameter identifier =
42+
new GetContactInfoIdentifierStringParameter(email);
43+
final GetExtendedContactDetails contactInfo = contactsApi.getContactInfo(
44+
identifier,
45+
null,
46+
null);
47+
LOG.info("Got contact[email={},listIds={}]", contactInfo.getEmail(), contactInfo.getListIds());
48+
if(!contactInfo.getListIds().contains(listId))
49+
{
50+
contactsApi.updateContact(identifier, new UpdateContact().listIds(List.of(listId)));
51+
LOG.info("Updated contact to include listId={}", listId);
52+
}
53+
}
54+
catch(final ApiException ex)
55+
{
56+
if(ex.getCode() == HttpStatus.SC_NOT_FOUND)
57+
{
58+
final CreateUpdateContactModel createdContact = contactsApi.createContact(new CreateContact()
59+
.email(email)
60+
.listIds(List.of(listId)));
61+
LOG.info("Created contact[id={}, email={},listIds={}]", createdContact.getId(), email, listId);
62+
}
63+
}
64+
}
65+
66+
private static <T> T getProperty(final String identifier, final Function<String, T> caster)
67+
{
68+
String value = Optional.ofNullable(System.getenv(identifier))
69+
.orElseGet(() -> System.getProperty(identifier));
70+
if(value == null)
71+
{
72+
LOG.error("Required {} not set in environment variables or system properties", identifier);
73+
74+
LOG.info("Please provide {} over console:", identifier);
75+
value = scanner.nextLine();
76+
77+
if(value == null || value.isBlank())
78+
{
79+
LOG.error("Invalid input; Aborting");
80+
System.exit(1);
81+
}
82+
}
83+
return caster.apply(value);
84+
}
85+
86+
private Application()
87+
{
88+
}
89+
90+
@SuppressWarnings("java:S2160")
91+
public static class GetContactInfoIdentifierStringParameter extends GetContactInfoIdentifierParameter
92+
{
93+
private final String value;
94+
95+
public GetContactInfoIdentifierStringParameter(final String value)
96+
{
97+
this.value = value;
98+
}
99+
100+
@Override
101+
public String toString()
102+
{
103+
return this.value;
104+
}
105+
}
106+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE Configuration>
3+
<Configuration status="ERROR">
4+
5+
<Properties>
6+
<Property name="consolePattern">%d{HH:mm:ss} %-5p [%t] [%-25.25c] %m %n</Property>
7+
</Properties>
8+
9+
<Appenders>
10+
<Console name="stdout" target="SYSTEM_OUT">
11+
<PatternLayout pattern="${consolePattern}"/>
12+
</Console>
13+
</Appenders>
14+
15+
<Loggers>
16+
<Root level="INFO">
17+
<AppenderRef ref="stdout"/>
18+
</Root>
19+
</Loggers>
20+
</Configuration>

template-placeholder/pom.xml renamed to brevo-java-client/pom.xml

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>software.xdev</groupId>
8-
<artifactId>template-placeholder</artifactId>
9-
<version>1.0.0-SNAPSHOT</version>
8+
<artifactId>brevo-java-client</artifactId>
9+
<version>1.0.4-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

12-
<name>template-placeholder</name>
13-
<description>template-placeholder</description>
14-
<url>https://github.com/xdev-software/template-placeholder</url>
12+
<name>brevo-java-client</name>
13+
<description>brevo-java-client</description>
14+
<url>https://github.com/xdev-software/brevo-java-client</url>
1515

1616
<scm>
17-
<url>https://github.com/xdev-software/template-placeholder</url>
18-
<connection>scm:git:https://github.com/xdev-software/template-placeholder.git</connection>
17+
<url>https://github.com/xdev-software/brevo-java-client</url>
18+
<connection>scm:git:https://github.com/xdev-software/brevo-java-client.git</connection>
1919
</scm>
2020

21-
<inceptionYear>2023</inceptionYear>
21+
<inceptionYear>2024</inceptionYear>
2222

2323
<organization>
2424
<name>XDEV Software</name>
@@ -314,7 +314,7 @@
314314
<profile>
315315
<id>openapi-generator</id>
316316
<properties>
317-
<componentName>INSERT_NAME_HERE</componentName>
317+
<componentName>brevo</componentName>
318318

319319
<generatedDir>${project.basedir}/${generatedDirRelative}</generatedDir>
320320
<openApiRelativeGeneratorDir>src/gen</openApiRelativeGeneratorDir>

0 commit comments

Comments
 (0)