Skip to content

sinch/sinch-sdk-java

Repository files navigation

sinch-sdk-java

Sinch Logo

Java SDK

License

Python 3.8

Welcome to Sinch's Java SDK.

Here you'll find documentation to start developing Java code using Sinch services.

To use this SDK you'll need a Sinch account and API keys. Please sign up at sinch.com

For more in depth version of the Sinch APIs, please refer to the official developer portal - developers.sinch.com

This SDK is currently available to selected developers for preview use only. It is being provided for the purpose of collecting feedback, and should not be used in production environments.


Prerequisites

Installation

Maven setup

Add to your pom.xml file the dependency to SDK:

<dependencies>
    <dependency>
      <groupId>com.sinch.sdk</groupId>
      <artifactId>sinch-java-sdk</artifactId>
      <version>${sdk.version}</version>
    </dependency>
    ...
</dependencies>

Getting started

Client initialization

To initialize communication with Sinch backed, credentials obtained from Sinch portal have to be provided to the main client class of this SDK. It's highly advised to not hardcode those credentials, but to fetch them from environment variables:

import com.sinch.sdk.SinchClient;
import com.sinch.sdk.models.Configuration;

...
Configuration configuration = Configuration.builder().setKeyId(PARAM_KEY_ID)
                                                     .setKeySecret(PARAM_KEY_SECRET)
                                                     .setProjectId(PARAM_PROJECT_ID)
                                                     .build();
...
SinchClient client = new SinchClient(configuration);

Products

Sinch client provides access to the following Sinch products:

Usage example of the numbers product:

AvailableNumberListResponse response = client
                                        .numbers()
                                        .available()
                                        .list(AvailableNumberListAllRequestParameters.builder()
                                                                                    .setRegionCode("US")
                                                                                    .setType(NumberType.LOCAL)
                                                                                    .build());

Logging

The SDK uses the Java 8 logging feature (java.util.logging) Loggers and severity can be configured by using a logging.properties file like (see sample-app/src/main/resources/:

handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = INFO
com.sinch.sdk.level = INFO

java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] [%4$-7s %2$s] %5$s %n

Examples

See sample-app module

HTTP Client

See HTTP-CLIENT file

Architecture

See ARCHITECTURE file

License

This project is licensed under the Apache License. See the LICENSE file for the license text.