Java API for ZenSend
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.travis.yml
LICENSE
README.md
pom.xml

README.md

Build Status

Installation

The library is distributed via Maven io.zensend::zensend

Examples

Create an instance of the client

Client client = new Client("YOUR-API-KEY");

Sending SMS

To send an SMS, you must specify the originator, body and numbers:

Message message = new Message();
message.originator = "orig";
message.body = "message body";
message.numbers = new String[]{"447777777777", "448888888888"};

SmsResult smsResult = client.sendSms(message);

System.out.println(
    smsResult.txGuid + ":" +
    smsResult.numbers + ":" +
    smsResult.smsParts + ":" +
    smsResult.encoding + ":" +
    smsResult.costInPence + ":" +
    smsResult.newBalanceInPence
);

You can also specify the following optional params:

Message message = new Message();
message.originator = "orig";
message.body = "message body";
message.numbers = new String[]{"447777777777", "448888888888"};
message.originatorType = Message.OriginatorType.ALPHA; // either ALPHA or MSISDN
message.timeToLiveInMinutes = 100;
message.smsEncoding = Message.SmsEncoding.GSM; // either GSM or UCS2

SmsResult smsResult = client.sendSms(message);

System.out.println(
    smsResult.txGuid + ":" +
    smsResult.numbers + ":" +
    smsResult.smsParts + ":" +
    smsResult.encoding + ":" +
    smsResult.costInPence + ":" +
    smsResult.newBalanceInPence
);

Checking your balance

This will return your current balance:

BigDecimal balance = client.checkBalance();

System.out.println(balance);

Listing prices

This will return a HashMap with all our prices by country code:

HashMap<String, BigDecimal> prices = client.getPrices();

System.out.println(prices);

Operator Lookup

This allows you to lookup the operator of a given MSISDN

OperatorLookupResult opLookup = client.lookupOperator("447777777777");

System.out.println(
    opLookup.mcc + ":" +
    opLookup.mnc + ":" +
    opLookup.operator + ":" +
    opLookup.costInPence + ":" +
    opLookup.newBalanceInPence
);

Release

mvn release:clean release:prepare
mvn release:perform -P release-profile

mvn deploy -P release-profile