Skip to content

Commit e49c09a

Browse files
author
SomaticIT
committed
Add definitions for sendgrid sdk for node
1 parent 50dd84e commit e49c09a

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

sendgrid/sendgrid.d.ts

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// Type definitions for sendgrid 1.1.0
2+
// Project: https://github.com/sendgrid/sendgrid-nodejs
3+
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
interface SendgridUriParts {
7+
protocol: string;
8+
host: string;
9+
port: string;
10+
endpoint: string;
11+
}
12+
13+
interface SendgridOptions {
14+
protocol?: string;
15+
host?: string;
16+
port?: string;
17+
endpoint?: string;
18+
uri?: string;
19+
}
20+
21+
interface SendgridOptionsExport {
22+
uriParts: SendgridUriParts;
23+
uri: string;
24+
}
25+
26+
interface SendgridEmailOptions {
27+
to?: any;
28+
toname?: string;
29+
from?: string;
30+
fromname?: string;
31+
subject?: string;
32+
text?: string;
33+
html?: string;
34+
bcc?: any;
35+
replyto?: string;
36+
date?: Date;
37+
headers?: { [key: string]: string };
38+
files?: SendgridEmailFileOptions[];
39+
smtpapi?: any;
40+
}
41+
42+
declare class PrivateSendgridEmail {
43+
to: any;
44+
toname: string;
45+
from: string;
46+
fromname: string;
47+
subject: string;
48+
text: string;
49+
html: string;
50+
bcc: any;
51+
replyto: string;
52+
date: Date;
53+
headers: { [key: string]: string };
54+
files: PrivateSendgridFile[];
55+
smtpapi: any;
56+
57+
constructor();
58+
constructor(options: SendgridEmailOptions);
59+
60+
addTo(address: string): void;
61+
addHeader(type: string, value: string): void;
62+
addSubstitution(type: string, value: string): void;
63+
addSubstitution(type: string, value: string[]): void;
64+
addSection(section: { [key: string]: string }): void;
65+
addUniqueArg(uarg: { [key: string]: string }): void;
66+
addCategory(category: string): void;
67+
addFilter(filter: string, command: string, value: number): void;
68+
addFilter(filter: string, command: string, value: string): void;
69+
addFile(file: SendgridEmailFileOptions): void;
70+
71+
setFrom(address: string): void;
72+
setSubject(subject: string): void;
73+
setText(text: string): void;
74+
setHtml(html: string): void;
75+
setHeaders(headers: { [key: string]: string }): void;
76+
setSubstitutions(substitutions: { [key: string]: string[] }): void;
77+
setSections(sections: { [key: string]: string }): void;
78+
setUniqueArgs(uargs: { [key: string]: string }): void;
79+
setCategories(categories: string[]): void;
80+
setFilters(filters: any): void;
81+
}
82+
83+
interface SendgridEmailFileOptions {
84+
filename?: string;
85+
contentType?: string;
86+
cid?: string;
87+
path?: string;
88+
url?: string;
89+
content?: any;
90+
}
91+
92+
declare class PrivateSendgridFile {
93+
filename: string;
94+
contentType: string;
95+
cid: string;
96+
97+
type: string;
98+
content: string;
99+
path: string;
100+
url: string;
101+
102+
loadContent(callback: (hasError: boolean, error: Error) => any): void;
103+
}
104+
105+
interface Sendgrid {
106+
version: string;
107+
api_user: string;
108+
api_key: string;
109+
options: SendgridOptionsExport;
110+
Email: typeof PrivateSendgridEmail;
111+
112+
send(email: PrivateSendgridEmail, callback: (err: Error, json: any) => any): void;
113+
}
114+
115+
declare module "sendgrid" {
116+
interface SendgridConstructor {
117+
(api_user: string, api_key: string, options?: SendgridOptions): Sendgrid;
118+
new (api_user: string, api_key: string, options?: SendgridOptions): Sendgrid;
119+
}
120+
121+
export = SendgridConstructor;
122+
}

0 commit comments

Comments
 (0)