Update docs and sdk for schedule
This commit is contained in:
3
apps/docs/api-reference/emails/cancel-schedule.mdx
Normal file
3
apps/docs/api-reference/emails/cancel-schedule.mdx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
openapi: post /v1/emails/{emailId}/cancel
|
||||||
|
---
|
3
apps/docs/api-reference/emails/update-schedule.mdx
Normal file
3
apps/docs/api-reference/emails/update-schedule.mdx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
openapi: patch /v1/emails/{emailId}
|
||||||
|
---
|
@@ -215,6 +215,7 @@
|
|||||||
"status": {
|
"status": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
"SCHEDULED",
|
||||||
"QUEUED",
|
"QUEUED",
|
||||||
"SENT",
|
"SENT",
|
||||||
"DELIVERY_DELAYED",
|
"DELIVERY_DELAYED",
|
||||||
@@ -225,7 +226,8 @@
|
|||||||
"OPENED",
|
"OPENED",
|
||||||
"CLICKED",
|
"CLICKED",
|
||||||
"COMPLAINED",
|
"COMPLAINED",
|
||||||
"FAILED"
|
"FAILED",
|
||||||
|
"CANCELLED"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"createdAt": {
|
"createdAt": {
|
||||||
@@ -260,6 +262,56 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"patch": {
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 3,
|
||||||
|
"example": "cuiwqdj74rygf74"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"name": "emailId",
|
||||||
|
"in": "path"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"scheduledAt": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"scheduledAt"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Retrieve the user",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"emailId": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/v1/emails": {
|
"/v1/emails": {
|
||||||
@@ -352,6 +404,10 @@
|
|||||||
"content"
|
"content"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"scheduledAt": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@@ -382,6 +438,39 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/v1/emails/{emailId}/cancel": {
|
||||||
|
"post": {
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 3,
|
||||||
|
"example": "cuiwqdj74rygf74"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"name": "emailId",
|
||||||
|
"in": "path"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Retrieve the user",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"emailId": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/v1/contactBooks/{contactBookId}/contacts": {
|
"/v1/contactBooks/{contactBookId}/contacts": {
|
||||||
"post": {
|
"post": {
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
@@ -70,7 +70,9 @@
|
|||||||
"group": "Emails",
|
"group": "Emails",
|
||||||
"pages": [
|
"pages": [
|
||||||
"api-reference/emails/get-email",
|
"api-reference/emails/get-email",
|
||||||
"api-reference/emails/send-email"
|
"api-reference/emails/send-email",
|
||||||
|
"api-reference/emails/update-schedule",
|
||||||
|
"api-reference/emails/cancel-schedule"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,27 @@ type GetEmailResponse = {
|
|||||||
error: ErrorResponse | null;
|
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 {
|
export class Emails {
|
||||||
constructor(private readonly unsend: Unsend) {
|
constructor(private readonly unsend: Unsend) {
|
||||||
this.unsend = unsend;
|
this.unsend = unsend;
|
||||||
@@ -54,4 +75,23 @@ export class Emails {
|
|||||||
);
|
);
|
||||||
return data;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
48
packages/sdk/types/schema.d.ts
vendored
48
packages/sdk/types/schema.d.ts
vendored
@@ -73,7 +73,7 @@ export interface paths {
|
|||||||
emailEvents: ({
|
emailEvents: ({
|
||||||
emailId: string;
|
emailId: string;
|
||||||
/** @enum {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;
|
createdAt: string;
|
||||||
data?: unknown;
|
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": {
|
"/v1/emails": {
|
||||||
post: {
|
post: {
|
||||||
@@ -100,6 +125,8 @@ export interface paths {
|
|||||||
filename: string;
|
filename: string;
|
||||||
content: 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": {
|
"/v1/contactBooks/{contactBookId}/contacts": {
|
||||||
post: {
|
post: {
|
||||||
parameters: {
|
parameters: {
|
||||||
|
Reference in New Issue
Block a user