AuthRPCResponse.swift 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. /** @protocol FIRAuthRPCResponse
  16. @brief The generic interface for an RPC response needed by @c FIRAuthBackend.
  17. */
  18. @objc(FIRAuthRPCResponse) public protocol AuthRPCResponse: NSObjectProtocol {
  19. /** @fn setFieldsWithDictionary:error:
  20. @brief Sets the response instance from the decoded JSON response.
  21. @param dictionary The dictionary decoded from HTTP JSON response.
  22. @param error An out field for an error which occurred constructing the request.
  23. @return Whether the operation was successful or not.
  24. */
  25. @objc(setWithDictionary:error:) func setFields(dictionary: [String: AnyHashable]) throws
  26. /** @fn clientErrorWithshortErrorMessage:detailErrorMessage
  27. @brief This optional method allows response classes to create client errors given a short error
  28. message and a detail error message from the server.
  29. @param shortErrorMessage The short error message from the server.
  30. @param detailErrorMessage The detailed error message from the server.
  31. @return A client error, if any.
  32. */
  33. @objc optional func clientError(shortErrorMessage: String, detailErrorMessage: String?)
  34. -> Error?
  35. }
  36. // extension AuthRPCResponse {
  37. // func clientError(shortErrorMessage: String, detailErrorMessage: String?) -> Error? {
  38. // nil
  39. // }
  40. // }