Skip to content

Commit b3cfc07

Browse files
committed
feat: handles expires_at
1 parent fe86a2a commit b3cfc07

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/attachments/receiving/interfaces/attachment.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,13 @@ export interface InboundAttachment {
66
content_id?: string;
77
content: string; // base64
88
}
9+
10+
export interface ApiInboundAttachment {
11+
id: string;
12+
filename?: string;
13+
content_type: string;
14+
content_disposition: 'inline' | 'attachment';
15+
content_id?: string;
16+
download_url: string;
17+
expires_at: string;
18+
}

src/attachments/receiving/interfaces/get-attachment.interface.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
import type { ErrorResponse } from '../../../interfaces';
2-
import type { InboundAttachment } from './attachment';
2+
import type { ApiInboundAttachment, InboundAttachment } from './attachment';
33

44
export interface GetAttachmentOptions {
55
emailId: string;
66
id: string;
77
}
88

9-
// API response type (snake_case from API)
109
export interface GetAttachmentApiResponse {
1110
object: 'attachment';
12-
data: {
13-
id: string;
14-
filename?: string;
15-
content_type: string;
16-
content_disposition: 'inline' | 'attachment';
17-
content_id?: string;
18-
download_url: string;
19-
};
11+
data: ApiInboundAttachment;
2012
}
2113

22-
// SDK response type (camelCase for users)
2314
export interface GetAttachmentResponseSuccess {
2415
object: 'attachment';
2516
data: InboundAttachment;

src/attachments/receiving/interfaces/list-attachments.interface.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export type ListAttachmentsOptions = PaginationOptions & {
66
emailId: string;
77
};
88

9-
// API response type (with download_url)
109
export interface ListAttachmentsApiResponse {
1110
object: 'list';
1211
has_more: boolean;
@@ -17,10 +16,10 @@ export interface ListAttachmentsApiResponse {
1716
content_disposition: 'inline' | 'attachment';
1817
content_id?: string;
1918
download_url: string;
19+
expires_at: string;
2020
}>;
2121
}
2222

23-
// SDK response type (with base64 content)
2423
export interface ListAttachmentsResponseSuccess {
2524
object: 'list';
2625
has_more: boolean;

src/attachments/receiving/receiving.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class Receiving {
6262
return apiResponse;
6363
}
6464

65-
const { download_url, ...otherFields } = apiResponse.data.data;
65+
const { expires_at, download_url, ...otherFields } = apiResponse.data.data;
6666
const downloadResult = await this.downloadAttachment(download_url);
6767
if (downloadResult.type === 'error') {
6868
return {
@@ -106,7 +106,7 @@ export class Receiving {
106106

107107
const attachmentsWithContent = [];
108108
for (const attachment of apiResponse.data.data) {
109-
const { download_url, ...otherFields } = attachment;
109+
const { expires_at, download_url, ...otherFields } = attachment;
110110
const downloadResult = await this.downloadAttachment(download_url);
111111
if (downloadResult.type === 'error') {
112112
return {

0 commit comments

Comments
 (0)