mautic_api 1.0.4 copy "mautic_api: ^1.0.4" to clipboard
mautic_api: ^1.0.4 copied to clipboard

outdated

Dart and Flutter Package Wrapper for Native Mautic REST API using Basic Authentication

Dart Mautic API #

Mautic API Wrapper for Dart and Flutter

Installing #

Add this to your package's pubspec.yaml file:

dependencies:
  mautic_api: any

Run flutter pub get on terminal to download and install packages and import on your files:

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:

  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.

  var user = await api.getCurrentUser();

Here a complete example to get current user info:

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

Avaiable Endpoints #

MauticAPI #

The class MauticAPI provide a constructor with 3 arguments:

Sample usage:

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 package to get default app cache directory.

The class MauticAPI has following attributes:

  /// Request Has Success?
  bool hasSuccess = false;

  /// Current Mautic Version?
  String mauticVersion;

  /// Is Data Read from Cache?
  bool isCachedData = false;

The class MauticAPI has following methods:

/// Return Current User
Future<MauticUser> getCurrentUser();

/// Return User by ID
Future<MauticUser> getUserByID(int _id);

/// Return All Users
Future<List<MauticUser>> getUsers();

/// Return Contact by ID
Future<MauticContact> getContactByID(int _id);

/// Return All Contacts
Future<List<MauticContact>> getContacts({int page = 0, String s = 'email:'});

MauticUser #

Class MauticUser has folowing attributes:

  /// 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 has folowing attributes:

  /// 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 has folowing methods:

  /// Return Gravatar URL
  String gravatarUrl({int size = 96});
1
likes
0
pub points
0%
popularity

Publisher

verified publisherpowertic.com

Dart and Flutter Package Wrapper for Native Mautic REST API using Basic Authentication

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

convert, crypto, http, meta

More

Packages that depend on mautic_api