DeleteAccountRequest.swift 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. typealias Response = DeleteAccountResponse
  25. /// The STS Access Token of the authenticated user.
  26. let accessToken: String
  27. /// The localID of the user.
  28. let localID: String
  29. init(localID: String, accessToken: String, requestConfiguration: AuthRequestConfiguration) {
  30. self.localID = localID
  31. self.accessToken = accessToken
  32. super.init(endpoint: kDeleteAccountEndpoint, requestConfiguration: requestConfiguration)
  33. }
  34. func unencodedHTTPRequestBody() throws -> [String: AnyHashable] {
  35. [
  36. kIDTokenKey: accessToken,
  37. kLocalIDKey: localID,
  38. ]
  39. }
  40. }