Download wp-calypso/test/e2e/specs/shared/api-close-account.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/test/e2e/specs/shared/api-close-account.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/test/e2e/specs/shared/api-close-account.ts
-
curl -L -o api-close-account.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/test/e2e/specs/shared/api-close-account.ts
1.12 kB
| import { RestAPIClient } from '@automattic/calypso-e2e'; | |
| import type { AccountDetails, AccountClosureResponse } from '@automattic/calypso-e2e'; | |
| /** | |
| * Makes an API request to close the user account. | |
| * | |
| * Note that closing an user account will also close any existing sites | |
| * belonging to the user, thus it is not required to close sites if this | |
| * function is called first. | |
| * | |
| * @param {RestAPIClient} client Client to interact with the WP REST API. | |
| * @param {AccountDetails} accountDetails Details of the account to close. | |
| * @returns { AccountClosureResponse} Response denoting whether deletion was successful. | |
| */ | |
| export async function apiCloseAccount( | |
| client: RestAPIClient, | |
| accountDetails: AccountDetails | |
| ): Promise< void > { | |
| console.log( `Closing account ${ accountDetails.userID }.` ); | |
| const response: AccountClosureResponse = await client.closeAccount( accountDetails ); | |
| if ( response.success !== true ) { | |
| console.warn( `Failed to delete user ID ${ accountDetails.userID }` ); | |
| console.warn( response ); | |
| } else { | |
| console.log( `Successfully deleted user ID ${ accountDetails.userID }` ); | |
| } | |
| } | |