moceansdk 1.1.1

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 moceanapi.com.

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

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'
});

print(res);
*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.1.1 #

  • Fix code analytics sugguestions 4ddb086

1.1.0 #

1.0.0 #

  • Initial release

example/main.dart

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:


dependencies:
  moceansdk: ^1.1.1

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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
10
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:moceansdk/moceansdk.dart.

Health issues and suggestions

Document public APIs. (-1 points)

42 out of 42 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/abstract_client.dart. (-1 points)

Analysis of lib/src/modules/abstract_client.dart reported 2 hints:

line 11 col 18: Don't type annotate initializing formals.

line 11 col 46: Don't type annotate initializing formals.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http ^0.12.0+2 0.12.0+2
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
source_span 1.5.5
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