-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK-1473][B2B] Add exchange method to session client #233
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
Sources/StytchCore/Generated/Sessions.exchange+AsyncVariants.generated.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery | ||
// DO NOT EDIT | ||
import Combine | ||
import Foundation | ||
|
||
public extension Sessions { | ||
/// Use this endpoint to exchange a Member's existing session for another session in a different Organization. | ||
func exchange(parameters: ExchangeParameters, completion: @escaping Completion<B2BAuthenticateResponse>) { | ||
Task { | ||
do { | ||
completion(.success(try await exchange(parameters: parameters))) | ||
} catch { | ||
completion(.failure(error)) | ||
} | ||
} | ||
} | ||
|
||
/// Use this endpoint to exchange a Member's existing session for another session in a different Organization. | ||
func exchange(parameters: ExchangeParameters) -> AnyPublisher<B2BAuthenticateResponse, Error> { | ||
return Deferred { | ||
Future({ promise in | ||
Task { | ||
do { | ||
promise(.success(try await exchange(parameters: parameters))) | ||
} catch { | ||
promise(.failure(error)) | ||
} | ||
} | ||
}) | ||
} | ||
.eraseToAnyPublisher() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Sources/StytchCore/StytchClientCommon/Sessions/SessionsRoute.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats with the
<B2BAuthenticateResponse>
? Is it because it's using the Session client defined in StytchClientCommon? Should we go ahead and break out the session clients into separate ones for B2B and B2C? that way we could doStytchB2BClient.Sessions.ExchangeParameters()
, right? Just for consistency with all the other products/methods. I think this current approach might lead to developer confusion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally feel that it is good the way it is and a good use of swift generics. If I can figure out something with sorcery where I can add a "where" clause to the protocol extensions then we can remove this.
This is the way around this:
public extension Sessions where AuthResponseType == B2BAuthenticateResponse
Then:
Sessions<B2BAuthenticateResponse>.ExchangeParameters
turns into:
Sessions.ExchangeParameters
But currently I can't figure out how to do that with sorcery and I posted a question about how to do that for the generated files here: krzysztofzablocki/Sourcery#1337.
I would only think we need to name space
Session
if it was to be used in tandem with the B2C session.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we split out the sessions clients (which we do on Android), would that avoid the unknown sourcery stuff? If so, that plus being able to namespace the parameters seems like a win to me. We already have some customer confusion with using two different clients, I just think that this might add to that cognitive load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, after thinking about it and pair programming, I think we do need separate objects for b2b session and b2c session, lets make a ticket to capture this work.