No Description

FIREmailLinkSignInRequest.m 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 "FIREmailLinkSignInRequest.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /** @var kEmailLinkSigninEndpoint
  19. @brief The "EmailLinkSignin" endpoint.
  20. */
  21. static NSString *const kEmailLinkSigninEndpoint = @"emailLinkSignin";
  22. /** @var kEmailKey
  23. @brief The key for the "identifier" value in the request.
  24. */
  25. static NSString *const kEmailKey = @"email";
  26. /** @var kEmailLinkKey
  27. @brief The key for the "emailLink" value in the request.
  28. */
  29. static NSString *const kOOBCodeKey = @"oobCode";
  30. /** @var kIDTokenKey
  31. @brief The key for the "IDToken" value in the request.
  32. */
  33. static NSString *const kIDTokenKey = @"idToken";
  34. /** @var kPostBodyKey
  35. @brief The key for the "postBody" value in the request.
  36. */
  37. static NSString *const kPostBodyKey = @"postBody";
  38. @implementation FIREmailLinkSignInRequest
  39. - (instancetype)initWithEmail:(NSString *)email
  40. oobCode:(NSString *)oobCode
  41. requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
  42. self = [super initWithEndpoint:kEmailLinkSigninEndpoint
  43. requestConfiguration:requestConfiguration];
  44. if (self) {
  45. _email = email;
  46. _oobCode = oobCode;
  47. }
  48. return self;
  49. }
  50. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  51. NSMutableDictionary *postBody = [@{
  52. kEmailKey : _email,
  53. kOOBCodeKey : _oobCode,
  54. } mutableCopy];
  55. if (_IDToken) {
  56. postBody[kIDTokenKey] = _IDToken;
  57. }
  58. return postBody;
  59. }
  60. @end
  61. NS_ASSUME_NONNULL_END