CreateAuthURIResponse.swift 1.8 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. /// Represents the parameters for the createAuthUri endpoint.
  16. /// See https: // developers.google.com/identity/toolkit/web/reference/relyingparty/createAuthUri
  17. class CreateAuthURIResponse: AuthRPCResponse {
  18. /// The URI used by the IDP to authenticate the user.
  19. var authURI: String?
  20. /// Whether the user is registered if the identifier is an email.
  21. var registered: Bool = false
  22. /// The provider ID of the auth URI.
  23. var providerID: String?
  24. /// True if the authUri is for user's existing provider.
  25. var forExistingProvider: Bool = false
  26. /// A list of provider IDs the passed identifier could use to sign in with.
  27. var allProviders: [String]?
  28. /// A list of sign-in methods available for the passed identifier.
  29. var signinMethods: [String] = []
  30. /// Bare initializer.
  31. required init() {}
  32. func setFields(dictionary: [String: AnyHashable]) throws {
  33. providerID = dictionary["providerId"] as? String
  34. authURI = dictionary["authUri"] as? String
  35. registered = dictionary["registered"] as? Bool ?? false
  36. forExistingProvider = dictionary["forExistingProvider"] as? Bool ?? false
  37. allProviders = dictionary["allProviders"] as? [String]
  38. signinMethods = dictionary["signinMethods"] as? [String] ?? []
  39. }
  40. }