moceansdk 1.2.0
MoceanAPI Client Library for Dart #
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 yourpubspec.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
mocean.voice.call(); //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'
});
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.2.0 #
- Add Voice Feature 5623e7f
1.1.1 #
- Fix code analytics sugguestions 4ddb086
1.1.0 #
- Add example 5623e7f
- Fix coding style 7a55967 f8fc22b
- Allow user to pass in their own http client d471842
- Add tests 5df17d1
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:
dependencies:
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';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
64
|
Health:
Code health derived from static analysis.
[more]
|
97
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
81
|
We analyzed this package on Dec 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.12.21
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)
54 out of 54 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.
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.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.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 |