m8ty_client_securemails
Package overview
Section titled “Package overview”m8ty_client_securemails solves this by providing a typed secure-mail interface for sending, reading, organizing, and deleting messages and attachments within the app.
Secure Mail client to manage message exchanges with the end user.
Before you start
Section titled “Before you start”Check the documentation of the m8ty_client_securemails library to get an idea about the available models and their properties.
Import all needed libraries
Section titled “Import all needed libraries” import 'package:dio/dio.dart'; import 'package:m8ty_client_securemails/m8ty_client_securemails.dart'; import 'package:m8ty_client_common/m8ty_client_common.dart'; import 'package:built_collection/built_collection.dart';Client Setup
Section titled “Client Setup”final client = M8tyClientSecuremails();client.setOAuthToken('ApiOAuth2', oauthToken);API Surface
Section titled “API Surface”SecureMailApi
Section titled “SecureMailApi”| Method | Description |
|---|---|
createNewSecureMail |
Create new secure mail message |
getSecureMailById |
Get secure mail by id |
searchSecureMail |
Get user secure mail messages |
deleteSecureMail |
Delete secure mail by id |
bulkDeleteSecureMail |
Delete multiple secure mails |
markSecureMailsAsRead |
Mark secure mails as read by the user |
getAllSecureMailRecipients |
Get all possible contacts to send secure mail to |
AttachmentsApi
Section titled “AttachmentsApi”| Method | Description |
|---|---|
getSecureMailAttachmentById |
Get a specific secure mail message attachment |
How to perform different tasks
Section titled “How to perform different tasks”Here some examples how the dart client can be used
Create a new secure mail
Section titled “Create a new secure mail” final client = M8tyClientSecuremails(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getSecureMailApi(); final Response<SecureMailModel> model = await api.createNewSecureMail( subject: "My message", content: "Here the content of my message", );Get secure mail by id
Section titled “Get secure mail by id” final client = M8tyClientSecuremails(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getSecureMailApi(); final Response<SecureMailModel> secureMail = await api.getSecureMailById(secureMailId: "12345");Delete secure mail by id
Section titled “Delete secure mail by id” final client = M8tyClientSecuremails(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getSecureMailApi(); await api.deleteSecureMail(secureMailId: "12345");Get secure mail attachment by id
Section titled “Get secure mail attachment by id” final client = M8tyClientSecuremails(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getAttachmentsApi();
try { final Response<Uint8List> secureMailAttachment = await api.getSecureMailAttachmentById( secureMailId: "12345", attachmentId: "789", );
File file = File("/temp/myfile"); await file.writeAsBytes(secureMailAttachment.data!); } on DioException catch (e) { throw Exception( 'Request failed (status: ${e.response?.statusCode}): ${e.response?.data}', ); }Search for secure mails
Section titled “Search for secure mails” final client = M8tyClientSecuremails(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getSecureMailApi();
SearchSecureMailRequestModel secureMailRequestModel = SearchSecureMailRequestModel((b) => b ..readStatus = ReadStatusModel.UNREAD ..customerId = "123" ..subject = "My message" ..dateSentFrom = DateTime.now().add(Duration(days: 5)), );
final Response<SecureMailPageModel> searchResult = await api.searchSecureMail( searchSecureMailRequestModel: secureMailRequestModel, );© m8ty GmbH 2023 · m8ty.eu
