//native
/**
* Create a Milestone
* Add a new milestone to a specific contract. Milestones represent distinct deliverables or phases in the contract and can include additional details such as attachments.
**Token scopes**: `milestones:write`
*/
export async function main(auth: RT.Deel, contract_id: string, body: Body) {
const url = new URL(`https://api.letsdeel.com/rest/v2/contracts/${contract_id}/milestones`)
const formData = new FormData()
for (const [k, v] of Object.entries(body)) {
if (v !== undefined && v !== '') {
formData.append(k, String(v))
}
}
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
export interface Body {
data: {
/**
* The title of the milestone.
*/
title: string
amount: string | number
/**
* A detailed description of the milestone.
*/
description: string
[k: string]: unknown
}
[k: string]: unknown
}
Submitted by hugo697 235 days ago