FIRStartMFASignInRequest.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 "FIRStartMFASignInRequest.h"
  17. static NSString *const kStartMFASignInEndPoint = @"accounts/mfaSignIn:start";
  18. @implementation FIRStartMFASignInRequest
  19. - (nullable instancetype)initWithMFAProvider:(NSString *)MFAProvider
  20. MFAPendingCredential:(NSString *)MFAPendingCredential
  21. MFAEnrollmentID:(NSString *)MFAEnrollmentID
  22. signInInfo:(FIRAuthProtoStartMFAPhoneRequestInfo *)signInInfo
  23. requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
  24. self = [super initWithEndpoint:kStartMFASignInEndPoint
  25. requestConfiguration:requestConfiguration
  26. useIdentityPlatform:YES
  27. useStaging:NO];
  28. if (self) {
  29. _MFAProvider = MFAProvider;
  30. _MFAPendingCredential = MFAPendingCredential;
  31. _MFAEnrollmentID = MFAEnrollmentID;
  32. _signInInfo = signInInfo;
  33. }
  34. return self;
  35. }
  36. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *__autoreleasing _Nullable *)error {
  37. NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
  38. if (_MFAProvider) {
  39. postBody[@"mfaProvider"] = _MFAProvider;
  40. }
  41. if (_MFAPendingCredential) {
  42. postBody[@"mfaPendingCredential"] = _MFAPendingCredential;
  43. }
  44. if (_MFAEnrollmentID) {
  45. postBody[@"mfaEnrollmentId"] = _MFAEnrollmentID;
  46. }
  47. if (_signInInfo) {
  48. if ([_signInInfo isKindOfClass:[FIRAuthProtoStartMFAPhoneRequestInfo class]]) {
  49. postBody[@"phoneSignInInfo"] = [_signInInfo dictionary];
  50. }
  51. }
  52. return [postBody copy];
  53. }
  54. @end