-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TypeScript definitions for v6 packages
- Loading branch information
1 parent
01a9efe
commit a01a277
Showing
34 changed files
with
1,244 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Client = require("@sendgrid/client/src/client"); | ||
|
||
export = Client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {ResponseError} from "@sendgrid/helpers/classes"; | ||
import {OptionsWithUrl} from "request"; | ||
|
||
declare type ClientRequest = OptionsWithUrl; | ||
|
||
declare class Client { | ||
/** | ||
* Set API key | ||
*/ | ||
setApiKey(apiKey: string): void; | ||
|
||
/** | ||
* Set default header | ||
*/ | ||
setDefaultHeader(key: string, value: string): this; | ||
|
||
/** | ||
* Set default request | ||
*/ | ||
setDefaultRequest<K extends keyof ClientRequest>(key: K, value: ClientRequest[K]): this; | ||
|
||
/** | ||
* Create headers for request | ||
*/ | ||
createHeaders(data: { [key: string]: string }): { [key: string]: string }; | ||
|
||
/** | ||
* Create request | ||
*/ | ||
createRequest(data: ClientRequest): ClientRequest; | ||
|
||
/** | ||
* Do a request | ||
*/ | ||
request(data: ClientRequest, cb?: (err: ResponseError, response: any[]) => void): Promise<any[]>; | ||
} | ||
|
||
export = new Client() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Importer = require("@sendgrid/contact-importer/src/importer"); | ||
|
||
export = Importer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
declare interface ContactImporterOptions { | ||
batchSize?: number; | ||
rateLimitLimit?: number; | ||
rateLimitPeriod?: number; | ||
} | ||
|
||
declare interface Contact { | ||
email: string; | ||
first_name?: string; | ||
last_name?: string; | ||
age?: number; | ||
} | ||
|
||
declare class ContactImporter { | ||
constructor(sg, options?: ContactImporterOptions); | ||
|
||
push(data: Contact|Contact[]) | ||
|
||
on(event: "success", cb: (result: any, batch: Contact[]) => void): void; | ||
on(event: "error", cb: (err: Error, batch?: Contact[]) => void): void; | ||
on(event: "drain", cb: () => void): void; | ||
on(event: string, cb: (data: any) => void): void; | ||
|
||
once(event: "success", cb: (result: any, batch: Contact[]) => void): void; | ||
once(event: "error", cb: (err: Error, batch?: Contact[]) => void): void; | ||
once(event: "drain", cb: () => void): void; | ||
once(event: string, cb: (data: any) => void): void; | ||
} | ||
|
||
export = ContactImporter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export interface AttachmentData { | ||
content: string; | ||
filename: string; | ||
type?: string; | ||
disposition?: string; | ||
contentId?: string; | ||
} | ||
|
||
export interface AttachmentJSON { | ||
content: string; | ||
filename: string; | ||
type?: string; | ||
disposition?: string; | ||
content_id?: string; | ||
} | ||
|
||
export default class Attachment { | ||
constructor(data?: AttachmentData); | ||
|
||
fromData(data: AttachmentData): void; | ||
setContent(content: string): void; | ||
setFilename(filename: string): void; | ||
setType(type: string): void; | ||
setDisposition(disposition: string): void; | ||
setContentId(contentId: string): void; | ||
toJSON(): AttachmentJSON; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export type EmailData = string|{ name?: string; email: string; } | ||
|
||
export type EmailJSON = { name?: string; email: string } | ||
|
||
export default class EmailAddress { | ||
constructor(data?: EmailData); | ||
|
||
/** | ||
* From data | ||
*/ | ||
fromData(data: EmailData); | ||
|
||
/** | ||
* Set name | ||
*/ | ||
setName(name: string); | ||
|
||
/** | ||
* Set email (mandatory) | ||
*/ | ||
setEmail(email: string); | ||
|
||
toJSON(): EmailJSON; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Attachment from "@sendgrid/helpers/classes/attachment"; | ||
import EmailAddress from "@sendgrid/helpers/classes/email-address"; | ||
import Mail from "@sendgrid/helpers/classes/mail" | ||
import Personalization from "@sendgrid/helpers/classes/personalization"; | ||
import ResponseError from "@sendgrid/helpers/classes/response-error"; | ||
|
||
export { | ||
Attachment, | ||
EmailAddress, | ||
Mail, | ||
Personalization, | ||
ResponseError, | ||
} |
Oops, something went wrong.