DeleteAccountRequest.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /** @var kCreateAuthURIEndpoint
  16. @brief The "deleteAccount" endpoint.
  17. */
  18. private let kDeleteAccountEndpoint = "deleteAccount"
  19. /** @var kIDTokenKey
  20. @brief The key for the "idToken" value in the request. This is actually the STS Access Token,
  21. despite it's confusing (backwards compatiable) parameter name.
  22. */
  23. private let kIDTokenKey = "idToken"
  24. /** @var kLocalIDKey
  25. @brief The key for the "localID" value in the request.
  26. */
  27. private let kLocalIDKey = "localId"
  28. @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
  29. class DeleteAccountRequest: IdentityToolkitRequest, AuthRPCRequest {
  30. typealias Response = DeleteAccountResponse
  31. /** @var _accessToken
  32. @brief The STS Access Token of the authenticated user.
  33. */
  34. let accessToken: String
  35. /** @var _localID
  36. @brief The localID of the user.
  37. */
  38. let localID: String
  39. init(localID: String, accessToken: String, requestConfiguration: AuthRequestConfiguration) {
  40. self.localID = localID
  41. self.accessToken = accessToken
  42. super.init(endpoint: kDeleteAccountEndpoint, requestConfiguration: requestConfiguration)
  43. }
  44. func unencodedHTTPRequestBody() throws -> [String: AnyHashable] {
  45. [
  46. kIDTokenKey: accessToken,
  47. kLocalIDKey: localID,
  48. ]
  49. }
  50. }