You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.8 KiB

6 years ago
6 years ago
  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 "FIRCreateAuthURIRequest.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /** @var kCreateAuthURIEndpoint
  19. @brief The "createAuthUri" endpoint.
  20. */
  21. static NSString *const kCreateAuthURIEndpoint = @"createAuthUri";
  22. /** @var kProviderIDKey
  23. @brief The key for the "providerId" value in the request.
  24. */
  25. static NSString *const kProviderIDKey = @"providerId";
  26. /** @var kIdentifierKey
  27. @brief The key for the "identifier" value in the request.
  28. */
  29. static NSString *const kIdentifierKey = @"identifier";
  30. /** @var kContinueURIKey
  31. @brief The key for the "continueUri" value in the request.
  32. */
  33. static NSString *const kContinueURIKey = @"continueUri";
  34. /** @var kOpenIDRealmKey
  35. @brief The key for the "openidRealm" value in the request.
  36. */
  37. static NSString *const kOpenIDRealmKey = @"openidRealm";
  38. /** @var kClientIDKey
  39. @brief The key for the "clientId" value in the request.
  40. */
  41. static NSString *const kClientIDKey = @"clientId";
  42. /** @var kContextKey
  43. @brief The key for the "context" value in the request.
  44. */
  45. static NSString *const kContextKey = @"context";
  46. /** @var kAppIDKey
  47. @brief The key for the "appId" value in the request.
  48. */
  49. static NSString *const kAppIDKey = @"appId";
  50. @implementation FIRCreateAuthURIRequest
  51. - (nullable instancetype)initWithIdentifier:(NSString *)identifier
  52. continueURI:(NSString *)continueURI
  53. requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
  54. self = [super initWithEndpoint:kCreateAuthURIEndpoint requestConfiguration:requestConfiguration];
  55. if (self) {
  56. _identifier = [identifier copy];
  57. _continueURI = [continueURI copy];
  58. }
  59. return self;
  60. }
  61. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  62. NSMutableDictionary *postBody = [@{
  63. kIdentifierKey : _identifier,
  64. kContinueURIKey : _continueURI
  65. } mutableCopy];
  66. if (_providerID) {
  67. postBody[kProviderIDKey] = _providerID;
  68. }
  69. if (_openIDRealm) {
  70. postBody[kOpenIDRealmKey] = _openIDRealm;
  71. }
  72. if (_clientID) {
  73. postBody[kClientIDKey] = _clientID;
  74. }
  75. if (_context) {
  76. postBody[kContextKey] = _context;
  77. }
  78. if (_appID) {
  79. postBody[kAppIDKey] = _appID;
  80. }
  81. return postBody;
  82. }
  83. @end
  84. NS_ASSUME_NONNULL_END