Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/resend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Contacts } from './contacts/contacts';
import { Domains } from './domains/domains';
import { Emails } from './emails/emails';
import type { ErrorResponse } from './interfaces';
import { Topics } from './topics/topics';

const defaultBaseUrl = 'https://api.resend.com';
const defaultUserAgent = `resend-node:${version}`;
Expand All @@ -32,6 +33,7 @@ export class Resend {
readonly contacts = new Contacts(this);
readonly domains = new Domains(this);
readonly emails = new Emails(this);
readonly topics = new Topics(this);

constructor(readonly key?: string) {
if (!key) {
Expand Down
15 changes: 15 additions & 0 deletions src/topics/interfaces/create-topic-options.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { ErrorResponse } from '../../interfaces';
import type { Topic } from './topic';

export interface CreateTopicOptions {
name: string;
description?: string;
default_subscription: 'opt_in' | 'opt_out';
}

export type CreateTopicResponseSuccess = Pick<Topic, 'id'>;

export interface CreateTopicResponse {
data: CreateTopicResponseSuccess | null;
error: ErrorResponse | null;
}
13 changes: 13 additions & 0 deletions src/topics/interfaces/get-contact.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ErrorResponse } from '../../interfaces';
import type { Topic } from './topic';

export interface GetTopicOptions {
id: string;
}

export type GetTopicResponseSuccess = Topic;

export interface GetTopicResponse {
data: GetTopicResponseSuccess | null;
error: ErrorResponse | null;
}
11 changes: 11 additions & 0 deletions src/topics/interfaces/list-topics.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ErrorResponse } from '../../interfaces';
import type { Topic } from './topic';

export interface ListTopicsResponseSuccess {
data: Topic[];
}

export interface ListTopicsResponse {
data: ListTopicsResponseSuccess | null;
error: ErrorResponse | null;
}
12 changes: 12 additions & 0 deletions src/topics/interfaces/remove-topic.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { ErrorResponse } from '../../interfaces';
import type { Topic } from './topic';

export type RemoveTopicResponseSuccess = Pick<Topic, 'id'> & {
object: 'topic';
deleted: boolean;
};

export interface RemoveTopicResponse {
data: RemoveTopicResponseSuccess | null;
error: ErrorResponse | null;
}
7 changes: 7 additions & 0 deletions src/topics/interfaces/topic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface Topic {
id: string;
name: string;
description?: string;
default_subscription: 'opt_in' | 'opt_out';
created_at: string;
}
15 changes: 15 additions & 0 deletions src/topics/interfaces/update-topic.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { ErrorResponse } from '../../interfaces';
import type { Topic } from './topic';

export interface UpdateTopicOptions {
id: string;
name?: string;
description?: string;
}

export type UpdateTopicResponseSuccess = Pick<Topic, 'id'>;

export interface UpdateTopicResponse {
data: UpdateTopicResponseSuccess | null;
error: ErrorResponse | null;
}
Loading