AuthRPCRequest.swift 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. // TODO: Once this type doesn't need to be @objc, perhaps it would make sense to make the response an
  16. // associated type of the request protocol and perform all encoding of requests and decoding of responses
  17. // using Codable.
  18. /** @protocol FIRAuthRPCRequest
  19. @brief The generic interface for an RPC request needed by @c FIRAuthBackend.
  20. */
  21. @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
  22. @objc(FIRAuthRPCRequest) public protocol AuthRPCRequest: NSObjectProtocol {
  23. /** @fn requestURL
  24. @brief Gets the request's full URL.
  25. */
  26. func requestURL() -> URL
  27. /** @fn containsPostBody
  28. @brief Returns whether the request contains a post body or not. Requests without a post body
  29. are get requests.
  30. @remarks The default implementation returns true.
  31. */
  32. @objc optional func containsPostBody() -> Bool
  33. /** @fn UnencodedHTTPRequestBodyWithError:
  34. @brief Creates unencoded HTTP body representing the request.
  35. @param error An out field for an error which occurred constructing the request.
  36. @return The HTTP body data representing the request before any encoding, or nil for error.
  37. */
  38. @objc(unencodedHTTPRequestBodyWithError:)
  39. func unencodedHTTPRequestBody() throws -> [String: AnyHashable]
  40. /** @fn requestConfiguration
  41. @brief Obtains the request configurations if available.
  42. @return Returns the request configurations.
  43. */
  44. func requestConfiguration() -> AuthRequestConfiguration
  45. /** @var response
  46. @brief The corresponding response for this request
  47. */
  48. var response: AuthRPCResponse { get }
  49. }