Mon SMS PRO - Flutter/Dart SDK
A comprehensive Flutter/Dart SDK for integrating with the Mon SMS PRO platform. Send bulk SMS, manage campaigns, contacts, and leverage gamification features.
Table of Contents
Installation
Add to your pubspec.yaml:
dependencies:
mon_sms_pro: ^0.2.1
Then run:
flutter pub get
Quick Start
import 'package:mon_sms_pro/mon_sms_pro.dart';
// Initialize the SDK with your API key
final monSmsPro = MonSMSPRO(apiKey: 'YOUR_API_KEY');
// Initialize Hive adapters (required for local storage)
await initHiveAdapters();
// Send an OTP
final otpResponse = await monSmsPro.otp.get(
phoneNumber: '+2250700000000',
length: 6,
mode: 'NUMERIC',
);
// Get user details
final userResponse = await monSmsPro.user.details();
// Create a campaign
final campaignResponse = await monSmsPro.campaign.create(
text: 'Hello from Mon SMS PRO!',
senderId: 'your-sender-id',
contacts: [ContactModel(phone: '+2250700000000')],
);
API Reference
OTP API
Authentication via One-Time Password.
final otpApi = monSmsPro.otp;
get() - Request OTP
Sends an OTP to a phone number.
final response = await otpApi.get(
phoneNumber: '+2250700000000', // Required
senderId: 'MySender', // Optional: Custom sender ID
length: 6, // Optional: OTP length (default: 4)
mode: 'NUMERIC', // Optional: NUMERIC, ALPHABET, ALPHA_NUMERIC
appName: 'MyApp', // Optional: App name for SMS template
);
// Response
OTPModel(
id: '...',
token: 'verification-token',
phoneNumber: '+2250700000000',
status: OTPStatus.pending,
mode: OTPMode.numeric,
)
verify() - Verify OTP
Verifies an OTP code.
final response = await otpApi.verify(
token: 'verification-token', // Required: Token from get()
otp: '123456', // Required: OTP code entered by user
phoneNumber: '+2250700000000', // Optional
);
// Response
OTPModel(
status: OTPStatus.verified, // PENDING, VERIFIED, DEMO
)
User API
User registration and management.
final userApi = monSmsPro.user;
create() - Register New User
final response = await userApi.create(
emailAddress: 'user@example.com', // Required
phoneNumber: '+2250700000000', // Required
fullName: 'John Doe', // Required
otpToken: 'verification-token', // Required: From OTP verification
verificationId: 'verify-id', // Required
codePromo: 'PROMO2024', // Optional: Promo code
);
// Response: UserModel
details() - Get Current User
final response = await userApi.details();
// Response
UserModel(
id: '...',
fullName: 'John Doe',
emailAddress: 'user@example.com',
phoneNumber: '+2250700000000',
apiKey: '...',
availableCredit: 100,
isVerified: true,
// ...
)
credit() - Get Available Credit
final response = await userApi.credit();
// Response: int (available SMS credits)
get() - Get User by Phone
final response = await userApi.get(
phoneNumber: '+2250700000000',
otpToken: 'verification-token',
);
updateLogo() - Update Profile Picture
final response = await userApi.updateLogo(
logo: 'base64-encoded-image-or-url',
);
Campaign API
SMS campaign management.
final campaignApi = monSmsPro.campaign;
list() - List Campaigns
final response = await campaignApi.list(
senderId: 'sender-id', // Required
);
// Response: List<CampaignModel>
get() - Get Campaign Details
final response = await campaignApi.get(
id: 'campaign-id',
);
// Response: CampaignDetailsModel with contacts, groups, sender
create() - Create Campaign
final response = await campaignApi.create(
text: 'Your SMS message here', // Required
senderId: 'sender-id', // Required
name: 'Campaign Name', // Optional
contacts: [ // Optional
ContactModel(phone: '+2250700000000'),
ContactModel(phone: '+2250700000001'),
],
groupsIds: ['group-id-1', 'group-id-2'], // Optional
type: SMSType.sms, // Optional: SMS, FLASH, SCHEDULED, RECURRING
scheduledDate: DateTime.now().add(Duration(hours: 1)), // Optional
recurring: CampaignRecurringDayModel( // Optional: For recurring campaigns
enabled: true,
monday: DateTime.parse('2024-01-01 09:00:00'),
// ...
),
);
update() - Update Campaign
final response = await campaignApi.update(
id: 'campaign-id',
scheduledDate: DateTime.now().add(Duration(days: 1)),
recurring: CampaignRecurringDayModel(...),
);
toggleEnable() - Enable/Disable Campaign
final response = await campaignApi.toggleEnable(
id: 'campaign-id',
);
Contact API
Contact management.
final contactApi = monSmsPro.contact;
list() - List Contacts
final response = await contactApi.list(
count: 20, // Optional: Items per page
page: 1, // Optional: Page number
sort: SortList.desc, // Optional: asc or desc
orderBy: 'createdAt', // Optional
);
// Response: List<ContactModel>
create() - Create Contacts
final response = await contactApi.create(
contacts: [
ContactModel(
phone: '+2250700000000',
name: 'John Doe',
firstName: 'John',
lastName: 'Doe',
sex: SexType.m,
),
ContactModel(phone: '+2250700000001', name: 'Jane Doe'),
],
);
get() - Get Contact
final response = await contactApi.get(id: 'contact-id');
update() - Update Contact
final response = await contactApi.update(
id: 'contact-id',
phone: '+2250700000000',
name: 'Updated Name',
firstName: 'John',
lastName: 'Doe',
sex: SexType.m,
);
delete() - Delete Contacts
final response = await contactApi.delete(
contactIds: ['contact-id-1', 'contact-id-2'],
);
Group API
Contact group management.
final groupApi = monSmsPro.group;
list() - List Groups
final response = await groupApi.list(
count: 20,
page: 1,
sort: SortList.desc,
orderBy: 'createdAt',
);
// Response: List<GroupModel>
create() - Create Group
final response = await groupApi.create(
name: 'VIP Customers',
contacts: [
ContactModel(phone: '+2250700000000', name: 'John'),
ContactModel(phone: '+2250700000001', name: 'Jane'),
],
);
get() - Get Group
final response = await groupApi.get(id: 'group-id');
update() - Update Group
final response = await groupApi.update(
id: 'group-id',
name: 'Updated Group Name',
contacts: [...],
);
delete() - Delete Group
final response = await groupApi.delete(id: 'group-id');
Sender API
Sender ID management.
final senderApi = monSmsPro.sender;
list() - List Senders
final response = await senderApi.list(
count: 20,
page: 1,
);
// Response: List<SenderModel>
create() - Create Sender
final response = await senderApi.create(
name: 'MySender', // Required: Max 11 characters
description: 'My business', // Required
);
// Note: Sender requires approval before use
// Status: PENDING -> SUBMITED -> ACCEPTED/REFUSED
get() - Get Sender
final response = await senderApi.get(id: 'sender-id');
update() - Archive/Restore Sender
final response = await senderApi.update(
id: 'sender-id',
archived: true, // Archive the sender
);
Transaction API
Payment and transaction management.
final transactionApi = monSmsPro.transaction;
list() - List Transactions
final response = await transactionApi.list(
count: 20,
page: 1,
companyId: 'company-id', // Optional
);
// Response: List<TransactionModel>
create() - Create Transaction
final response = await transactionApi.create(
offerId: 'offer-id',
paymentMethod: PaymentMethod.omCi, // OM_CI, MTN_CI, MOOV_CI, WAVE_CI, etc.
companyId: 'company-id', // Optional
);
check() - Check Transaction Status
final response = await transactionApi.check(id: 'transaction-id');
// Response
TransactionModel(
status: TransactionStatus.charged, // PENDING, FAILED, CHARGED
credit: 100,
price: 5000,
)
update() - Update Transaction
final response = await transactionApi.update(
id: 'transaction-id',
status: TransactionStatus.charged,
);
Offer API
Credit offers/packages.
final offerApi = monSmsPro.offer;
list() - List Offers
final response = await offerApi.list();
// Response: List<OfferModel>
// Offers: STARTER, BRONZE, FER, OR, DIAMANT, VIP
get() - Get Offer
final response = await offerApi.get(id: 'offer-id');
// Response
OfferModel(
id: '...',
name: OfferName.bronze,
price: 5000, // Price in XOF
credit: 100, // SMS credits
)
Device API
Device registration and management.
final deviceApi = monSmsPro.device;
get() - Get Device
final response = await deviceApi.get(
deviceId: 'unique-device-id',
);
register() - Register Device
final response = await deviceApi.register(
deviceId: 'unique-device-id',
type: DeviceType.android, // ANDROID, IOS, WEB
notificationToken: 'fcm-token', // Optional: For push notifications
companyId: 'company-id', // Optional
);
updateToken() - Update Notification Token
final response = await deviceApi.updateToken(
deviceId: 'unique-device-id',
notificationToken: 'new-fcm-token',
);
delete() - Delete Device
final response = await deviceApi.delete(id: 'device-id');
Company API
Company/business management.
final companyApi = monSmsPro.company;
list() - List User's Companies
final response = await companyApi.list();
// Response: List<CompanyModel>
listTypes() - List Company Types
final response = await companyApi.listTypes();
// Response: List<CompanyTypeModel>
get() - Get Company
final response = await companyApi.get(id: 'company-id');
// Response
CompanyModel(
id: '...',
name: 'My Business',
verificationStatus: CompanyVerificationStatus.approved,
)
create() - Create Company
final response = await companyApi.create(
name: 'My Business',
companyTypeId: 'type-id',
description: 'Business description', // Optional
logo: 'base64-or-url', // Optional
address: '123 Main St', // Optional
city: 'Abidjan', // Optional
);
update() - Update Company
final response = await companyApi.update(
id: 'company-id',
name: 'Updated Name',
description: 'New description',
);
AI API
AI-powered message optimization and URL shortening.
final aiApi = monSmsPro.ai;
shortenUrl() - Shorten URLs in Message
final response = await aiApi.shortenUrl(
message: 'Check out https://example.com/very/long/url',
);
// Response
AIUrlResponse(
original: 'Check out https://example.com/very/long/url',
processed: 'Check out https://short.url/abc',
)
optimizeMessage() - AI Message Optimization
Uses AI to optimize SMS messages for length and clarity.
final response = await aiApi.optimizeMessage(
message: 'Your long message here...',
language: 'fr', // Target language
abbreviation: true, // Optional: Use abbreviations
latinize: true, // Optional: Remove accents
);
// Response: String (optimized message)
processMessage() - Process Message (Legacy)
final response = await aiApi.processMessage(
message: 'Message with URLs',
);
Challenges API
Gamification challenges system.
final challengesApi = monSmsPro.challenges;
list() - List Challenges
final response = await challengesApi.list(
companyId: 'company-id',
type: ChallengeType.weekly, // Optional: WEEKLY, MONTHLY, SPECIAL
status: ChallengeStatus.active, // Optional: UPCOMING, ACTIVE, ENDED
);
// Response: List<ChallengeModel>
get() - Get Challenge Details
final response = await challengesApi.get(
id: 'challenge-id',
companyId: 'company-id',
);
// Response
ChallengeModel(
id: '...',
name: 'Weekly Challenge',
type: ChallengeType.weekly,
status: ChallengeStatus.active,
startDate: DateTime(...),
endDate: DateTime(...),
tasks: [...],
communityRewards: [...],
isJoined: true,
userXp: 500,
userRank: 3,
)
join() - Join Challenge
final response = await challengesApi.join(
id: 'challenge-id',
companyId: 'company-id',
);
leave() - Leave Challenge
final response = await challengesApi.leave(
id: 'challenge-id',
companyId: 'company-id',
);
leaderboard() - Get Leaderboard
final response = await challengesApi.leaderboard(
id: 'challenge-id',
companyId: 'company-id',
);
// Response: List<ChallengeLeaderboardEntryModel>
claimTask() - Claim Task Reward
final response = await challengesApi.claimTask(
id: 'challenge-id',
taskKey: 'send_100_sms',
companyId: 'company-id',
);
claimReward() - Claim Community Reward
final response = await challengesApi.claimReward(
id: 'challenge-id',
rewardIndex: 0,
companyId: 'company-id',
);
Daily Tasks API
Daily gamification tasks.
final dailyTasksApi = monSmsPro.dailyTasks;
list() - List Today's Tasks
final response = await dailyTasksApi.list(
companyId: 'company-id',
);
// Response: List<DailyTaskModel>
// Task types: SMS_SENT, SMS_DELIVERED, CONTACTS_ADDED, etc.
claim() - Claim Task Reward
final response = await dailyTasksApi.claim(
taskKey: 'send_10_sms',
companyId: 'company-id',
);
// Response: int (XP claimed)
getProfile() - Get Game Profile
final response = await dailyTasksApi.getProfile(
companyId: 'company-id',
);
// Response
GameProfileModel(
totalXp: 1500,
level: 5,
currentLevelXp: 300,
xpToNextLevel: 500,
streak: 7,
)
claimBonus() - Claim All-Tasks Bonus
final response = await dailyTasksApi.claimBonus(
companyId: 'company-id',
);
// Response: int (bonus XP)
Follower API
Le Rezo subscription/follower management.
final followerApi = monSmsPro.follower;
get() - Get Follower
final response = await followerApi.get(id: 'follower-id');
getByPhone() - Get Follower by Phone
final response = await followerApi.getByPhone(
phoneNumber: '+2250700000000',
);
update() - Update Follower
final response = await followerApi.update(
id: 'follower-id',
name: 'New Name',
);
updateLogo() - Update Follower Photo
final response = await followerApi.updateLogo(
id: 'follower-id',
logo: 'base64-or-url',
);
following() - List Followed Companies
final response = await followerApi.following(
id: 'follower-id',
);
// Response: List<CompanyFollowedModel>
subscribe() - Subscribe to Company
final response = await followerApi.subscribe(
id: 'follower-id',
companyId: 'company-id',
);
unsubscribe() - Unsubscribe from Company
final response = await followerApi.unsubscribe(
id: 'follower-id',
companyId: 'company-id',
);
getCompanyCampaigns() - Get Company's Campaigns
final response = await followerApi.getCompanyCampaigns(
id: 'follower-id',
companyId: 'company-id',
);
Models
Core Models
| Model | Description |
|---|---|
UserModel |
User profile with credits, verification status |
OTPModel |
OTP token with status and mode |
OfferModel |
Credit package with price and credits |
VersionModel |
App version information |
Campaign Models
| Model | Description |
|---|---|
CampaignModel |
SMS campaign with stats |
CampaignDetailsModel |
Full campaign with contacts, groups, sender |
CampaignCountModel |
Contact and group counts |
CampaignRecurringDayModel |
Recurring schedule configuration |
Contact & Group Models
| Model | Description |
|---|---|
ContactModel |
Contact with phone, name, sex |
GroupModel |
Contact group with members |
GroupCountModel |
Contact count in group |
Company Models
| Model | Description |
|---|---|
CompanyModel |
Business/company profile |
CompanyTypeModel |
Company category type |
VerifyIdModel |
KYC verification record |
Transaction Models
| Model | Description |
|---|---|
TransactionModel |
Payment transaction |
SenderModel |
Sender ID with approval status |
DeviceModel |
Registered device |
Gamification Models
| Model | Description |
|---|---|
ChallengeModel |
Challenge with tasks and rewards |
ChallengeTaskModel |
Individual challenge task |
ChallengeRewardModel |
Community reward |
ChallengeLeaderboardEntryModel |
Leaderboard entry |
DailyTaskModel |
Daily task with progress |
GameProfileModel |
User XP, level, streak |
Le Rezo Models
| Model | Description |
|---|---|
FollowerModel |
Subscriber/follower profile |
CompanyFollowedModel |
Company subscription |
Enums
SMS & Campaign Types
enum SMSType { sms, flash, scheduled, recurring }
enum SmsType { promotional, transactional, otp } // For sender types
Status Enums
enum OTPStatus { pending, verified, demo }
enum OTPMode { numeric, alphabet, alphaNumeric }
enum SenderStatus { pending, submited, accepted, refused }
enum TransactionStatus { pending, failed, charged }
enum TransactionType { debited, recharged }
enum VerifyIdStatus { pending, verified, approved, refused }
enum CompanyVerificationStatus { pending, approved, refused }
Gamification Enums
enum ChallengeType { weekly, monthly, special }
enum ChallengeStatus { upcoming, active, ended }
enum DailyTaskCriteriaType {
smsSent, smsDelivered, contactsAdded,
campaignsCreated, groupsCreated, appOpened, creditPurchased
}
Other Enums
enum PaymentMethod { omCi, mtnCi, moovCi, waveCi, cash, iap, builtIn, otp }
enum DeviceType { android, ios, web }
enum OfferName { starter, bronze, fer, or, diamant, vip }
enum SexType { m, f }
enum Country { ci }
enum TransactionPeriod { year, month, week, day, none }
Hive Database Management
This SDK uses Hive for local data caching.
Initialize Hive
import 'package:mon_sms_pro/mon_sms_pro.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initHiveAdapters();
runApp(MyApp());
}
Quick Commands
# Update Hive registrars and build adapters
make hive-full
# Watch for changes
make hive-watch
# Clean build cache
make hive-clean
Regenerate Adapters
dart run build_runner build --delete-conflicting-outputs
Error Handling
All API methods return ApiResponseModel<T>:
final response = await monSmsPro.user.details();
if (response.success) {
final user = response.data;
print('User: ${user?.fullName}');
} else {
print('Error: ${response.error}');
}
API Key
Get your API key from the Mon SMS PRO app in Settings.
Documentation
Visit docs.monsms.pro for more information.
Support
For issues and feature requests, visit our GitHub repository.
License
MIT License - see LICENSE file for details.
Libraries
- apis/ai_api
- apis/campaign_api
- apis/challenges_api
- apis/company_api
- apis/contact_api
- apis/daily_tasks_api
- apis/device_api
- apis/follower_api
- apis/group_api
- apis/offer_api
- apis/otp_api
- apis/sender_api
- apis/transaction_api
- apis/user_api
- models/api_response_model
- models/campaign/campaign_count_model
- models/campaign/campaign_details_model
- models/campaign/campaign_model
- models/campaign/campaign_recurring_day_model
- models/company/company_model
- models/company/verify_id_model
- models/contact/contact_model
- models/core/import_model
- models/core/offer_model
- models/core/otp_model
- models/core/user_model
- models/core/version_model
- models/device/device_model
- models/gamification/challenge_model
- models/gamification/daily_task_model
- models/gamification/game_profile_model
- models/group/group_count_model
- models/group/group_model
- models/hive_registrar
- models/init_hive_adapters
- models/lerezo/company_followed_model
- models/lerezo/company_type_model
- models/lerezo/follower_model
- models/models
- models/sender/sender_model
- models/template/template_model
- models/transaction/transaction_model
- models/utils
- mon_sms_pro
- payload/core/base_payload
- payload/core/list_payload