basecamp-api-v3
Version:
This TypeScript library provides an API wrapper for interacting with Basecamp resources, including People, Projects, Todo Sets, Todo Lists, Comments, and Authorization.
27 lines (23 loc) • 772 B
text/typescript
import { fetchDataWithRetry } from '../utils/fetchWithRetry'
interface createAttachmentParams {
accountId: string,
authorization: string,
name: string,
contentType: string,
contentLength: number,
binaryBody: string,
}
export const createAttachment = async(params: createAttachmentParams): Promise<any> => {
const url = `https://3.basecampapi.com/${params.accountId}/attachments.json`
const options = {
method: 'post',
headers: { Authorization: `Bearer ${params.authorization}` },
body: JSON.stringify({
name: params.name,
content_type: params.contentType,
content_length: params.contentLength,
binary_body: params.binaryBody,
})
}
return await fetchDataWithRetry({ url, options })
}