//native
type Enode = {
token: string
}
export async function main(
auth: Enode,
locationId: string,
body: {
tariffId: string
tariffIntervals: {
name: string
weekdays?: 0 | 1 | 2 | 3 | 4 | 5 | 6[]
from: string
to: string
}[]
}
) {
const url = new URL(`https://enode-api.production.enode.io/locations/${locationId}/tariff`)
const response = await fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 581 days ago