Edits history of script submission #17782 for ' Deactivate a Repo Sync (phrase)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Phrase = {
    	token: string
    	baseUrl: string
    }
    /**
     * Deactivate a Repo Sync
     * Deactivate an active Repo Sync. Import and export can't be performed on deactivated syncs
    and the pushes to the repository won't trigger the import to Phrase.
     */
    export async function main(auth: Phrase, account_id: string, id: string) {
    	const url = new URL(`${auth.baseUrl}/accounts/${account_id}/repo_syncs/${id}/deactivate`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			Authorization: 'ApiToken ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago