Skip to content

Commit 1aa7565

Browse files
committed
feat: move emails inbound method to be nested within email
1 parent 1d74eae commit 1aa7565

File tree

8 files changed

+17
-14
lines changed

8 files changed

+17
-14
lines changed

src/emails/emails.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ import type {
2727
UpdateEmailResponse,
2828
UpdateEmailResponseSuccess,
2929
} from './interfaces/update-email-options.interface';
30+
import { Receiving } from './receiving/receiving';
3031

3132
export class Emails {
32-
constructor(private readonly resend: Resend) {}
33+
readonly receiving: Receiving;
34+
35+
constructor(private readonly resend: Resend) {
36+
this.receiving = new Receiving(resend);
37+
}
3338

3439
async send(
3540
payload: CreateEmailOptions,

src/inbound/interfaces/get-inbound-email.interface.ts renamed to src/emails/receiving/interfaces/get-inbound-email.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ErrorResponse } from '../../interfaces';
1+
import type { ErrorResponse } from '../../../interfaces';
22
import type { InboundEmail } from './inbound-email';
33

44
// API response type (snake_case from API)
File renamed without changes.

src/inbound/inbound.spec.ts renamed to src/emails/receiving/receiving.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { ErrorResponse } from '../interfaces';
2-
import { Resend } from '../resend';
1+
import type { ErrorResponse } from '../../interfaces';
2+
import { Resend } from '../../resend';
33

44
const resend = new Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
55

6-
describe('Inbound', () => {
6+
describe('Receiving', () => {
77
afterEach(() => fetchMock.resetMocks());
88

99
describe('get', () => {
@@ -22,7 +22,7 @@ describe('Inbound', () => {
2222
},
2323
});
2424

25-
const result = resend.inbound.get(
25+
const result = resend.emails.receiving.get(
2626
'61cda979-919d-4b9d-9638-c148b93ff410',
2727
);
2828

@@ -74,7 +74,7 @@ describe('Inbound', () => {
7474
},
7575
});
7676

77-
const result = await resend.inbound.get(
77+
const result = await resend.emails.receiving.get(
7878
'67d9bcdb-5a02-42d7-8da9-0d6feea18cff',
7979
);
8080

@@ -141,7 +141,7 @@ describe('Inbound', () => {
141141
},
142142
});
143143

144-
const result = await resend.inbound.get(
144+
const result = await resend.emails.receiving.get(
145145
'67d9bcdb-5a02-42d7-8da9-0d6feea18cff',
146146
);
147147

src/inbound/inbound.ts renamed to src/emails/receiving/receiving.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import type { Resend } from '../resend';
1+
import type { Resend } from '../../resend';
22
import type {
33
GetInboundEmailApiResponse,
44
GetInboundEmailResponse,
55
GetInboundEmailResponseSuccess,
66
} from './interfaces/get-inbound-email.interface';
77

8-
export class Inbound {
8+
export class Receiving {
99
constructor(private readonly resend: Resend) {}
1010

1111
async get(id: string): Promise<GetInboundEmailResponse> {
1212
const data = await this.resend.get<GetInboundEmailApiResponse>(
13-
`/emails/inbound/${id}`,
13+
`/emails/receiving/${id}`,
1414
);
1515

1616
if (data.error) {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export * from './common/interfaces';
77
export * from './contacts/interfaces';
88
export * from './domains/interfaces';
99
export * from './emails/interfaces';
10-
export * from './inbound/interfaces';
10+
export * from './emails/receiving/interfaces';
1111
export { ErrorResponse } from './interfaces';
1212
export { Resend } from './resend';

src/resend.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type { PatchOptions } from './common/interfaces/patch-option.interface';
1010
import { Contacts } from './contacts/contacts';
1111
import { Domains } from './domains/domains';
1212
import { Emails } from './emails/emails';
13-
import { Inbound } from './inbound/inbound';
1413
import type { ErrorResponse } from './interfaces';
1514

1615
const defaultBaseUrl = 'https://api.resend.com';
@@ -35,7 +34,6 @@ export class Resend {
3534
readonly contacts = new Contacts(this);
3635
readonly domains = new Domains(this);
3736
readonly emails = new Emails(this);
38-
readonly inbound = new Inbound(this);
3937

4038
constructor(readonly key?: string) {
4139
if (!key) {

0 commit comments

Comments
 (0)