Skip to content

Commit

Permalink
warp: add Remove device function
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Pashmfouroush <[email protected]>
  • Loading branch information
markpash committed Mar 4, 2024
1 parent 8c7255d commit b26d7d3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions warp/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,3 +633,36 @@ func CheckProfileExists(license string) bool {
}
return isOk
}

func RemoveDevice(account AccountData) error {

headers := map[string]string{
"Content-Type": "application/json",
"User-Agent": "okhttp/3.12.1",
"CF-Client-Version": "a-6.30-3596",
"Authorization": "Bearer " + account.AccessToken,
}

req, err := http.NewRequest("DELETE", "https://api.cloudflareclient.com/v0a3596/reg/"+account.AccountID, nil)
if err != nil {
return err
}

// Set headers
for k, v := range MergeMaps(defaultHeaders, headers) {
req.Header.Set(k, v)
}

// Create HTTP client and execute request
response, err := client.Do(req)
if err != nil {
fmt.Println("sending request to remote server", err)
return err
}

if response.StatusCode != 204 {
return fmt.Errorf("error in deleting account %d %s", response.StatusCode, response.Status)
}

return nil
}

0 comments on commit b26d7d3

Please sign in to comment.