Skip to content

Commit 77b9c93

Browse files
CarolinaMoraesCisneiros
authored andcommitted
feat: add topics support (#544)
1 parent 406f6f7 commit 77b9c93

File tree

9 files changed

+525
-0
lines changed

9 files changed

+525
-0
lines changed

src/resend.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Emails } from './emails/emails';
1313
import { Inbound } from './inbound/inbound';
1414
import type { ErrorResponse } from './interfaces';
1515
import { Templates } from './templates/templates';
16+
import { Topics } from './topics/topics';
1617

1718
const defaultBaseUrl = 'https://api.resend.com';
1819
const defaultUserAgent = `resend-node:${version}`;
@@ -38,6 +39,7 @@ export class Resend {
3839
readonly emails = new Emails(this);
3940
readonly templates = new Templates(this);
4041
readonly inbound = new Inbound(this);
42+
readonly topics = new Topics(this);
4143

4244
constructor(readonly key?: string) {
4345
if (!key) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { ErrorResponse } from '../../interfaces';
2+
import type { Topic } from './topic';
3+
4+
export interface CreateTopicOptions {
5+
name: string;
6+
description?: string;
7+
default_subscription: 'opt_in' | 'opt_out';
8+
}
9+
10+
export type CreateTopicResponseSuccess = Pick<Topic, 'id'>;
11+
12+
export interface CreateTopicResponse {
13+
data: CreateTopicResponseSuccess | null;
14+
error: ErrorResponse | null;
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { ErrorResponse } from '../../interfaces';
2+
import type { Topic } from './topic';
3+
4+
export interface GetTopicOptions {
5+
id: string;
6+
}
7+
8+
export type GetTopicResponseSuccess = Topic;
9+
10+
export interface GetTopicResponse {
11+
data: GetTopicResponseSuccess | null;
12+
error: ErrorResponse | null;
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { ErrorResponse } from '../../interfaces';
2+
import type { Topic } from './topic';
3+
4+
export interface ListTopicsResponseSuccess {
5+
data: Topic[];
6+
}
7+
8+
export interface ListTopicsResponse {
9+
data: ListTopicsResponseSuccess | null;
10+
error: ErrorResponse | null;
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { ErrorResponse } from '../../interfaces';
2+
import type { Topic } from './topic';
3+
4+
export type RemoveTopicResponseSuccess = Pick<Topic, 'id'> & {
5+
object: 'topic';
6+
deleted: boolean;
7+
};
8+
9+
export interface RemoveTopicResponse {
10+
data: RemoveTopicResponseSuccess | null;
11+
error: ErrorResponse | null;
12+
}

src/topics/interfaces/topic.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface Topic {
2+
id: string;
3+
name: string;
4+
description?: string;
5+
default_subscription: 'opt_in' | 'opt_out';
6+
created_at: string;
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { ErrorResponse } from '../../interfaces';
2+
import type { Topic } from './topic';
3+
4+
export interface UpdateTopicOptions {
5+
id: string;
6+
name?: string;
7+
description?: string;
8+
}
9+
10+
export type UpdateTopicResponseSuccess = Pick<Topic, 'id'>;
11+
12+
export interface UpdateTopicResponse {
13+
data: UpdateTopicResponseSuccess | null;
14+
error: ErrorResponse | null;
15+
}

0 commit comments

Comments
 (0)