FIRGetRecaptchaConfigRequest.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2022 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FirebaseAuth/Sources/Backend/RPC/FIRGetRecaptchaConfigRequest.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /** @var kGetRecaptchaConfigEndpoint
  19. @brief The "getRecaptchaConfig" endpoint.
  20. */
  21. static NSString *const kGetRecaptchaConfigEndpoint = @"recaptchaConfig";
  22. /** @var kClientType
  23. @brief The key for the "clientType" value in the request.
  24. */
  25. static NSString *const kClientTypeKey = @"clientType";
  26. /** @var kVersionKey
  27. @brief The key for the "version" value in the request.
  28. */
  29. static NSString *const kVersionKey = @"version";
  30. /** @var kTenantIDKey
  31. @brief The key for the tenant id value in the request.
  32. */
  33. static NSString *const kTenantIDKey = @"tenantId";
  34. @implementation FIRGetRecaptchaConfigRequest
  35. - (nullable instancetype)initWithClientType:(NSString *)clientType
  36. version:(NSString *)version
  37. requestConfiguration:
  38. (nonnull FIRAuthRequestConfiguration *)requestConfiguration {
  39. requestConfiguration.HTTPMethod = @"GET";
  40. self = [super initWithEndpoint:kGetRecaptchaConfigEndpoint
  41. requestConfiguration:requestConfiguration];
  42. self.useIdentityPlatform = YES;
  43. if (self) {
  44. _clientType = [clientType copy];
  45. _version = [version copy];
  46. }
  47. return self;
  48. }
  49. - (BOOL)containsPostBody {
  50. return NO;
  51. }
  52. - (nullable NSString *)queryParams {
  53. NSMutableString *queryParams = [[NSMutableString alloc] init];
  54. [queryParams appendFormat:@"&%@=%@&%@=%@", kClientTypeKey, _clientType, kVersionKey, _version];
  55. if (self.tenantID) {
  56. [queryParams appendFormat:@"&%@=%@", kTenantIDKey, self.tenantID];
  57. }
  58. return queryParams;
  59. }
  60. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  61. return nil;
  62. }
  63. @end
  64. NS_ASSUME_NONNULL_END