aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Auth/Source/RPCs/FIRCreateAuthURIRequest.m
blob: 6d2b9e9983aba7f003c62715638c9681197ef537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * Copyright 2017 Google
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#import "FIRCreateAuthURIRequest.h"

/** @var kCreateAuthURIEndpoint
    @brief The "createAuthUri" endpoint.
 */
static NSString *const kCreateAuthURIEndpoint = @"createAuthUri";

/** @var kProviderIDKey
    @brief The key for the "providerId" value in the request.
 */
static NSString *const kProviderIDKey = @"providerId";

/** @var kIdentifierKey
    @brief The key for the "identifier" value in the request.
 */
static NSString *const kIdentifierKey = @"identifier";

/** @var kContinueURIKey
    @brief The key for the "continueUri" value in the request.
 */
static NSString *const kContinueURIKey = @"continueUri";

/** @var kOpenIDRealmKey
    @brief The key for the "openidRealm" value in the request.
 */
static NSString *const kOpenIDRealmKey = @"openidRealm";

/** @var kClientIDKey
    @brief The key for the "clientId" value in the request.
 */
static NSString *const kClientIDKey = @"clientId";

/** @var kContextKey
    @brief The key for the "context" value in the request.
 */
static NSString *const kContextKey = @"context";

/** @var kAppIDKey
    @brief The key for the "appId" value in the request.
 */
static NSString *const kAppIDKey = @"appId";

@implementation FIRCreateAuthURIRequest

- (nullable instancetype)initWithIdentifier:(NSString *)identifier
                                continueURI:(NSString *)continueURI
                                     APIKey:(NSString *)APIKey {
  self = [super initWithEndpoint:kCreateAuthURIEndpoint APIKey:APIKey];
  if (self) {
    _identifier = [identifier copy];
    _continueURI = [continueURI copy];
  }
  return self;
}

- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  NSMutableDictionary *postBody = [@{
    kIdentifierKey : _identifier,
    kContinueURIKey : _continueURI
  } mutableCopy];
  if (_providerID) {
    postBody[kProviderIDKey] = _providerID;
  }
  if (_openIDRealm) {
    postBody[kOpenIDRealmKey] = _openIDRealm;
  }
  if (_clientID) {
    postBody[kClientIDKey] = _clientID;
  }
  if (_context) {
    postBody[kContextKey] = _context;
  }
  if (_appID) {
    postBody[kAppIDKey] = _appID;
  }
  return postBody;
}

@end