1
//native
2
type Adhook = {
3
token: string
4
}
5
6
export async function main(auth: Adhook, subtenantId: string | undefined, Origin: string) {
7
const url = new URL(`https://app.adhook.io/v1/posts/publishManually`)
8
9
for (const [k, v] of [['subtenantId', subtenantId]]) {
10
if (v !== undefined && v !== '' && k !== undefined) {
11
url.searchParams.append(k, v)
12
13
14
15
const response = await fetch(url, {
16
method: 'GET',
17
headers: {
18
Authorization: `Bearer ${auth.token}`,
19
Origin: Origin
20
},
21
body: undefined
22
})
23
24
if (!response.ok) {
25
const text = await response.text()
26
throw new Error(`${response.status} ${text}`)
27
28
29
return await response.json()
30
31