FIRAuthProtoStartMFAPhoneRequestInfo.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2019 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 "FirebaseAuth/Sources/Backend/RPC/Proto/Phone/FIRAuthProtoStartMFAPhoneRequestInfo.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /** @var kPhoneNumberKey
  19. @brief The key for the Phone Number parameter in the request.
  20. */
  21. static NSString *const kPhoneNumberKey = @"phoneNumber";
  22. /** @var kReceiptKey
  23. @brief The key for the receipt parameter in the request.
  24. */
  25. static NSString *const kReceiptKey = @"iosReceipt";
  26. /** @var kSecretKey
  27. @brief The key for the Secret parameter in the request.
  28. */
  29. static NSString *const kSecretKey = @"iosSecret";
  30. /** @var kreCAPTCHATokenKey
  31. @brief The key for the reCAPTCHAToken parameter in the request.
  32. */
  33. static NSString *const kreCAPTCHATokenKey = @"recaptchaToken";
  34. @implementation FIRAuthProtoStartMFAPhoneRequestInfo
  35. - (nullable instancetype)initWithPhoneNumber:(NSString *)phoneNumber
  36. appCredential:(nullable FIRAuthAppCredential *)appCredential
  37. reCAPTCHAToken:(nullable NSString *)reCAPTCHAToken {
  38. self = [super init];
  39. if (self) {
  40. _phoneNumber = [phoneNumber copy];
  41. _appCredential = appCredential;
  42. _reCAPTCHAToken = [reCAPTCHAToken copy];
  43. }
  44. return self;
  45. }
  46. - (NSDictionary *)dictionary {
  47. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  48. if (_phoneNumber) {
  49. dict[kPhoneNumberKey] = _phoneNumber;
  50. }
  51. if (_appCredential.receipt) {
  52. dict[kReceiptKey] = _appCredential.receipt;
  53. }
  54. if (_appCredential.secret) {
  55. dict[kSecretKey] = _appCredential.secret;
  56. }
  57. if (_reCAPTCHAToken) {
  58. dict[kreCAPTCHATokenKey] = _reCAPTCHAToken;
  59. }
  60. return [dict copy];
  61. }
  62. @end
  63. NS_ASSUME_NONNULL_END