A JMAP client library in Dart to make JMAP method calls and process the responses

Overview

JMAP Dart client

A JMAP client library to make JMAP method calls and process the responses.

We most notably use it to write the TMail Flutter application but you might reuse this library to write your own JMAP application.

We do welcome all contributions, given decent test coverage and acceptable code quality.

Please report any problem, any feature request, or discuss how you plan to use this lib in the repository issues.

Code samples

GetSession:

// create instance of httpClient with Dio
// using BasicAuth to config Dio
final httpClient = HttpClient(Dio());

final getSessionBuilder = GetSessionBuilder(httpClient);
final session = await getSessionBuilder.build().execute();

Fetching mailboxes

final processingInvocation = ProcessingInvocation();
final jmapRequestBuilder = JmapRequestBuilder(httpClient, processingInvocation);

final getMailboxMethod = GetMailboxMethod(accountId)
  ..addProperties(Properties({'role', 'name'}));

final queryInvocation = jmapRequestBuilder.invocation(getMailboxMethod);

final responseObject = await (jmapRequestBuilder
    ..usings(getMailboxCreated.requiredCapabilities))
  .build()
  .execute();

final getMailboxResponse = responseObject.parse<GetMailboxResponse>(
  queryInvocation.methodCallId,
  GetMailboxResponse.deserialize);

Get emails in Mailbox

final processingInvocation = ProcessingInvocation();

final jmapRequestBuilder = JmapRequestBuilder(httpClient, processingInvocation);

final queryEmailMethod = QueryEmailMethod(accountId)
  ..addPosition(0)
  ..addLimit(UnsignedInt(20))
  ..addSorts({EmailComparator(EmailComparatorProperty.sentAt)..setIsAscending(false)})
  ..addFilters(EmailFilterCondition(inMailbox: inBoxId));

final queryEmailInvocation = jmapRequestBuilder.invocation(queryEmailMethod);

final getEmailMethod = GetEmailMethod(accountId)
  ..addProperties(Properties({'id', 'subject','from', 'keywords', 'sentAt', 'preview', 'hasAttachment'}))
  ..addReferenceIds(processingInvocation.createResultReference(
    queryEmailInvocation.methodCallId,
    ReferencePath.idsPath));

final getEmailInvocation = jmapRequestBuilder.invocation(getEmailMethod);

final responseObject = await (jmapRequestBuilder
    ..usings(getEmailMethod.requiredCapabilities))
  .build()
  .execute();

final getEmailResponse = responseObject.parse<GetEmailResponse>(
    getEmailInvocation.methodCallId, 
    GetEmailResponse.deserialize);
Comments
  • Implement List Email in Mailbox

    Implement List Email in Mailbox

    • [x] Parsing GetEmailMethod
    • [x] Parsing QueryEmailMethod
    • [x] Parsing GetEmailResponse
    • [x] Parsing QueryEmailResponse
    • [x] Implement unit test GetListEmail on docker
    opened by dab246 3
  • Upgrade flutter version

    Upgrade flutter version

    Just trying to upgrade dependencies to their latest version. Quite some drastic change regarding the flutter sdk and dart sdk as well that need to be bumped up (as some libs upgrade are depending on dart 2.14) so that's why I bump up the version of this lib as well at the end (you have the right to disagree).

    opened by Arsnael 1
  • Get session

    Get session

    • [x] parsing capabilities
    • [x] parsing account
    • [x] parsing primary account
    • [x] test for session class
    • [x] test for capabilities converter

    @dab246 @chibenwa please review it

    opened by hoangdat 1
  • Support `Team-Mailboxes`

    Support `Team-Mailboxes`

    Issues

    • https://github.com/linagora/tmail-flutter/issues/1332

    Resolved

    • [x] Implement Team-mailboxes for GetMailbox method
    • [x] Write unit test for GetMailbox method
    opened by dab246 0
  • Change `newState` in `SetResponse` can take null value

    Change `newState` in `SetResponse` can take null value

    Issues

    • SetResponse has newState null on server FastMail

    Resolved

    • Tested with CRUD identity on FastMail

    https://user-images.githubusercontent.com/80730648/192410851-ed1bc43c-7fdd-4116-a89b-a93acd19fb82.mov

    opened by dab246 0
  • [Fastmail interoperation] Parsing Error-Method response

    [Fastmail interoperation] Parsing Error-Method response

    Fastmail

    https://user-images.githubusercontent.com/6462404/191409055-50713239-22d2-4c1b-b1df-09b762134512.mov

    Tmail

    https://user-images.githubusercontent.com/6462404/191412315-fccfe12e-d79e-480a-b7fd-aae68167610a.mov

    opened by hoangdat 0
Owner
LINAGORA
💻 🌎 Our mission is to invent and develop ethical and open-source Good Tech - Join Us! ✌️
LINAGORA
Provides null-safety implementation to simplify JSON data handling by adding extension method to JSON object

Lazy JSON Provides null-safety implementation to simplify JSON data handling by adding extension method to JSON object and JSON array. Getting started

Kinnara Digital Studio 0 Oct 27, 2021
The diozz package helps you to deal with APIs easily and speed up the process of writing code.

Diozz The diozz package helps you to deal with APIs easily and speed up the process of writing code. Installation Diozz Use that command in the termin

Mohamed Abu.elezz 4 Nov 13, 2022
Utility to process H264 profile-level-id values

h264_profile_level_id Dart utility to process H264 profile-level-id values based on Google's libwebrtc C++ code. API import 'package:h264_profile_leve

Ibragim Abbasov 2 Apr 22, 2022
Application that simplifies the search process in several supermarkets, allowing the user to define the shopping list in a few minutes.

economiz Application that solves the price research process in different supermarkets, facilitating and simplifying this process for the user. Getting

Guilherme Henrique 1 Dec 29, 2021
Library for help you make userbot or bot telegram and support tdlib telegram database and only support nodejs dart and google-apps-script

To-Do telegram client dart ✅️ support multi token ( bot / userbot ) ✅️ support bot and userbot ✅️ support telegram-bot-api local server ✅️ support tel

Azka Full Snack Developer:) 73 Jan 7, 2023
This library contains methods that make it easy to consume Mpesa Api.

This library contains methods that make it easy to consume Mpesa Api. It's multi-platform, and supports CLI, server, mobile, desktop, and the browser.

Eddie Genius 3 Dec 15, 2021
A Flutter library to make Rest API clients more easily. Inspired by Java Feing.

A Flutter library to make Rest API clients more easily. Inspired by Java Feing. Features Facilitated JSON encode and decode using common interfaces. F

null 2 Mar 15, 2022
Contains utility functions and classes in the style of dart:collection to make working with collections easier

The collection package for Dart contains a number of separate libraries with utility functions and classes that makes working with collections easier.

Dart 273 Dec 27, 2022
A simple, unofficial AWS Polly client in dart. Supports generating a URL given an input text and voice identifier.

Flutter AWS Polly Plugin This plugin is a Flutter wrapper for AWS Polly which is a cloud service that converts text into lifelike speech. Getting Star

null 4 Aug 20, 2022
Future based HTTP client for the Dart and Flutter

Uno Future based HTTP client for the Dart and Flutter. Uno, inspired by Axios, bringing a simple and robust experience to the crossplatform apps in Fl

Flutterando 56 Dec 16, 2022
Utilities to make working with 'Duration's easier.

duration Utilities to make working with 'Duration's easier. NOTE: Use prettyDuration, prettySeconds, prettyMilliseconds instead of printDuration, prin

null 45 Sep 21, 2022
A pure Dart implementation of the Pusher Channels Client

pusher_channels is a pure Dart pusher channels client. This client is work in progress and it is unstable. Usage A simple usage example: import 'packa

Indaband 7 Nov 6, 2022
The Dart Time Machine is a date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.

The Dart Time Machine is a date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.

null 2 Oct 8, 2021
An http request client, which supports Manageable Requests Cancellation, Request Policy (Timeout and Retry), Easier Multipart Requests, etc.

A wrapper around Dart's http package, which supports Manageable Requests Cancellation, Request Policy (Timeout and Retry), Easier Multipart Requests, Error Handling, etc.

Iandi Santulus 5 Oct 10, 2021
An example todo list back end project that uses gRPC for client-server communication and Firestore for data storage

An example todo list back end project that uses gRPC for client-server communication and Firestore for data storage

Lucas Coelho 2 Apr 18, 2022
A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

Julien Scholz 10 Oct 26, 2022
A Dart library to parse Portable Executable (PE) format

pefile A Dart library to parse Portable Executable (PE) format Usage A simple usage example: var pe = pefile.parse('C:\\Windows\\System32\\notepad.exe

null 4 Sep 12, 2022
An alternative random library for Dart.

Randt Randt library for Dart... Description Use Randt to get a random integer from a list, generate random integer in a specific range and generate ra

Bangladesh Coding Soldierz 3 Nov 21, 2021
A comprehensive, cross-platform path manipulation library for Dart.

A comprehensive, cross-platform path manipulation library for Dart. The path package provides common operations for manipulating paths: joining, split

Dart 159 Dec 29, 2022