Last updated:
0 purchases
moceansdk
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
Usage
Example
Installation #
To install the client
add moceansdk to your pubspec.yaml
name: my_app
dependencies:
moceansdk: ^1.0.0
copied to clipboard
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')
);
copied to clipboard
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
copied to clipboard
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.
import 'package:moceansdk/moceansdk.dart';
var mocean = Mocean(
Basic('MOCEAN_API_KEY', 'MOCEAN_API_SECRET')
);
void main() async {
var res = await mocean.sms.send({
'mocean-to': '60123456789',
'mocean-text': 'hello world testing dart',
'mocean-from': 'MoceanAPI'
});
var result = res['messages'][0];
print(result);
print(result['status']);
print(result['msgid']);
print(result['receiver']);
}
copied to clipboard
*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['messages'][0]['status']); // show response status, '0' in this case
copied to clipboard
Documentation #
Kindly visit MoceanApi Docs for more usage
License #
This library is released under the MIT License
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.