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.

95 lines
2.7 KiB

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