-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathStytchClient.OTP.authenticate+AsyncVariants.generated.swift
33 lines (31 loc) · 1.55 KB
/
StytchClient.OTP.authenticate+AsyncVariants.generated.swift
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
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
import Combine
import Foundation
public extension StytchClient.OTP {
/// Wraps the OTP [authenticate](https://stytch.com/docs/api/authenticate-otp) API endpoint which validates the one-time code passed in. If this method succeeds, the user will be logged in, granted an active session, and the session cookies will be minted and stored in `HTTPCookieStorage.shared`.
func authenticate(parameters: AuthenticateParameters, completion: @escaping Completion<AuthenticateResponse>) {
Task {
do {
completion(.success(try await authenticate(parameters: parameters)))
} catch {
completion(.failure(error))
}
}
}
/// Wraps the OTP [authenticate](https://stytch.com/docs/api/authenticate-otp) API endpoint which validates the one-time code passed in. If this method succeeds, the user will be logged in, granted an active session, and the session cookies will be minted and stored in `HTTPCookieStorage.shared`.
func authenticate(parameters: AuthenticateParameters) -> AnyPublisher<AuthenticateResponse, Error> {
return Deferred {
Future({ promise in
Task {
do {
promise(.success(try await authenticate(parameters: parameters)))
} catch {
promise(.failure(error))
}
}
})
}
.eraseToAnyPublisher()
}
}