feat(16-02): add AutotaskClient.getAttachmentContent()
- Fetches Tickets/{id}/Attachments/{attachmentId}, reads response.items?.[0]
- Confirmed live: per-attachment-ID GET is list-shaped, not {item:...}
This commit is contained in:
parent
8be10db6e0
commit
9b65de72dc
1 changed files with 20 additions and 0 deletions
|
|
@ -435,6 +435,26 @@ export class AutotaskClient {
|
|||
return response.items || [];
|
||||
}
|
||||
|
||||
// Fetches a single attachment's full content (base64 `data` populated).
|
||||
// Confirmed live: the per-attachment-ID GET returns `{items:[...]}`
|
||||
// (list-shaped), NOT `{item:...}` like getEntityById/uploadAttachment —
|
||||
// do not "fix" this to read response.item, that would silently return
|
||||
// undefined content.
|
||||
async getAttachmentContent(
|
||||
entityName: string,
|
||||
entityId: number,
|
||||
attachmentId: number
|
||||
): Promise<Attachment | null> {
|
||||
const url = `${this.config.apiUrl}/${entityName}/${entityId}/Attachments/${attachmentId}`;
|
||||
|
||||
const response = await this.makeApiCall<ApiResponse<Attachment>>(url, {
|
||||
method: 'GET',
|
||||
headers: this.getAuthHeaders(),
|
||||
});
|
||||
|
||||
return response.items?.[0] ?? null;
|
||||
}
|
||||
|
||||
// Time Entries specific methods
|
||||
async getTimeEntriesByResource(resourceId: number): Promise<AutotaskTimeEntry[]> {
|
||||
return this.queryEntity<AutotaskTimeEntry>('TimeEntries', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue