moceansdk 1.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

MoceanAPI Client Library for Dart #

Latest Stable Version Build Status codecov MIT license

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

Installation #

To install the client

  • add moceansdk to your pubspec.yaml
  • run pub get

Usage #

Create a client with your API key and secret

import 'package:moceansdk/moceansdk.dart';

var mocean = Mocean(
  Basic('your api key', 'your api secret')

Available API #

mocean.balance.inquiry();       //Get Account Balance
mocean.pricing.inquiry();       //Get Account Pricing
mocean.sms.send();              //Send SMS
mocean.messageStatus.inquiry(); //Get Message Status
mocean.sendCode.send();         //Send Verify Code
mocean.verifyCode.send();       //Check Verify Code
mocean.numberLookup.inquiry();  //Number Lookup;            //Voice

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.

var res = await mocean.sms.send({
  'mocean-to': '60123456789',
  'mocean-text': 'hello world',
  'mocean-from': 'dart'

*All calls will return Future object

Responses #

For your convenient, the API response has been parsed to Map

print(res);           // show full response string
print(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

1.2.0 #

1.1.1 #

  • Fix code analytics sugguestions 4ddb086

1.1.0 #

1.0.0 #

  • Initial release


import 'package:moceansdk/moceansdk.dart';

void main() async {
  //setup your credentials
  var basicCredentials = Basic('your_api_key', 'your_api_secret');

  //create a mocean object using the credentials
  var mocean = Mocean(basicCredentials);

  //get account balance
  await mocean.balance.inquiry();

  //get account pricing
  await mocean.pricing.inquiry();

  //send sms
  await mocean.sms.send({
    'mocean-to': '60123456789',
    'mocean-from': 'yourname',
    'mocean-text': 'sample text'

  //get message status
  await mocean.messageStatus
      .inquiry({'mocean-msgid': 'the msg id get from sms response'});

  //send otp code
  await mocean.sendCode
      .send({'mocean-to': '60123456789', 'mocean-brand': 'yourbrand'});

  //verify otp code
  await mocean.verifyCode.send({
    'mocean-reqid': 'the req id get from send otp response',
    'mocean-code': 'the code'

  //perform number lookup
  await mocean.numberLookup.inquiry({'mocean-to': '60123456789'});

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  moceansdk: ^1.2.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:moceansdk/moceansdk.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-1 points)

55 out of 55 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/modules/voice/mc.dart. (-2.48 points)

Analysis of lib/src/modules/voice/mc.dart reported 5 hints:

line 9 col 43: Avoid using null in if null operators.

line 11 col 47: Avoid using null in if null operators.

line 13 col 42: Avoid using null in if null operators.

line 15 col 63: Avoid using null in if null operators.

line 17 col 57: Avoid using null in if null operators.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http ^0.12.0+2 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
mockito ^4.1.0
test >=1.3.0 <2.0.0
test_coverage ^0.2.0