Skip to content
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

feat: limited v7 API integration with individual to team migration endpoint - WPB-11961 #2151

Open
wants to merge 3 commits into
base: feat/individual-to-team-migration-ui
Choose a base branch
from

Conversation

El-Fitz
Copy link
Contributor

@El-Fitz El-Fitz commented Nov 12, 2024

TaskWPB-11961 [iOS] add API endpoint for upgrading to a team

Issue

Please describe the issue.

A barebones v7 API integration, limited to adding the individual to team migration endpoint, using APIService


Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Make sure you use the API for UI elements that support large fonts.
  • All colors are taken from WireDesign.ColorTheme or constructed using WireDesign.BaseColorPalette.
  • New UI elements have Accessibility strings for VoiceOver.

Copy link
Contributor

github-actions bot commented Nov 12, 2024

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
1 files    0 ❌

Results for commit d85246c.

♻️ This comment has been updated with latest results.

WireAPI/Package.resolved Show resolved Hide resolved
WireAPI/Sources/WireAPI/Components/ResponseParser.swift Outdated Show resolved Hide resolved

public struct IndividualToTeamMigrationUseCase {
private let accountsAPI: AccountsAPI
private let logger: WireLogger = WireLogger(tag: "individual-to-team-migration")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer a static one like WireLogger.individualToTeam

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meaning instead of using the string, declare one in WireLogger+Instances.swift

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then the WireLogger has manual references to all the other modules. Isn't that... weird?

@@ -42,6 +68,12 @@ open class AuthenticatedSessionFactory {
reachability: Reachability,
minTLSVersion: String?
) {
self.apiService = APIService(
backendURL: environment.backendURL,
// TODO: Use the authentication storage from https://github.com/wireapp/wire-ios/pull/2084
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import WireDataModel


final class InMemoryAuthenticationStorage: AuthenticationStorage {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this is temporary too until renew access token PR is merged, right?
otherwise I would suggest to move to own file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already is an InMemoryAuthenticationStorage so feel free to make it public and use it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's exactly the same code, just copy-pasted.
And it is temporary until the renew access token PR is merged.

@johnxnguyen Do we want the InMemoryAuthentication to be and remain public?

Copy link
Collaborator

@johnxnguyen johnxnguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I'll wait for the conversations to be resolved before approving.

import WireDataModel


final class InMemoryAuthenticationStorage: AuthenticationStorage {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already is an InMemoryAuthenticationStorage so feel free to make it public and use it here.

@El-Fitz El-Fitz force-pushed the feat/individual-to-team-migration-ui branch from 12300f5 to 7ebdca4 Compare November 15, 2024 09:09
@El-Fitz El-Fitz force-pushed the feat/invidiual-to-team-migration-api branch from aa88e45 to d85246c Compare November 15, 2024 15:08
Copy link
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Feel free to ignore comments which I prefix with optional.

/// An error occurred while encoding the request body.
case invalidRequestBody

/// A request url is not invalid.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A request url is not invalid.
/// A request url is not valid.

override func upgradeToTeam(teamName: String) async throws -> UpgradedAccountTeam {
let components = URLComponents(string: "upgrade-personal-to-team")

guard let url = components?.url else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Personally I might force unwrap this and ensure it is tested

let name: String

init(
currency: String? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, do you expect this to be called with default values?

private var accessToken: WireAPI.AccessToken?
private var cookieData: Data?

func storeAccessToken(_ accessToken: WireAPI.AccessToken) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, are these custom setters / getters to implement AuthenticationStorage?

Copy link
Collaborator

@netbe netbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I've replied to my comments so you can finish pending points

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants