No Description

FIRSendVerificationCodeRequest.m 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2017 Google
  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 "FIRSendVerificationCodeRequest.h"
  17. #import "FIRAuthAppCredential.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. /** @var kSendVerificationCodeEndPoint
  20. @brief The "sendVerificationCodeEnd" endpoint.
  21. */
  22. static NSString *const kSendVerificationCodeEndPoint = @"sendVerificationCode";
  23. /** @var kPhoneNumberKey
  24. @brief The key for the Phone Number parameter in the request.
  25. */
  26. static NSString *const kPhoneNumberKey = @"phoneNumber";
  27. /** @var kReceiptKey
  28. @brief The key for the receipt parameter in the request.
  29. */
  30. static NSString *const kReceiptKey = @"iosReceipt";
  31. /** @var kSecretKey
  32. @brief The key for the Secret parameter in the request.
  33. */
  34. static NSString *const kSecretKey = @"iosSecret";
  35. /** @var kreCAPTCHATokenKey
  36. @brief The key for the reCAPTCHAToken parameter in the request.
  37. */
  38. static NSString *const kreCAPTCHATokenKey = @"recaptchaToken";
  39. @implementation FIRSendVerificationCodeRequest {
  40. }
  41. - (nullable instancetype)initWithPhoneNumber:(NSString *)phoneNumber
  42. appCredential:(nullable FIRAuthAppCredential *)appCredential
  43. reCAPTCHAToken:(nullable NSString *)reCAPTCHAToken
  44. requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
  45. self = [super initWithEndpoint:kSendVerificationCodeEndPoint
  46. requestConfiguration:requestConfiguration];
  47. if (self) {
  48. _phoneNumber = [phoneNumber copy];
  49. _appCredential = appCredential;
  50. _reCAPTCHAToken = [reCAPTCHAToken copy];
  51. }
  52. return self;
  53. }
  54. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  55. NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
  56. if (_phoneNumber) {
  57. postBody[kPhoneNumberKey] = _phoneNumber;
  58. }
  59. if (_appCredential.receipt) {
  60. postBody[kReceiptKey] = _appCredential.receipt;
  61. }
  62. if (_appCredential.secret) {
  63. postBody[kSecretKey] = _appCredential.secret;
  64. }
  65. if (_reCAPTCHAToken) {
  66. postBody[kreCAPTCHATokenKey] = _reCAPTCHAToken;
  67. }
  68. return postBody;
  69. }
  70. @end
  71. NS_ASSUME_NONNULL_END