Skip to content

Latest commit

 

History

History
106 lines (76 loc) · 2.88 KB

README.md

File metadata and controls

106 lines (76 loc) · 2.88 KB

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

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