Restores soft deleted User.
1
//native
2
type Motimate = {
3
token: string
4
}
5
6
export async function main(
7
auth: Motimate,
8
user_id: string,
9
identifier_type: 'id' | 'external_id' | undefined
10
) {
11
const url = new URL(`https://motimateapp.com/public_api/users/${user_id}/restore`)
12
13
for (const [k, v] of [['identifier_type', identifier_type]]) {
14
if (v !== undefined && v !== '' && k !== undefined) {
15
url.searchParams.append(k, v)
16
17
18
19
const response = await fetch(url, {
20
method: 'PATCH',
21
headers: {
22
Authorization: 'Bearer ' + auth.token
23
24
})
25
26
if (!response.ok) {
27
const text = await response.text()
28
throw new Error(`${response.status} ${text}`)
29
30
31
return await response.json()
32
33