FIRCreateAuthURIRequest.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 "FirebaseAuth/Sources/Backend/RPC/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. /** @var kTenantIDKey
  51. @brief The key for the tenant id value in the request.
  52. */
  53. static NSString *const kTenantIDKey = @"tenantId";
  54. @implementation FIRCreateAuthURIRequest
  55. - (nullable instancetype)initWithIdentifier:(NSString *)identifier
  56. continueURI:(NSString *)continueURI
  57. requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
  58. self = [super initWithEndpoint:kCreateAuthURIEndpoint requestConfiguration:requestConfiguration];
  59. if (self) {
  60. _identifier = [identifier copy];
  61. _continueURI = [continueURI copy];
  62. }
  63. return self;
  64. }
  65. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  66. NSMutableDictionary *postBody =
  67. [@{kIdentifierKey : _identifier, kContinueURIKey : _continueURI} mutableCopy];
  68. if (_providerID) {
  69. postBody[kProviderIDKey] = _providerID;
  70. }
  71. if (_openIDRealm) {
  72. postBody[kOpenIDRealmKey] = _openIDRealm;
  73. }
  74. if (_clientID) {
  75. postBody[kClientIDKey] = _clientID;
  76. }
  77. if (_context) {
  78. postBody[kContextKey] = _context;
  79. }
  80. if (_appID) {
  81. postBody[kAppIDKey] = _appID;
  82. }
  83. if (self.tenantID) {
  84. postBody[kTenantIDKey] = self.tenantID;
  85. }
  86. return [postBody copy];
  87. }
  88. @end
  89. NS_ASSUME_NONNULL_END