Skip to content

Commit 27237e6

Browse files
authored
Merge pull request #2 from xdev-software/develop
Release
2 parents 7f3e551 + 4c34b8c commit 27237e6

File tree

404 files changed

+147577
-48
lines changed

Some content is hidden

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

404 files changed

+147577
-48
lines changed

.run/Run Demo.run.xml

Lines changed: 0 additions & 16 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## 1.0.0
2+
Initial release

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ You should have the following things installed:
3333
* Ensure that the JDK/Java-Version is correct
3434

3535

36-
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/openapi-client-maven-template/release.yml?branch=master)](https://github.com/xdev-software/openapi-client-maven-template/actions/workflows/release.yml)
36+
## 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)
3737

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

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

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
1-
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/openapi-client-maven-template?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/openapi-client-maven-template)
2-
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/openapi-client-maven-template/checkBuild.yml?branch=develop)](https://github.com/xdev-software/openapi-client-maven-template/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
3-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_openapi-client-maven-template&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_openapi-client-maven-template)
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/openapi-client-maven-template/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/checkBuild.yml?branch=develop)](https://github.com/xdev-software/brevo-java-client/actions/workflows/checkBuild.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-
# openapi-client-maven-template
6+
# <img src="https://corp-backend.brevo.com/wp-content/uploads/2023/05/favicon.svg" height="28" /> [brevo](https://brevo.com)-java-client
77

8-
This client [is generated](./openapi-client-maven-template/pom.xml) from an [``openapi.yml``](./openapi/openapi.yml) using [OpenAPI Generator](https://openapi-generator.tech/).
8+
A Java client for the [Brevo](https://brevo.com) (formerly [SendinBlue](https://help.brevo.com/hc/en-us/articles/11279317272722-FAQs-Sendinblue-becomes-Brevo)) 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/openapi-client-maven-template/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](./openapi-client-maven-template-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/openapi-client-maven-template/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

Lines changed: 1 addition & 1 deletion
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/openapi-client-maven-template/security/advisories/new).
5+
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/brevo-java-client/security/advisories/new).

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>software.xdev</groupId>
8-
<artifactId>openapi-client-maven-template-demo</artifactId>
8+
<artifactId>brevo-java-client-demo</artifactId>
99
<version>1.0.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

@@ -31,7 +31,7 @@
3131
<dependencies>
3232
<dependency>
3333
<groupId>software.xdev</groupId>
34-
<artifactId>openapi-client-maven-template</artifactId>
34+
<artifactId>brevo-java-client</artifactId>
3535
<version>${project.version}</version>
3636
</dependency>
3737

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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+
// Tries to add an email/contact to a list
27+
public static void main(final String[] args)
28+
{
29+
final ApiClient apiClient = new ApiClient();
30+
apiClient.setApiKey(getProperty("API-KEY", Function.identity()));
31+
apiClient.setUserAgent("Brevo Java Client");
32+
33+
final long listId = getProperty("LIST-ID", Long::parseLong);
34+
final String email = getProperty("EMAIL-FOR-LIST", Function.identity());
35+
36+
final ContactsApi contactsApi = new ContactsApi(apiClient);
37+
try
38+
{
39+
final GetContactInfoIdentifierParameter identifier =
40+
new GetContactInfoIdentifierStringParameter(email);
41+
final GetExtendedContactDetails contactInfo = contactsApi.getContactInfo(
42+
identifier,
43+
null,
44+
null);
45+
LOG.info("Got contact[email={},listIds={}]", contactInfo.getEmail(), contactInfo.getListIds());
46+
if(!contactInfo.getListIds().contains(listId))
47+
{
48+
contactsApi.updateContact(identifier, new UpdateContact().listIds(List.of(listId)));
49+
LOG.info("Updated contact to include listId={}", listId);
50+
}
51+
}
52+
catch(final ApiException ex)
53+
{
54+
if(ex.getCode() == HttpStatus.SC_NOT_FOUND)
55+
{
56+
final CreateUpdateContactModel createdContact = contactsApi.createContact(new CreateContact()
57+
.email(email)
58+
.listIds(List.of(listId)));
59+
LOG.info("Created contact[id={}, email={},listIds={}]", createdContact.getId(), email, listId);
60+
}
61+
}
62+
}
63+
64+
private static <T> T getProperty(final String identifier, final Function<String, T> caster)
65+
{
66+
String value = Optional.ofNullable(System.getenv(identifier))
67+
.orElseGet(() -> System.getProperty(identifier));
68+
if(value == null)
69+
{
70+
LOG.error("Required {} not set in environment variables or system properties", identifier);
71+
72+
LOG.info("Please provide {} over console:", identifier);
73+
try(final Scanner scanner = new Scanner(System.in))
74+
{
75+
value = scanner.nextLine();
76+
}
77+
78+
if(value == null || value.isBlank())
79+
{
80+
LOG.error("Invalid input; Aborting");
81+
System.exit(1);
82+
}
83+
}
84+
return caster.apply(value);
85+
}
86+
87+
private Application()
88+
{
89+
}
90+
91+
@SuppressWarnings("java:S2160")
92+
public static class GetContactInfoIdentifierStringParameter extends GetContactInfoIdentifierParameter
93+
{
94+
private final String value;
95+
96+
public GetContactInfoIdentifierStringParameter(final String value)
97+
{
98+
this.value = value;
99+
}
100+
101+
@Override
102+
public String toString()
103+
{
104+
return this.value;
105+
}
106+
}
107+
}
Lines changed: 20 additions & 0 deletions
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>
Lines changed: 13 additions & 13 deletions
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>openapi-client-maven-template</artifactId>
8+
<artifactId>brevo-java-client</artifactId>
99
<version>1.0.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

12-
<name>openapi-client-maven-template</name>
13-
<description>openapi-client-maven-template</description>
14-
<url>https://github.com/xdev-software/openapi-client-maven-template</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/openapi-client-maven-template</url>
18-
<connection>https://github.com/xdev-software/openapi-client-maven-template.git</connection>
17+
<url>https://github.com/xdev-software/brevo-java-client</url>
18+
<connection>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>
@@ -283,7 +283,7 @@
283283
<profile>
284284
<id>openapi-generator</id>
285285
<properties>
286-
<componentName>INSERT_NAME_HERE</componentName>
286+
<componentName>brevo</componentName>
287287

288288
<generatedDir>${project.basedir}/${generatedDirRelative}</generatedDir>
289289
<openApiRelativeGeneratorDir>src/gen</openApiRelativeGeneratorDir>
@@ -348,12 +348,12 @@
348348
<!-- Use newer Jakarta EE instead of Javax -->
349349
<useJakartaEe>true</useJakartaEe>
350350
<hideGenerationTimestamp>true</hideGenerationTimestamp>
351-
<!-- No tests and documentation because we don't use that -->
352-
<generateModelTests>false</generateModelTests>
353-
<generateApiTests>false</generateApiTests>
354-
<generateModelDocumentation>false</generateModelDocumentation>
355-
<generateApiDocumentation>false</generateApiDocumentation>
356351
</configOptions>
352+
<!-- No tests and documentation because we don't use that -->
353+
<generateModelTests>false</generateModelTests>
354+
<generateApiTests>false</generateApiTests>
355+
<generateModelDocumentation>false</generateModelDocumentation>
356+
<generateApiDocumentation>false</generateApiDocumentation>
357357
</configuration>
358358
</execution>
359359
</executions>

0 commit comments

Comments
 (0)