mandrill 1.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 49

Mandrill API #

This is a native dart implementation of a Mandrill API client.

It's not a fork of the other mandrill_api package, because the other library is quite old, unmaintained and not very suitable to be ported to Dart 2.0

Usage #

import 'package:mandrill/mandrill_server.dart';
// or if you're in the browser:
// import 'package:mandrill/mandrill_browser.dart';

final apiKey = 'your-key';

main() async {
  final mandrill = createMandrill(apiKey);

  final recipients = [
    new Recipient(email: 'customer1@example.com', name: 'Customer 1'),
    new Recipient(email: 'customer2@example.com', name: 'Customer 2', type: RecipientType.bcc),
  ];

  final message = new OutgoingMessage(
    html: '<h1>Welcome to our website</h1>',
    text: 'WELCOME TO OUR WEBSITE',
    to: recipients,
    /* etc... */
  );

  final response = await mandrill.messages.send(message);
}

For a full example, please see example/example.dart.

Stability #

This library is meant to be rock solid, using Codable to (de)serialize JSON messages, well tested and used in production.

Completeness #

We have only implemented a subset of the full API calls, because we don't need the other calls right now.

To see which API calls have been implemented, please check the API Documentation.

If you need other resources to be implemented we are happy to accept Merge Requests, but we are also willing to add new resources if requested.

License #

MIT

Changelog #

1.1.2 #

  • Upgrade dependencies.

1.1.1 #

  • Make Recipient.name optional.

1.1.0 #

  • Expose package:mandrill/mandrill.dart in package:mandrill/mandrill_server.dart so users of this library don't need to import both files.

1.0.1 #

  • Add analysis_options.yaml and fix all errors, warnings and hints.

1.0.0 #

  • Initial release of the library

example/example.dart

import 'package:logging/logging.dart';
import 'package:mandrill/mandrill_server.dart';

const apiKey = 'your-key';

void main() async {
  Logger.root
    ..level = Level.ALL
    ..onRecord.listen(print);

  final log = new Logger('Mandrill Example');

  final mandrill = createMandrill(apiKey);

  final recipients = [
    new Recipient(email: 'customer1@example.com', name: 'Customer 1'),
    new Recipient(
        email: 'customer2@example.com',
        name: 'Customer 2',
        type: RecipientType.bcc),
  ];

  final message = new OutgoingMessage(
    html: '<h1>Welcome to our website</h1>',
    text: 'WELCOME TO OUR WEBSITE',
    fromEmail: 'good@website.com',
    fromName: 'Greatest Website',
    to: recipients,
    important: true,
  );

  try {
    final response = await mandrill.messages.send(message);
    log.info('${response.sentMessages.length} messages have been sent.');
  } on MandrillException catch (e) {
    log.severe(e.toString());
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  mandrill: ^1.1.2

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:mandrill/mandrill.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
15
Health:
Code health derived from static analysis. [more]
77
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
49
Learn more about scoring.

We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Health suggestions

Fix lib/exceptions.dart. (-13.96 points)

Analysis of lib/exceptions.dart reported 30 hints, including:

line 11 col 16: Unnecessary new keyword.

line 13 col 16: Unnecessary new keyword.

line 15 col 16: Unnecessary new keyword.

line 17 col 16: Unnecessary new keyword.

line 19 col 16: Unnecessary new keyword.

Fix lib/client/client.dart. (-5.36 points)

Analysis of lib/client/client.dart reported 11 hints, including:

line 18 col 16: Use = to separate a named parameter from its default value.

line 19 col 14: Use = to separate a named parameter from its default value.

line 20 col 14: Use = to separate a named parameter from its default value.

line 21 col 20: Use = to separate a named parameter from its default value.

line 22 col 17: Use = to separate a named parameter from its default value.

Fix lib/src/resources/messages.dart. (-1.99 points)

Analysis of lib/src/resources/messages.dart reported 4 hints:

line 27 col 19: Use = to separate a named parameter from its default value.

line 38 col 53: Unnecessary new keyword.

line 54 col 19: Use = to separate a named parameter from its default value.

line 68 col 41: Unnecessary new keyword.

Fix additional 4 files with analysis or formatting issues. (-3 points)

Additional issues in the following files:

  • lib/messages.dart (2 hints)
  • lib/src/messages/messages.dart (2 hints)
  • lib/mandrill.dart (1 hint)
  • lib/mandrill_server.dart (1 hint)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (intl).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <3.0.0
codable ^1.0.0 1.0.0
http >=0.11.0 <0.13.0 0.12.0+2
intl ^0.15.0 0.15.8 0.16.0
logging ^0.11.0 0.11.3+2
meta ^1.1.6 1.1.8
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
path 1.6.4
pedantic 1.9.0
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
grind_publish ^0.0.5
grinder ^0.8.3
mockito ^4.0.0
test ^1.3.0