Java SDK
  • 16 Jan 2021
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Java SDK

  • Dark
    Light
  • PDF

Article Summary

This Java Callable-SDK provides support for the management and flow control of the callable platform. The latest version can be found here

Maven

<dependency>
    <groupId>io.callable</groupId>
    <artifactId>callable-sdk</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

compile group: 'io.callable', name: 'callable-sdk', version: '1.0.0'

# Example library usage
This library makes heavy use of the Builder/Fluent Pattern

Client Initialisation

CallableClient client = CallableClientBuilder.builder()
         .withUrl("https://api.callable.io")
         .withUsername("demo@callable.io")
         .withPassword("1234")
         .build();

Organisation Service

The OrganisationService is the top of the hierarchy and deals with the account management.

Get Organisation Service

OrganisationService organisationService = client.organisation();

//Retrieve your organisation details
Organisation myOrg = organisationService.me();

List Accounts

List<Account> accounts = organisationService.accounts();

//Grab the first account
Account account = accounts.get(0);

Create Account

Creating an account will automatically assign an inbound number to the address which you use to create the account.

Address address = Address.builder()
        .line1("5 The Old Printworks")
        .line2("20 Wharf Road")
        .level2("Eastbourne")
        .level1("East Sussex")
        .postalCode("BN21 3AW")
        .country("United Kingdom")
        .build();
            
AccountPostRequest accountPostRequest = AccountPostRequest.builder()
        .organisation(me.getId())
        .name("Deans Pizza's")
        .domain("deanspizzas")
        .address(address)
        .build();

Account account = organisationService.create(accountPostRequest);

Account Service

Used for the management of the account.

AccountService accountService = organisationService.account(account.getId());

//Get DDIs (Inbound numbers)
accountService.ddis().list().forEach(ddi -> log.info(ddi.getName()));

//List SIP Trunks
accountService.trunks().list().forEach(trunk -> log.info(trunk.getDescription()));

//List Integration URLs
accountService.integrations().list().forEach(integration -> log.info(integration.getUrl()));

//List MS Teams Devices
accountService.devices().findByDeviceType(DeviceType.TEAM).forEach(device -> log.info(device.getName()));

//List SIP Clients
accountService.devices().findByDeviceType(DeviceType.CLIENT).forEach(device -> log.info(device.getName()));

Channel Service

A Callable channel is a conduit for communicating with the outside world. We currently support Voice, SMS & Email.

ChannelService channelService = organisationService.channel(account.getId());

//Make a voice call (Dials number then hangs up)
CallableTarget target = new CallableTarget(new PhoneNumber("+441234567890"));
VoiceCall voiceCall = new VoiceCall(target);
Sid sid = channelService.voice().create(voiceCall);

What's Next