Skip to content

MoceanAPI/mocean-sdk-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

169 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MoceanAPI Client Library for Java

Maven Release build codecov codacy license

This is the Java client library for use Mocean's API. To use this, you'll need a Mocean account. Sign up for free at moceanapi.com.

Installation

To use the client library you'll need to have created a Mocean account.

Maven

Add the following to the correct place in your project's POM file:

<dependency>
      <groupId>com.github.moceanapi</groupId>
      <artifactId>moceanapisdk</artifactId>
      <version>1.x.x</version>
</dependency>

Gradle

Add the following to build.gradle

repositories {
    mavenCentral()
}

For Gradle 3.4 or Higher:

dependencies {
    implementation 'com.github.moceanapi:moceanapisdk:1.x.x'
}

For older versions:

dependencies {
    compile 'com.github.moceanapi:moceanapisdk:1.x.x'
}

Usage

For version >=1.1.6

There are 2 ways to connect to MoceanAPI

Option 1: Create a client with your API token:

import com.mocean.system.Mocean;
import com.mocean.system.auth.Basic;

Basic credential = new Basic("API_TOKEN_HERE");
Mocean mocean = new Mocean(credential);

Option 2 (legacy): Create a client with your API key and secret:

import com.mocean.system.Mocean;
import com.mocean.system.auth.Basic;

Basic credential = new Basic("API_KEY_HERE","API_SECRET_HERE");
Mocean mocean = new Mocean(credential);

For version <1.1.6

Create a client with your API key and secret:

import com.mocean.system.Mocean;
import com.mocean.system.auth.Basic;

Basic credential = new Basic("API_KEY_HERE","API_SECRET_HERE");
Mocean mocean = new Mocean(credential);

Example

To use Mocean's SMS API to send an SMS message, call the mocean.sms.send() method.

The API can be called directly, using a simple array of parameters, the keys match the parameters of the API.

SmsResponse res = mocean.sms()
            .setFrom("MOCEAN")
            .setTo("60123456789")
            .setText("Hello World")
            .send();
            
System.out.println(res);

Responses

For your convenient, the API response has been parse to specified object.

System.out.println(res);         //show full response string
System.out.println(res.status);  //show response status, "0" in this case

Documentation

Kindly visit MoceanApi Docs for more usage

License

This library is released under the MIT License

About

βœ‰πŸ“² SDK Library for Java to send SMS for FREE using MoceanAPI sms solution.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages