//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Update an article
* You can update the details of a single article by making a PUT request to `https://api.intercom.io/articles/`.
*/
export async function main(
auth: Intercom,
id: string,
body: {
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
parent_id?: string
parent_type?: string
translated_content?: {
type?: 'article_translated_content'
ar?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
bg?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
bs?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
ca?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
cs?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
da?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
de?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
el?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
en?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
es?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
et?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
fi?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
fr?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
he?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
hr?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
hu?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
id?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
it?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
ja?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
ko?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
lt?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
lv?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
mn?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
nb?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
nl?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
pl?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
pt?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
ro?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
ru?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
sl?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
sr?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
sv?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
tr?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
vi?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
'pt-BR'?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
'zh-CN'?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
'zh-TW'?: {
type?: 'article_content'
title?: string
description?: string
body?: string
author_id?: number
state?: 'published' | 'draft'
created_at?: number
updated_at?: number
url?: string
}
}
}
) {
const url = new URL(`https://api.intercom.io/articles/${id}`)
const response = await fetch(url, {
method: 'PUT',
headers: {
'Intercom-Version': auth.apiVersion,
'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.json()
}
Submitted by hugo697 536 days ago