-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget-mailbox-list
executable file
·77 lines (74 loc) · 2.02 KB
/
get-mailbox-list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
#
# Get the account's mailbox list.
#
# Syntax:
#
# get-mailbox-list <token> <account_id>
#
# # JMAP Specification
#
# https://www.rfc-editor.org/rfc/rfc8621.html
#
# ## 2. Mailboxes
#
# A Mailbox represents a named set of Email objects. This is the
# primary mechanism for organising messages within an account. It is
# analogous to a folder or a label in other systems. A Mailbox may
# perform a certain role in the system; see below for more details.
#
# For compatibility with IMAP, an Email MUST belong to one or more
# Mailboxes. The Email id does not change if the Email changes
# Mailboxes.
#
# A *Mailbox* object has the following properties:
#
# * id: "Id" (immutable; server-set).
#
# The id of the Mailbox.
#
# * name: "String"
#
# User-visible name for the Mailbox, e.g., "Inbox". This MUST be a
# Net-Unicode string [RFC5198] of at least 1 character in length,
# subject to the maximum size given in the capability object. There
# MUST NOT be two sibling Mailboxes with both the same parent and
# the same name. Servers MAY reject names that violate server
# policy (e.g., names containing a slash (/) or control characters).
#
# * etc.
#
# The following JMAP methods are supported.
#
# ## 2.1. Mailbox/get
#
# This is a standard "/get" method as described in [RFC8620],
# Section 5.1. The "ids" argument may be "null" to fetch all at once.
#
set -euf
. "$(dirname "$(readlink -f "$0")")/unix-shell-script-kit"
command_exists_or_die curl
if [ "$#" -ne 2 ]; then
die "$EXIT_USAGE" "Usage: get-mailbox-list <token> <account_id>"
fi
token="$1"
account_id="$2"
curl \
--header 'Content-Type: application/json; charset=utf-8' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer '"$token" \
--request POST \
--data '
{
"using": [
"urn:ietf:params:jmap:core",
"urn:ietf:params:jmap:mail"
],
"methodCalls": [[
"Mailbox/get", {
"accountId": "'"$account_id"'"
},
""
]]
}' \
'https://api.fastmail.com/jmap/api/'