DeleteAccountRequest.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import Foundation
  15. /// The "deleteAccount" endpoint.
  16. private let kDeleteAccountEndpoint = "deleteAccount"
  17. /// The key for the "idToken" value in the request. This is actually the STS Access Token,
  18. /// despite its confusing (backwards compatible) parameter name.
  19. private let kIDTokenKey = "idToken"
  20. /// The key for the "localID" value in the request.
  21. private let kLocalIDKey = "localId"
  22. @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
  23. class DeleteAccountRequest: IdentityToolkitRequest, AuthRPCRequest,
  24. @unchecked Sendable /* TODO: sendable */ {
  25. typealias Response = DeleteAccountResponse
  26. /// The STS Access Token of the authenticated user.
  27. let accessToken: String
  28. /// The localID of the user.
  29. let localID: String
  30. init(localID: String, accessToken: String, requestConfiguration: AuthRequestConfiguration) {
  31. self.localID = localID
  32. self.accessToken = accessToken
  33. super.init(endpoint: kDeleteAccountEndpoint, requestConfiguration: requestConfiguration)
  34. }
  35. var unencodedHTTPRequestBody: [String: AnyHashable]? {
  36. [
  37. kIDTokenKey: accessToken,
  38. kLocalIDKey: localID,
  39. ]
  40. }
  41. }