nexmo-spring-boot-autoconfigure

Spring Boot Auto Configuration for Nexmo

License

License

MIT
Categories

Categories

Spring Boot Container Microservices Auto Application Layer Libs Code Generators config Configuration
GroupId

GroupId

com.nexmo
ArtifactId

ArtifactId

nexmo-spring-boot-autoconfigure
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

nexmo-spring-boot-autoconfigure
Spring Boot Auto Configuration for Nexmo
Project URL

Project URL

https://github.com/nexmo/nexmo-spring-boot-starter
Project Organization

Project Organization

Nexmo
Source Code Management

Source Code Management

https://github.com/Nexmo/nexmo-spring-boot-starter

Download nexmo-spring-boot-autoconfigure

How to add to project

<!-- https://jarcasting.com/artifacts/com.nexmo/nexmo-spring-boot-autoconfigure/ -->
<dependency>
    <groupId>com.nexmo</groupId>
    <artifactId>nexmo-spring-boot-autoconfigure</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.nexmo/nexmo-spring-boot-autoconfigure/
implementation 'com.nexmo:nexmo-spring-boot-autoconfigure:1.1.0'
// https://jarcasting.com/artifacts/com.nexmo/nexmo-spring-boot-autoconfigure/
implementation ("com.nexmo:nexmo-spring-boot-autoconfigure:1.1.0")
'com.nexmo:nexmo-spring-boot-autoconfigure:jar:1.1.0'
<dependency org="com.nexmo" name="nexmo-spring-boot-autoconfigure" rev="1.1.0">
  <artifact name="nexmo-spring-boot-autoconfigure" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.nexmo', module='nexmo-spring-boot-autoconfigure', version='1.1.0')
)
libraryDependencies += "com.nexmo" % "nexmo-spring-boot-autoconfigure" % "1.1.0"
[com.nexmo/nexmo-spring-boot-autoconfigure "1.1.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.springframework.boot : spring-boot jar 2.1.4.RELEASE
org.springframework.boot : spring-boot-autoconfigure jar 2.1.4.RELEASE
org.springframework.boot : spring-boot-configuration-processor Optional jar 2.1.4.RELEASE
com.nexmo : client Optional jar 4.4.0
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.31

test (2)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.1.4.RELEASE
org.assertj : assertj-core jar 3.12.2

Project Modules

There are no modules declared in this project.

Nexmo Spring Boot Starter

Maven Central Build Status codecov

Nexmo is now known as Vonage

This Spring Boot Starter has been provided to help with integrating the Nexmo Java SDK into your Spring Boot project.

Installation

For Gradle:

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.nexmo:nexmo-spring-boot-starter:1.1.0'
}

For Maven:

<dependency>
  <groupId>com.nexmo</groupId>
  <artifactId>nexmo-spring-boot-starter</artifactId>
  <version>1.1.0</version>
</dependency>

Usage

The Nexmo Spring Boot Starter will automatically configure instances of the NexmoClient.Builder, NexmoClient, and any of the other sub-clients (AccountClient, VoiceClient, etc..) once you have provided the required configuration values.

Configuration

The following configuration values are used to configure the starter. Check out the Application Property Files and Externalized Configuration reference in the Spring Boot documentation for how to provide configuration values.

API Key and Secret Configuration

nexmo.creds.api-key=your-api-key
nexmo.creds.secret=your-api-secret

This will give you access to automatically wire in the NexmoClient, AccountClient, ApplicationClient, ConversionClient, InsightClient, NumbersClient, RedactClient, SmsClient, SnsClient, and VerifyClient.

You can also provide a signature secret:

nexmo.creds.api-key=your-api-key
nexmo.creds.signature=signature

Application ID and Private Key Configuration

To gain access to the VoiceClient you will need to provide a Nexmo Application ID and location or contents of a private key file associated with the Nexmo Application.

Here is an example providing the path to the key:

nexmo.creds.application-id=application-id
nexmo.creds.private-key-path=/path/to/your/private.key

Here is an example providing the contents of the key:

nexmo.creds.application-id=application-id
nexmo.creds.private-key-contents=contents-of-the-key

Customizing the NexmoClient

By default, the auto configuration will create a NexmoClient.Builder using the information provided in your application.properties, application.yml, or other external configuration source. However, when registering the NexmoClient and all of the other sub-clients, the auto configuration can opt to use a pre-registered NexmoClient.Builder.

For example, if you would like to customize the base URI that the library uses, you can register a custom version of the NexmoClient.Builder in your configuration class:

@Autowired
NexmoCredentialsProperties nexmoCredentialsProperties;

@Bean
public NexmoClient.Builder customNexmoBuilder() {
    return NexmoClient.builder()
            .apiKey(nexmoCredentialsProperties.getApiKey())
            .apiSecret(nexmoCredentialsProperties.getSecret())
            .httpConfig(HttpConfig.builder().baseUri("https://example.com").build());
}

Note that you must include your credentials as shown in this example. This builder completely replaces the automatically configured one.

Customize Nexmo Client Version

By default, the Nexmo Spring Boot Starter will transitively define Nexmo Client to the latest version at its release. You can override this by adding a dependency on the Nexmo Client, bringing in 4.2.0 for example:

For Gradle:

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.nexmo:client:4.2.0'
}

For Maven:

<dependency>
  <groupId>com.nexmo</groupId>
  <artifactId>client</artifactId>
  <version>4.2.0</version>
</dependency>

Bringing in older versions of the supported Nexmo Client, may result in some unforseen consequences and build errors. As a result here is a list of each version targeted by each version of the starter:

Nexmo Spring Boot Starter Nexmo Java Client
v1.0.0 v4.3.0
v1.0.1 v4.3.1
v1.1.0 v4.4.0
com.nexmo

Nexmo

Versions

Version
1.1.0
1.0.1
1.0.0