Skip to content

Commit

Permalink
Merge branch 'develop' into update-from-template-merged
Browse files Browse the repository at this point in the history
  • Loading branch information
xdev-gh-bot committed Jul 29, 2024
2 parents 5061004 + 8e8fc48 commit 13956b8
Show file tree
Hide file tree
Showing 409 changed files with 146,932 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ body:
attributes:
label: "Checklist"
options:
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)"
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/brevo-java-client/releases/latest)"
required: true
- 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."
- 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."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/enhancement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- 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."
- 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."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- 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."
- 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."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise."
required: true
Expand Down
16 changes: 0 additions & 16 deletions .run/Run Demo.run.xml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 1.0.1
* Updated dependencies
* Updated to OpenAPI Generator 7.4

# 1.0.0
Initial release
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ You should have the following things installed:
* Ensure that the JDK/Java-Version is correct


## 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)
## 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)

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

If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes
Expand Down
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
[![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)
[![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)
[![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)
[![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)
[![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)
[![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)
[![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)

# template-placeholder
# <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

This client [is generated](./template-placeholder/pom.xml) from an [``openapi.yml``](./openapi/openapi.yml) using [OpenAPI Generator](https://openapi-generator.tech/).
A Java client for the [Brevo](https://www.brevo.com/?r=t) (formerly SendinBlue) API

> [!IMPORTANT]
> An API-Key is required.<br/>
> You can get it at https://app.brevo.com/settings/keys/api
This client [is generated](./brevo-java-client/pom.xml) from an [``openapi.yml``](./openapi/openapi.yml) using [OpenAPI Generator](https://openapi-generator.tech/).

> [!NOTE]
> <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>
>
> We had some problems (as of March 2024) with the "official" client:
> * The client looks seriously outdated:
> * it is still called "SendinBlue"
> * was last updated over a year ago and there was no activity (on issues/PR) since then
> * There is at least one CVE in the underlying HTTP client
> * It looks like there are problems with the underlying dependencies:
> * ``maven-gpg-plugin`` is declared as compile dependency
> * There is a [dependency for Java 7](https://www.threeten.org/threetenbp/) however the client is built for Java 8+
> * ...
>
> </details>
## Installation
[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#Installation)
[Installation guide for the latest release](https://github.com/xdev-software/brevo-java-client/releases/latest#Installation)

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

## Support
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).
Expand All @@ -20,4 +41,6 @@ If you need support as soon as possible and you can't wait for any pull request,
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.

## Dependencies and Licenses
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/template-placeholder/dependencies)
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/brevo-java-client/dependencies)

<sub>Disclaimer: This is not an official Brevo product and not associated with Brevo</sub>
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Reporting a Vulnerability

Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new).
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/brevo-java-client/security/advisories/new).
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<parent>
<groupId>software.xdev</groupId>
<artifactId>template-placeholder-root</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>brevo-java-client-root</artifactId>
<version>1.0.2-SNAPSHOT</version>
</parent>

<artifactId>template-placeholder-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>brevo-java-client-demo</artifactId>
<version>1.0.2-SNAPSHOT</version>
<packaging>jar</packaging>

<organization>
Expand All @@ -34,7 +34,7 @@
<dependencies>
<dependency>
<groupId>software.xdev</groupId>
<artifactId>template-placeholder</artifactId>
<artifactId>brevo-java-client</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
106 changes: 106 additions & 0 deletions brevo-java-client-demo/src/main/java/software/xdev/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package software.xdev;

import java.util.List;
import java.util.Optional;
import java.util.Scanner;
import java.util.function.Function;

import org.apache.hc.core5.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import software.xdev.brevo.api.ContactsApi;
import software.xdev.brevo.client.ApiClient;
import software.xdev.brevo.client.ApiException;
import software.xdev.brevo.model.CreateContact;
import software.xdev.brevo.model.CreateUpdateContactModel;
import software.xdev.brevo.model.GetContactInfoIdentifierParameter;
import software.xdev.brevo.model.GetExtendedContactDetails;
import software.xdev.brevo.model.UpdateContact;


public final class Application
{
private static final Logger LOG = LoggerFactory.getLogger(Application.class);

static Scanner scanner = new Scanner(System.in);

// Tries to add an email/contact to a list
public static void main(final String[] args)
{
final ApiClient apiClient = new ApiClient();
apiClient.setApiKey(getProperty("API-KEY", Function.identity()));
apiClient.setUserAgent("Brevo Java Client");

final long listId = getProperty("LIST-ID", Long::parseLong);
final String email = getProperty("EMAIL-FOR-LIST", Function.identity());

final ContactsApi contactsApi = new ContactsApi(apiClient);
try
{
final GetContactInfoIdentifierParameter identifier =
new GetContactInfoIdentifierStringParameter(email);
final GetExtendedContactDetails contactInfo = contactsApi.getContactInfo(
identifier,
null,
null);
LOG.info("Got contact[email={},listIds={}]", contactInfo.getEmail(), contactInfo.getListIds());
if(!contactInfo.getListIds().contains(listId))
{
contactsApi.updateContact(identifier, new UpdateContact().listIds(List.of(listId)));
LOG.info("Updated contact to include listId={}", listId);
}
}
catch(final ApiException ex)
{
if(ex.getCode() == HttpStatus.SC_NOT_FOUND)
{
final CreateUpdateContactModel createdContact = contactsApi.createContact(new CreateContact()
.email(email)
.listIds(List.of(listId)));
LOG.info("Created contact[id={}, email={},listIds={}]", createdContact.getId(), email, listId);
}
}
}

private static <T> T getProperty(final String identifier, final Function<String, T> caster)
{
String value = Optional.ofNullable(System.getenv(identifier))
.orElseGet(() -> System.getProperty(identifier));
if(value == null)
{
LOG.error("Required {} not set in environment variables or system properties", identifier);

LOG.info("Please provide {} over console:", identifier);
value = scanner.nextLine();

if(value == null || value.isBlank())
{
LOG.error("Invalid input; Aborting");
System.exit(1);
}
}
return caster.apply(value);
}

private Application()
{
}

@SuppressWarnings("java:S2160")
public static class GetContactInfoIdentifierStringParameter extends GetContactInfoIdentifierParameter
{
private final String value;

public GetContactInfoIdentifierStringParameter(final String value)
{
this.value = value;
}

@Override
public String toString()
{
return this.value;
}
}
}
20 changes: 20 additions & 0 deletions brevo-java-client-demo/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configuration>
<Configuration status="ERROR">

<Properties>
<Property name="consolePattern">%d{HH:mm:ss} %-5p [%t] [%-25.25c] %m %n</Property>
</Properties>

<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="${consolePattern}"/>
</Console>
</Appenders>

<Loggers>
<Root level="INFO">
<AppenderRef ref="stdout"/>
</Root>
</Loggers>
</Configuration>
18 changes: 9 additions & 9 deletions template-placeholder/pom.xml → brevo-java-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.xdev</groupId>
<artifactId>template-placeholder</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>brevo-java-client</artifactId>
<version>1.0.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>template-placeholder</name>
<description>template-placeholder</description>
<url>https://github.com/xdev-software/template-placeholder</url>
<name>brevo-java-client</name>
<description>brevo-java-client</description>
<url>https://github.com/xdev-software/brevo-java-client</url>

<scm>
<url>https://github.com/xdev-software/template-placeholder</url>
<connection>scm:git:https://github.com/xdev-software/template-placeholder.git</connection>
<url>https://github.com/xdev-software/brevo-java-client</url>
<connection>scm:git:https://github.com/xdev-software/brevo-java-client.git</connection>
</scm>

<inceptionYear>2023</inceptionYear>
<inceptionYear>2024</inceptionYear>

<organization>
<name>XDEV Software</name>
Expand Down Expand Up @@ -314,7 +314,7 @@
<profile>
<id>openapi-generator</id>
<properties>
<componentName>INSERT_NAME_HERE</componentName>
<componentName>brevo</componentName>

<generatedDir>${project.basedir}/${generatedDirRelative}</generatedDir>
<openApiRelativeGeneratorDir>src/gen</openApiRelativeGeneratorDir>
Expand Down
Loading

0 comments on commit 13956b8

Please sign in to comment.