A Java module for communicating with the Nimba SMS API.
-
JDK 11 or higher.
-
subscription via Nimba SMS Partner portal
-
Java 11 or higher
-
Subscription via Nimba SMS Partner Portal
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>
⚠️ 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>
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>
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";
import com.nimbasms.nimbasms.NimbaSMSClient;
NimbaSMSClient client = new NimbaSMSClient(ACCOUNT_SID, AUTH_TOKEN)
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());
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);
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);
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);
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);
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();
This project is licensed under the MIT License – see the LICENSE file for details.
Contributions to the official Java client for Nimba SMS
💡 Feel free to open issues or pull requests to improve the SDK.