forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogle-apps-script.gmail.d.ts
205 lines (197 loc) · 8.13 KB
/
google-apps-script.gmail.d.ts
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// Type definitions for Google Apps Script 2015-11-12
// Project: https://developers.google.com/apps-script/
// Definitions by: motemen <https://github.com/motemen/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="google-apps-script.types.d.ts" />
/// <reference path="google-apps-script.base.d.ts" />
declare namespace GoogleAppsScript {
export module Gmail {
/**
* Provides access to Gmail threads, messages, and labels.
*/
export interface GmailApp {
createLabel(name: string): GmailLabel;
deleteLabel(label: GmailLabel): GmailApp;
getAliases(): String[];
getChatThreads(): GmailThread[];
getChatThreads(start: Integer, max: Integer): GmailThread[];
getDraftMessages(): GmailMessage[];
getInboxThreads(): GmailThread[];
getInboxThreads(start: Integer, max: Integer): GmailThread[];
getInboxUnreadCount(): Integer;
getMessageById(id: string): GmailMessage;
getMessagesForThread(thread: GmailThread): GmailMessage[];
getMessagesForThreads(threads: GmailThread[]): GmailMessage[][];
getPriorityInboxThreads(): GmailThread[];
getPriorityInboxThreads(start: Integer, max: Integer): GmailThread[];
getPriorityInboxUnreadCount(): Integer;
getSpamThreads(): GmailThread[];
getSpamThreads(start: Integer, max: Integer): GmailThread[];
getSpamUnreadCount(): Integer;
getStarredThreads(): GmailThread[];
getStarredThreads(start: Integer, max: Integer): GmailThread[];
getStarredUnreadCount(): Integer;
getThreadById(id: string): GmailThread;
getTrashThreads(): GmailThread[];
getTrashThreads(start: Integer, max: Integer): GmailThread[];
getUserLabelByName(name: string): GmailLabel;
getUserLabels(): GmailLabel[];
markMessageRead(message: GmailMessage): GmailApp;
markMessageUnread(message: GmailMessage): GmailApp;
markMessagesRead(messages: GmailMessage[]): GmailApp;
markMessagesUnread(messages: GmailMessage[]): GmailApp;
markThreadImportant(thread: GmailThread): GmailApp;
markThreadRead(thread: GmailThread): GmailApp;
markThreadUnimportant(thread: GmailThread): GmailApp;
markThreadUnread(thread: GmailThread): GmailApp;
markThreadsImportant(threads: GmailThread[]): GmailApp;
markThreadsRead(threads: GmailThread[]): GmailApp;
markThreadsUnimportant(threads: GmailThread[]): GmailApp;
markThreadsUnread(threads: GmailThread[]): GmailApp;
moveMessageToTrash(message: GmailMessage): GmailApp;
moveMessagesToTrash(messages: GmailMessage[]): GmailApp;
moveThreadToArchive(thread: GmailThread): GmailApp;
moveThreadToInbox(thread: GmailThread): GmailApp;
moveThreadToSpam(thread: GmailThread): GmailApp;
moveThreadToTrash(thread: GmailThread): GmailApp;
moveThreadsToArchive(threads: GmailThread[]): GmailApp;
moveThreadsToInbox(threads: GmailThread[]): GmailApp;
moveThreadsToSpam(threads: GmailThread[]): GmailApp;
moveThreadsToTrash(threads: GmailThread[]): GmailApp;
refreshMessage(message: GmailMessage): GmailApp;
refreshMessages(messages: GmailMessage[]): GmailApp;
refreshThread(thread: GmailThread): GmailApp;
refreshThreads(threads: GmailThread[]): GmailApp;
search(query: string): GmailThread[];
search(query: string, start: Integer, max: Integer): GmailThread[];
sendEmail(recipient: string, subject: string, body: string): GmailApp;
sendEmail(recipient: string, subject: string, body: string, options: Object): GmailApp;
starMessage(message: GmailMessage): GmailApp;
starMessages(messages: GmailMessage[]): GmailApp;
unstarMessage(message: GmailMessage): GmailApp;
unstarMessages(messages: GmailMessage[]): GmailApp;
}
/**
* An attachment from Gmail. This is a regular
* Blob except that it has an extra
* getSize() method that is faster than calling getBytes().length and does
* not count against the Gmail read quota.
*
* // Logs information about any attachments in the first 100 inbox threads.
* var threads = GmailApp.getInboxThreads(0, 100);
* var msgs = GmailApp.getMessagesForThreads(threads);
* for (var i = 0 ; i < msgs.length; i++) {
* for (var j = 0; j < msgs[i].length; j++) {
* var attachments = msgs[i][j].getAttachments();
* for (var k = 0; k < attachments.length; k++) {
* Logger.log('Message "%s" contains the attachment "%s" (%s bytes)',
* msgs[i][j].getSubject(), attachments[k].getName(), attachments[k].getSize());
* }
* }
* }
*/
export interface GmailAttachment {
copyBlob(): Base.Blob;
getAs(contentType: string): Base.Blob;
getBytes(): Byte[];
getContentType(): string;
getDataAsString(): string;
getDataAsString(charset: string): string;
getName(): string;
getSize(): Integer;
isGoogleType(): boolean;
setBytes(data: Byte[]): Base.Blob;
setContentType(contentType: string): Base.Blob;
setContentTypeFromExtension(): Base.Blob;
setDataFromString(string: string): Base.Blob;
setDataFromString(string: string, charset: string): Base.Blob;
setName(name: string): Base.Blob;
getAllBlobs(): Base.Blob[];
}
/**
* A user-created label in a user's Gmail account.
*/
export interface GmailLabel {
addToThread(thread: GmailThread): GmailLabel;
addToThreads(threads: GmailThread[]): GmailLabel;
deleteLabel(): void;
getName(): string;
getThreads(): GmailThread[];
getThreads(start: Integer, max: Integer): GmailThread[];
getUnreadCount(): Integer;
removeFromThread(thread: GmailThread): GmailLabel;
removeFromThreads(threads: GmailThread[]): GmailLabel;
}
/**
* A message in a user's Gmail account.
*/
export interface GmailMessage {
forward(recipient: string): GmailMessage;
forward(recipient: string, options: Object): GmailMessage;
getAttachments(): GmailAttachment[];
getBcc(): string;
getBody(): string;
getCc(): string;
getDate(): Date;
getFrom(): string;
getId(): string;
getPlainBody(): string;
getRawContent(): string;
getReplyTo(): string;
getSubject(): string;
getThread(): GmailThread;
getTo(): string;
isDraft(): boolean;
isInChats(): boolean;
isInInbox(): boolean;
isInTrash(): boolean;
isStarred(): boolean;
isUnread(): boolean;
markRead(): GmailMessage;
markUnread(): GmailMessage;
moveToTrash(): GmailMessage;
refresh(): GmailMessage;
reply(body: string): GmailMessage;
reply(body: string, options: Object): GmailMessage;
replyAll(body: string): GmailMessage;
replyAll(body: string, options: Object): GmailMessage;
star(): GmailMessage;
unstar(): GmailMessage;
}
/**
* A thread in a user's Gmail account.
*/
export interface GmailThread {
addLabel(label: GmailLabel): GmailThread;
getFirstMessageSubject(): string;
getId(): string;
getLabels(): GmailLabel[];
getLastMessageDate(): Date;
getMessageCount(): Integer;
getMessages(): GmailMessage[];
getPermalink(): string;
hasStarredMessages(): boolean;
isImportant(): boolean;
isInChats(): boolean;
isInInbox(): boolean;
isInSpam(): boolean;
isInTrash(): boolean;
isUnread(): boolean;
markImportant(): GmailThread;
markRead(): GmailThread;
markUnimportant(): GmailThread;
markUnread(): GmailThread;
moveToArchive(): GmailThread;
moveToInbox(): GmailThread;
moveToSpam(): GmailThread;
moveToTrash(): GmailThread;
refresh(): GmailThread;
removeLabel(label: GmailLabel): GmailThread;
reply(body: string): GmailThread;
reply(body: string, options: Object): GmailThread;
replyAll(body: string): GmailThread;
replyAll(body: string, options: Object): GmailThread;
}
}
}
declare var GmailApp: GoogleAppsScript.Gmail.GmailApp;