-
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
Conversation
8d7527d
to
d450152
Compare
public extension Sessions { | ||
// sourcery: AsyncVariants, (NOTE: - must use /// doc comment styling) | ||
/// Use this endpoint to exchange a Member's existing session for another session in a different Organization. | ||
func exchnage(parameters: ExchangeParameters) async throws -> B2BAuthenticateResponse { |
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.
typo: exchange
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.
Good catch, just an fyi, I am super dyslexic!
} | ||
Task { | ||
do { | ||
let parameters = Sessions<B2BAuthenticateResponse>.ExchangeParameters(organizationID: organizationID) |
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 do StytchB2BClient.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.
b73c0fc
to
7b75f23
Compare
7b75f23
to
6c0ea0f
Compare
Linear Ticket: SDK-1473: Add exchange method to session client
Notes:
Changes:
Sessions
to include anexchnage
method. And add theExchangeParameters
type.private let defaults: UserDefaults = .standard
and instead refer directly toUserDefaults.standard
. I feel that this is confusing and would imply custom usage of user default and not the standard usage.SceneDelegate
, wrong logic was being used to parse out thePasswordsViewController
.RootViewController
to stop popping to the root view controller every time we got a notification about the session info changing. TheRootViewController
only ever set the project id and that almost never changes. And with the improved reporting throughout the app, we know when the user needs to be authenticated.Checklist: