Skip to content

nimbasms/nimbasms-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nimbasms-java

A Java module for communicating with the Nimba SMS API.


Table of Contents


Installation

System Requirements

  • JDK 11 or higher.

  • subscription via Nimba SMS Partner portal

  • Java 11 or higher

  • Subscription via Nimba SMS Partner Portal

Maven (Default - Maven Central)

Add Maven Dependency

If you use Maven, add the following configuration to your project's pom.xml

<dependency>
  <groupId>com.nimbasms</groupId>
  <artifactId>nimbasms</artifactId>
  <version>0.0.1</version>
</dependency>

JitPack Setup

⚠️ If the package is not yet on Maven Central, you can use JitPack

<repositories>
  <repository>
  <id>jitpack.io</id>
  <url>https://jitpack.io</url>
  </repository>
</repositories>

Add Dependency

Using the latest release tag (recommended):

<dependency>
    <groupId>com.github.nimbasms</groupId>
    <artifactId>nimbasms-java</artifactId>
    <version>v0.0.1</version> <!-- Replace with the latest tag -->
</dependency>

If no release exists:

<dependency>
    <groupId>com.github.nimbasms</groupId>
    <artifactId>nimbasms-java</artifactId>
    <version>master-SNAPSHOT</version> <!-- Or use commit hash -->
</dependency>

Configuration of Credentials

Before instantiating a NimbaSMSClient object, ensure you have the required credentials. Obtain these credentials (ACCOUNT_SID and AUTH_TOKEN) from your SMS service provider.

String ACCOUNT_SID = "Your_ACCOUNT_SID";
String AUTH_TOKEN = "Your_AUTH_TOKEN";

Get your Access token

import com.nimbasms.nimbasms.NimbaSMSClient;

NimbaSMSClient client = new NimbaSMSClient(ACCOUNT_SID, AUTH_TOKEN)

Accounts

Retrieve the account information using the getAccount() method:

AccountResponse account = client.getAccount().get();
System.out.println(account);

Check balance

AccountResponse account = client.getAccount().get();
System.out.println(account.getBalance());

Groups

This code retrieves a list of all groups.

GroupResponse groups = client.getGroup().list();
System.out.println(groups);

You can also retrieve the last 10 Group by passing in the limit and offset:

GroupResponse last10groups = client.getGroup().list(10, 1);
System.out.println(last10groups);

The next method returns the next item in a list.

GroupResponse nextGroups = client.getGroup().next();
System.out.println(nextGroups);

The previous method returns the previous item in the list.

GroupResponse previousGroups = client.getGroup().previous();
System.out.println(previousGroups);

Sendernames

Retrieve the sender names using the getSenderName() method:

SenderNameResponse senderNames = client.getSenderName().list();
System.out.println(senderNames);

You can also retrieve the last 10 sender names by passing in the limit and offset:

SenderNameResponse last10SenderNames = client.getSenderName().list(10, 1);
System.out.println(last10SenderNames);

The next method returns the next item in a list.

SenderNameResponse nextSenderNames = client.getSenderName().next();
System.out.println(nextSenderNames);

The previous method returns the previous item in the list.

SenderNameResponse previousSenderNames = client.getSenderName().previous();
System.out.println(previousSenderNames);

Contacts

This code retrieves a list of all contacts.

ContactResponse contacts = client.getContact().list();
System.out.println(contacts);

You can also retrieve the last 10 contacts by passing in the limit and offset:

ContactResponse last10contacts = client.getContact().list(10, 1);
System.out.println(last10contacts);

The next method returns the next item in a list.

ContactResponse nextContacts = client.getContact().next();
System.out.println(nextContacts);

The previous method returns the previous item in the list.

ContactResponse previousContacts = client.getContact().previous();
System.out.println(previousContacts);

Create Contact. This contact will be added to the default contact list:

ContactDto createContactResponse = client.getContact().create("+224XXXXXXXXX", null, null);
System.out.println(createContactResponse)

Create with groups and name - name and groups are optional.

ContactDto contactResponseWithGroupsAndName = client.getContact().create("+224XXXXXXXXX", "Foo", List.of("API", "Facebook Client"));
System.out.println(contactResponseWithGroupsAndName);

Messages

Get All messages

MessageResponse messages = client.getMessage().list();
System.out.println(messages);

Get only last 10 messages

MessageResponse last10Messages = client.getMessage().list(10, 1);
System.out.println(last10Messages);

The next method returns the next item in a list.

MessageResponse nextMessages = client.getMessage().next();
System.out.println(nextMessages);

The previous method returns the previous item in the list.

MessageResponse previousMessages = client.getMessage().previous();
System.out.println(previousMessages);

Send a message

MessageResponse messageResponse = client.getMessage().create("sender_name", List.of("+224XXXXXXXXX"), "Hello nimba");
System.out.println(messageResponse);

Retrieve message

MessageDetails messageDetails = client.getMessage().retrieve("123");
System.out.println(messageDetails);

Purchases

List all purchases

PurchaseResponse purchases = client.getPurchase().list();

Retrieve the last 10 purchases

PurchaseResponse last10Purchases = client.getPurchase().list(10, 1);

The next method returns the next item in a list.

PurchaseResponse nextPurchases = client.getPurchase().next();

The previous method returns the previous item in a list.

PurchaseResponse previousPurchases = client.getPurchase().previous();

License

This project is licensed under the MIT License – see the LICENSE file for details.


Author & Contributions

Contributions to the official Java client for Nimba SMS

💡 Feel free to open issues or pull requests to improve the SDK.

About

A Java module for communicating with Nimba SMS API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages