0

List Interventions

by
Published Nov 5, 2024

Returns a list of all supported interventions. The `language` parameter can be used to specify the language of the resolution title and description.

Script enode Verified

The script

Submitted by hugo697 Bun
Verified 581 days ago
1
//native
2
type Enode = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Enode,
8
	language:
9
		| 'en-US'
10
		| 'en-GB'
11
		| 'de-DE'
12
		| 'fr-FR'
13
		| 'es-ES'
14
		| 'pt-PT'
15
		| 'nl-NL'
16
		| 'nl-BE'
17
		| 'nb-NO'
18
		| 'sv-SE'
19
		| 'da-DK'
20
		| 'fi-FI'
21
		| 'ro-RO'
22
		| undefined,
23
	vendorType: string | undefined,
24
	vendor: string | undefined
25
) {
26
	const url = new URL(`https://enode-api.production.enode.io/interventions`)
27

28
	for (const [k, v] of [
29
		['language', language],
30
		['vendorType', vendorType],
31
		['vendor', vendor]
32
	]) {
33
		if (v !== undefined && v !== '' && k !== undefined) {
34
			url.searchParams.append(k, v)
35
		}
36
	}
37

38
	const response = await fetch(url, {
39
		method: 'GET',
40
		headers: {
41
			Authorization: 'Bearer ' + auth.token
42
		},
43
		body: undefined
44
	})
45

46
	if (!response.ok) {
47
		const text = await response.text()
48
		throw new Error(`${response.status} ${text}`)
49
	}
50

51
	return await response.json()
52
}
53