Skip to content

Commit be14386

Browse files
committed
Add RequestAccountDeletion
1 parent f2a1a58 commit be14386

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// RequestAccountDelete.swift
3+
//
4+
//
5+
// Created by Christopher Jr Riley on 2024-02-25.
6+
//
7+
8+
import Foundation
9+
10+
extension ATProtoKit {
11+
/// Requests the server to delete the user's account via email.
12+
///
13+
/// - Warning: Doing this will permanently delete the user's account. Use caution when using this.
14+
public func requestAccountDeletion() async throws {
15+
guard let sessionURL = session.pdsURL,
16+
let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.requestAccountDelete") else {
17+
throw NSError(domain: "", code: -1, userInfo: [NSLocalizedDescriptionKey : "Invalid URL"])
18+
}
19+
20+
do {
21+
let request = APIClientService.createRequest(forRequest: requestURL, andMethod: .post, acceptValue: nil, contentTypeValue: nil, authorizationValue: "Bearer \(session.accessToken)")
22+
try await APIClientService.sendRequest(request)
23+
} catch {
24+
throw error
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)