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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions WireAPI/Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
El-Fitz marked this conversation as resolved.
Show resolved Hide resolved
"originHash" : "2ba11e1655444cb2c2454eeba5934b2d91ed9ad986846082e63f9d8aa5888465",
"pins" : [
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-docc-plugin",
"state" : {
"revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
"version" : "1.4.3"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "42a086182681cf661f5c47c9b7dc3931de18c6d7",
"version" : "1.17.6"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
}
],
"version" : 3
}
28 changes: 28 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

import Foundation

public protocol AccountsAPI {

/// Convert the account from individual to team.
///
///

func upgradeToTeam(teamName: String) async throws -> UpgradedAccountTeam
}
58 changes: 58 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPIBuilder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

/// A builder for `AccountsAPI`.

public struct AccountsAPIBuilder {

let apiService: any APIServiceProtocol

/// Create a new builder.
///
/// - Parameter apiService: An api service.

public init(apiService: any APIServiceProtocol) {
self.apiService = apiService
}

/// Make a versioned `AccountsAPI`.
///
/// - Parameter version: An api version.
/// - Returns: A versioned `AccountsAPI`.

public func makeAPI(for version: APIVersion) -> any AccountsAPI {
switch version {
case .v0:
AccountsAPIV0(apiService: apiService)
case .v1:
AccountsAPIV1(apiService: apiService)
case .v2:
AccountsAPIV2(apiService: apiService)
case .v3:
AccountsAPIV3(apiService: apiService)
case .v4:
AccountsAPIV4(apiService: apiService)
case .v5:
AccountsAPIV5(apiService: apiService)
case .v6:
AccountsAPIV6(apiService: apiService)
case .v7:
AccountsAPIV7(apiService: apiService)
}
}
}
35 changes: 35 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPIError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

/// Errors originating from `AccountsAPI`.
public enum AccountsAPIError: Error {
/// An error occurred while encoding the request body.
case invalidRequestBody

/// A request url is invalid.
case invalidURL

/// Unsupported endpoint for API version
case unsupportedEndpointForAPIVersion

/// The user is already in a team
case userAlreadyInATeam

/// The user could not be found
case userNotFound
}
35 changes: 35 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPIV0.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

import Foundation

class AccountsAPIV0: AccountsAPI, VersionedAPI {
let apiService: any APIServiceProtocol

init(apiService: any APIServiceProtocol) {
self.apiService = apiService
}

var apiVersion: APIVersion {
.v0
}

func upgradeToTeam(teamName: String) async throws -> UpgradedAccountTeam {
throw AccountsAPIError.unsupportedEndpointForAPIVersion
}
}
23 changes: 23 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPIV1.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

class AccountsAPIV1: AccountsAPIV0 {
override var apiVersion: APIVersion {
.v1
}
}
23 changes: 23 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPIV2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

class AccountsAPIV2: AccountsAPIV1 {
override var apiVersion: APIVersion {
.v2
}
}
23 changes: 23 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPIV3.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

class AccountsAPIV3: AccountsAPIV2 {
override var apiVersion: APIVersion {
.v3
}
}
23 changes: 23 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPIV4.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

class AccountsAPIV4: AccountsAPIV3 {
override var apiVersion: APIVersion {
.v4
}
}
23 changes: 23 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPIV5.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

class AccountsAPIV5: AccountsAPIV4 {
override var apiVersion: APIVersion {
.v5
}
}
23 changes: 23 additions & 0 deletions WireAPI/Sources/WireAPI/APIs/AccountsAPI/AccountsAPIV6.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Wire
// Copyright (C) 2024 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

class AccountsAPIV6: AccountsAPIV5 {
override var apiVersion: APIVersion {
.v6
}
}
Loading
Loading