VerifyClientRequest.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. @objc(FIRVerifyClientRequest)
  16. public class VerifyClientRequest: IdentityToolkitRequest, AuthRPCRequest {
  17. /// The endpoint for the verifyClient request.
  18. private static let verifyClientEndpoint = "verifyClient"
  19. /// The key for the appToken request paramenter.
  20. private static let appTokenKey = "appToken"
  21. /// The key for the isSandbox request parameter.
  22. private static let isSandboxKey = "isSandbox"
  23. /** @var response
  24. @brief The corresponding response for this request
  25. */
  26. @objc public var response: AuthRPCResponse = VerifyClientResponse()
  27. public func unencodedHTTPRequestBody() throws -> [String: AnyHashable] {
  28. var postBody = [String: AnyHashable]()
  29. if let appToken = appToken {
  30. postBody[Self.appTokenKey] = appToken
  31. }
  32. postBody[Self.isSandboxKey] = isSandbox
  33. return postBody
  34. }
  35. /// The APNS device token.
  36. @objc public private(set) var appToken: String?
  37. /// The flag that denotes if the appToken pertains to Sandbox or Production.
  38. @objc public private(set) var isSandbox: Bool
  39. @objc public init(withAppToken: String?,
  40. isSandbox: Bool,
  41. requestConfiguration: AuthRequestConfiguration) {
  42. appToken = withAppToken
  43. self.isSandbox = isSandbox
  44. self.isSandbox = isSandbox
  45. super.init(endpoint: Self.verifyClientEndpoint, requestConfiguration: requestConfiguration)
  46. }
  47. }