Skip to content

Commit 7ded4e2

Browse files
committed
[Auth] Update VerifyPhoneNumberRequest to have only immutable properties
1 parent c920a6a commit 7ded4e2

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

FirebaseAuth/Sources/Swift/Backend/RPC/VerifyPhoneNumberRequest.swift

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,52 +61,76 @@ class VerifyPhoneNumberRequest: IdentityToolkitRequest, AuthRPCRequest {
6161
typealias Response = VerifyPhoneNumberResponse
6262

6363
/// The verification ID obtained from the response of `sendVerificationCode`.
64-
var verificationID: String?
64+
let verificationID: String?
6565

6666
/// The verification code provided by the user.
67-
var verificationCode: String?
67+
let verificationCode: String?
6868

6969
/// The STS Access Token for the authenticated user.
7070
var accessToken: String?
7171

7272
/// The temporary proof code, previously returned from the backend.
73-
var temporaryProof: String?
73+
let temporaryProof: String?
7474

7575
/// The phone number to be verified in the request.
76-
var phoneNumber: String?
76+
let phoneNumber: String?
7777

7878
/// The type of operation triggering this verify phone number request.
79-
var operation: AuthOperationType
79+
let operation: AuthOperationType
8080

81-
/// Designated initializer.
81+
/// Convenience initializer.
8282
/// - Parameter temporaryProof: The temporary proof sent by the backed.
8383
/// - Parameter phoneNumber: The phone number associated with the credential to be signed in .
8484
/// - Parameter operation: Indicates what operation triggered the verify phone number request.
8585
/// - Parameter requestConfiguration: An object containing configurations to be added to the
8686
/// request.
87-
init(temporaryProof: String, phoneNumber: String, operation: AuthOperationType,
88-
requestConfiguration: AuthRequestConfiguration) {
89-
self.temporaryProof = temporaryProof
90-
self.phoneNumber = phoneNumber
91-
self.operation = operation
92-
super.init(endpoint: kVerifyPhoneNumberEndPoint, requestConfiguration: requestConfiguration)
87+
convenience init(temporaryProof: String, phoneNumber: String, operation: AuthOperationType,
88+
requestConfiguration: AuthRequestConfiguration) {
89+
self.init(
90+
temporaryProof: temporaryProof,
91+
phoneNumber: phoneNumber,
92+
verificationID: nil,
93+
verificationCode: nil,
94+
operation: operation,
95+
requestConfiguration: requestConfiguration
96+
)
9397
}
9498

95-
/// Designated initializer.
99+
/// Convenience initializer.
96100
/// - Parameter verificationID: The verification ID obtained from the response of
97101
/// `sendVerificationCode`.
98102
/// - Parameter verificationCode: The verification code provided by the user.
99103
/// - Parameter operation: Indicates what operation triggered the verify phone number request.
100104
/// - Parameter requestConfiguration: An object containing configurations to be added to the
101105
/// request.
102-
init(verificationID: String,
103-
verificationCode: String,
104-
operation: AuthOperationType,
105-
requestConfiguration: AuthRequestConfiguration) {
106+
convenience init(verificationID: String,
107+
verificationCode: String,
108+
operation: AuthOperationType,
109+
requestConfiguration: AuthRequestConfiguration) {
110+
self.init(
111+
temporaryProof: nil,
112+
phoneNumber: nil,
113+
verificationID: verificationID,
114+
verificationCode: verificationCode,
115+
operation: operation,
116+
requestConfiguration: requestConfiguration
117+
)
118+
}
119+
120+
private init(temporaryProof: String?, phoneNumber: String?, verificationID: String?,
121+
verificationCode: String?, operation: AuthOperationType,
122+
requestConfiguration: AuthRequestConfiguration) {
123+
self.temporaryProof = temporaryProof
124+
self.phoneNumber = phoneNumber
106125
self.verificationID = verificationID
107126
self.verificationCode = verificationCode
108127
self.operation = operation
109-
super.init(endpoint: kVerifyPhoneNumberEndPoint, requestConfiguration: requestConfiguration)
128+
super.init(
129+
endpoint: kVerifyPhoneNumberEndPoint,
130+
requestConfiguration: requestConfiguration,
131+
useIdentityPlatform: false,
132+
useStaging: false
133+
)
110134
}
111135

112136
func unencodedHTTPRequestBody() throws -> [String: AnyHashable] {

0 commit comments

Comments
 (0)