FIRFinalizeMFAEnrollmentRequest.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/LICENSE2.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 "FIRFinalizeMFAEnrollmentRequest.h"
  17. static NSString *const kFinalizeMFAEnrollmentEndPoint = @"accounts/mfaEnrollment:finalize";
  18. @implementation FIRFinalizeMFAEnrollmentRequest
  19. - (nullable instancetype)initWithIDToken:(NSString *)IDToken
  20. MFAProvider:(NSString *)MFAProvider
  21. displayName:(NSString *)displayName
  22. verificationInfo:(FIRAuthProtoFinalizeMFAPhoneRequestInfo *)verificationInfo
  23. requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
  24. self = [super initWithEndpoint:kFinalizeMFAEnrollmentEndPoint
  25. requestConfiguration:requestConfiguration
  26. useIdentityPlatform:YES
  27. useStaging:NO];
  28. if (self) {
  29. _IDToken = IDToken;
  30. _MFAProvider = MFAProvider;
  31. _displayName = displayName;
  32. _verificationInfo = verificationInfo;
  33. }
  34. return self;
  35. }
  36. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *__autoreleasing _Nullable *)error {
  37. NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
  38. if (_IDToken) {
  39. postBody[@"idToken"] = _IDToken;
  40. }
  41. if (_MFAProvider) {
  42. postBody[@"mfaProvider"] = _MFAProvider;
  43. }
  44. if (_displayName) {
  45. postBody[@"displayName"] = _displayName;
  46. }
  47. if (_verificationInfo) {
  48. if ([_verificationInfo isKindOfClass:[FIRAuthProtoFinalizeMFAPhoneRequestInfo class]]) {
  49. postBody[@"phoneVerificationInfo"] = [_verificationInfo dictionary];
  50. }
  51. }
  52. return [postBody copy];
  53. }
  54. @end