Drafts: create (including a threaded reply draft for a human to review), update, send, list, get, delete. Messages are built with ::google::gmail::mime and switch to the media-upload endpoint above 5 MiB, as for sending.

Scopes. gmail.compose for everything except reads, which use gmail.readonly. create-reply-draft also reads the original (gmail.readonly).

Functions

create-draft

fn (message: Map): Map
fn (message: Map, opts: Map): Map

POST /users/me/drafts - save a draft from a message Map (same fields as ::google::gmail::messages/send). Options: thread-id, upload. Returns {id, message: {id, threadId, labelIds}}. Scope: gmail.compose.

create-reply-draft

fn (message-id: Str, reply: Map): Map
fn (message-id: Str, reply: Map, opts: Map): Map

Draft a reply to a message, threaded and addressed like ::google::gmail::messages/reply, for a person to review and send. all: true in opts drafts a reply-all. Scopes: gmail.readonly and gmail.compose.

draft ::google::gmail::drafts/create-reply-draft(email.id, {text: "Proposed answer..."})

delete-draft

fn (draft-id: Str): Bool
fn (draft-id: Str, opts: Map): Bool

DELETE /users/me/drafts/{id} - discard a draft (immediately and permanently; it does not go to the trash). Returns true. Scope: gmail.compose.

draft-body

fn (raw: Bytes, thread-id: Str?, draft-id: Str?): Map

The JSON body for drafts.create / drafts.update (pure): {id?, message: {raw, threadId?}}.

get-draft

fn (draft-id: Str): Map
fn (draft-id: Str, opts: Map): Map

GET /users/me/drafts/{id} - a draft with its message. Options: format (full default, metadata, minimal, raw). Scope: gmail.readonly.

list-all-drafts

fn (opts: Map): Vec
fn (opts: Map, limit: Int?): Vec

Every draft (all pages), or at most limit. Scope: gmail.readonly.

list-drafts

fn (): Map
fn (opts: Map): Map

GET /users/me/drafts - one page of drafts: {drafts: [{id, message: {id, threadId}}], nextPageToken?}. Options: q, maxResults (max 500), pageToken, includeSpamTrash. Scope: gmail.readonly.

save-draft

fn (method: Str, path: Str, message: Map, draft-id: Str?, opts: Map): Map

send-draft

fn (draft-id: Str): Map
fn (draft-id: Str, opts: Map): Map

POST /users/me/drafts/send - send an existing draft as is. Returns the sent message; the draft is removed. Scope: gmail.compose.

update-draft

fn (draft-id: Str, message: Map): Map
fn (draft-id: Str, message: Map, opts: Map): Map

PUT /users/me/drafts/{id} - replace a draft's message (all fields; Gmail keeps nothing from the old one). Options: thread-id, upload. Scope: gmail.compose.