Update docs and sdk for schedule

This commit is contained in:
KMKoushik
2024-08-21 18:32:56 +10:00
parent 9b54fc1793
commit 0df42698d0
6 changed files with 186 additions and 3 deletions

View File

@@ -25,6 +25,27 @@ type GetEmailResponse = {
error: ErrorResponse | null;
};
type UpdateEmailPayload =
paths["/v1/emails/{emailId}"]["patch"]["requestBody"]["content"]["application/json"] & {
react?: React.ReactElement;
};
type UpdateEmailResponse = {
data: UpdateEmailResponseSuccess | null;
error: ErrorResponse | null;
};
type UpdateEmailResponseSuccess =
paths["/v1/emails/{emailId}"]["patch"]["responses"]["200"]["content"]["application/json"];
type CancelEmailResponse = {
data: CancelEmailResponseSuccess | null;
error: ErrorResponse | null;
};
type CancelEmailResponseSuccess =
paths["/v1/emails/{emailId}/cancel"]["post"]["responses"]["200"]["content"]["application/json"];
export class Emails {
constructor(private readonly unsend: Unsend) {
this.unsend = unsend;
@@ -54,4 +75,23 @@ export class Emails {
);
return data;
}
async update(
id: string,
payload: UpdateEmailPayload
): Promise<UpdateEmailResponse> {
const data = await this.unsend.patch<UpdateEmailResponseSuccess>(
`/emails/${id}`,
payload
);
return data;
}
async cancel(id: string): Promise<CancelEmailResponse> {
const data = await this.unsend.post<CancelEmailResponseSuccess>(
`/emails/${id}/cancel`,
{}
);
return data;
}
}

View File

@@ -73,7 +73,7 @@ export interface paths {
emailEvents: ({
emailId: string;
/** @enum {string} */
status: "QUEUED" | "SENT" | "DELIVERY_DELAYED" | "BOUNCED" | "REJECTED" | "RENDERING_FAILURE" | "DELIVERED" | "OPENED" | "CLICKED" | "COMPLAINED" | "FAILED";
status: "SCHEDULED" | "QUEUED" | "SENT" | "DELIVERY_DELAYED" | "BOUNCED" | "REJECTED" | "RENDERING_FAILURE" | "DELIVERED" | "OPENED" | "CLICKED" | "COMPLAINED" | "FAILED" | "CANCELLED";
createdAt: string;
data?: unknown;
})[];
@@ -82,6 +82,31 @@ export interface paths {
};
};
};
patch: {
parameters: {
path: {
emailId: string;
};
};
requestBody: {
content: {
"application/json": {
/** Format: date-time */
scheduledAt: string;
};
};
};
responses: {
/** @description Retrieve the user */
200: {
content: {
"application/json": {
emailId?: string;
};
};
};
};
};
};
"/v1/emails": {
post: {
@@ -100,6 +125,8 @@ export interface paths {
filename: string;
content: string;
}[];
/** Format: date-time */
scheduledAt?: string;
};
};
};
@@ -115,6 +142,25 @@ export interface paths {
};
};
};
"/v1/emails/{emailId}/cancel": {
post: {
parameters: {
path: {
emailId: string;
};
};
responses: {
/** @description Retrieve the user */
200: {
content: {
"application/json": {
emailId?: string;
};
};
};
};
};
};
"/v1/contactBooks/{contactBookId}/contacts": {
post: {
parameters: {