Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/powerticmkt/dart-mautic-api
Mautic API Wrapper for Dart and Flutter
https://github.com/powerticmkt/dart-mautic-api
api dart flutter flutter-package mautic
Last synced: about 1 month ago
JSON representation
Mautic API Wrapper for Dart and Flutter
- Host: GitHub
- URL: https://github.com/powerticmkt/dart-mautic-api
- Owner: powerticmkt
- License: gpl-3.0
- Created: 2020-01-09T16:01:17.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-12T17:18:15.000Z (almost 5 years ago)
- Last Synced: 2024-08-20T14:22:03.595Z (3 months ago)
- Topics: api, dart, flutter, flutter-package, mautic
- Language: Dart
- Homepage: https://pub.dev/packages/mautic_api
- Size: 63.5 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mautic - powerticmkt/mautic_api - Mautic API Wrapper for Dart and Flutter. Also listed at [pub.dev](https://pub.dev/packages/mautic_api) (Libraries)
README
# Dart Mautic API
Mautic API Wrapper for Dart and Flutter
## Installing
Add this to your package's pubspec.yaml file:
```yaml
dependencies:
mautic_api: any
```Run `flutter pub get` on terminal to download and install packages and import on your files:
```dart
import 'package:mautic_api/mautic_api.dart';
```## Basic Usage
You can create a new instance of class `MauticAPI` with 3 arguments: `base_url`, `username` and `password`:
```dart
final api = MauticAPI('https://yourmauticaddress.com', 'username', 'password');
```To test your credentials you can call `getCurrentUser()` to get your `MauticUser`. If the credentials fail the method return `null`.
```dart
var user = await api.getCurrentUser();
```Here a complete example to get current user info:
```dart
import 'package:mautic_api/mautic_api.dart';void main() async {
///
final api =
MauticAPI('https://yourmauticaddress.com', 'username', 'password');var user = await api.getCurrentUser();
print(user.id);
print(user.firstName);
print(user.lastName);
print(user.email);
print(user.onlineStatus);
}
```## Available Endpoints
### MauticAPI
The class [`MauticAPI`](https://github.com/powerticmkt/dart-mautic-api/blob/master/lib/src/mautic_api.dart) provides a constructor with 3 arguments:
- `base_url`: Your Mautic URL (eg: https://yourmauticaddress.com)
- `username`: Your Mautic Username
- `password`: Your Mautic PasswordSample usage:
```dart
var api = MauticAPI('https://yourmauticaddress.com', 'username', 'password');
```There are also two optional arguments to handle cache:
- `localPath`: The Path for cache directory (default: `./tmp`)
- `localExpiresMinutes`: Time to Expire cache in minutes (default: 5)On Flutter you can use the [`path_provider`](https://pub.dev/packages/path_provider) package to get default app cache directory.
The class [`MauticAPI`](https://github.com/powerticmkt/dart-mautic-api/blob/master/lib/src/mautic_api.dart) has following attributes:
```dart
/// Request Has Success?
bool hasSuccess = false;/// Current Mautic Version?
String mauticVersion;/// Is Data Read from Cache?
bool isCachedData = false;
```The class [`MauticAPI`](https://github.com/powerticmkt/dart-mautic-api/blob/master/lib/src/mautic_api.dart) has following methods:
```dart
/// Return Current User
Future getCurrentUser();/// Return User by ID
Future getUserByID(int _id);/// Return All Users
Future> getUsers();/// Return Contact by ID
Future getContactByID(int _id);/// Return All Contacts
Future> getContacts({ int page = 0, String s = 'email:%@%', String ob = 'last_active', String od = 'desc', int limit = 5});/// Return the number of identified contacts
Future getTotalContacts();/// Return the number of pagination of contacts
Future getContactsPagination({int limit = 30});/// Return All Emails
Future> getEmails({ int page = 0, String s = '', String ob = 'id', String od = 'desc', int limit = 30});/// Return Contact by ID
Future getEmailByID(int _id);/// Return the number of emails
Future getTotalEmails();/// Return the number of pagination of emails
Future getEmailsPagination({int limit = 30});
```### MauticUser
Class [`MauticUser`](https://github.com/powerticmkt/dart-mautic-api/blob/master/lib/src/mautic_user.dart) has the following attributes:
```dart
/// User ID
final int id;/// User First Name
final String firstName;/// User Last Name
final String lastName;/// User Email
final String email;/// User Online Status
final String onlineStatus;
```### MauticContact
Class [`MauticContact`](https://github.com/powerticmkt/dart-mautic-api/blob/master/lib/src/mautic_contact.dart) has the following attributes:
```dart
/// Contact ID
final int id;/// Contact First Name
final String firstName;/// Contact Last Name
final String lastName;/// Contact Email
final String email;/// Contact Points
final int points;/// Contact Date Added
final DateTime dateAdded;/// Contact Date Last Active
final DateTime dateLastActive;/// Contact Date Identified
final DateTime dateIdentified;/// Return if Contact is Identified
bool get isIdentified;
```Class [`MauticContact`](https://github.com/powerticmkt/dart-mautic-api/blob/master/lib/src/mautic_contact.dart) has the following methods:
```dart
/// Return Gravatar URL
String gravatarUrl({int size = 96});
```### MauticEmail
Class [`MauticEmail`](https://github.com/powerticmkt/dart-mautic-api/blob/master/lib/src/mautic_email.dart) has the following attributes:
```dart
final int id;final bool isPublished;
final String name;
final String subject;
final String fromAddress;
final String fromName;
final String replyToAddress;
final String customHtml;
final String plainText;
final String template;
final String emailType;
final String language;
final DateTime publishUp;
final DateTime publishDown;
final int readCount;
final int sentCount;
double readRate;
bool hasTextPlain;
```