//native
type Zuplo = {
apiKey: string
}
/**
* Updates a subscription
* Updates the subscription for this bucket.
*/
export async function main(
auth: Zuplo,
bucketId: string,
subscriptionId: string,
body: {
planExternalIds?: string[]
status?:
| 'active'
| 'inactive'
| 'incomplete'
| 'incomplete-expired'
| 'trialing'
| 'past-due'
| 'canceled'
| 'unpaid'
| 'paused'
prorate?: number
metadata?: {}
trialEndDate?: string
}
) {
const url = new URL(
`https://dev.zuplo.com/v1/metering/${bucketId}/subscriptions/${subscriptionId}`
)
const response = await fetch(url, {
method: 'PATCH',
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()
}
Submitted by hugo697 235 days ago