Skip to content

Commit 5846f43

Browse files
committed
Use prefixed UUIDs for Users and Places
1 parent 5b73d50 commit 5846f43

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

Package.resolved

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@
66
"repositoryURL": "https://github.com/MonkiProjects/monki-projects-model-swift",
77
"state": {
88
"branch": null,
9-
"revision": "b6557a9e8d4bf6ed6dadc239759d567985a75370",
10-
"version": "0.4.0"
9+
"revision": "63e0b3c912886d8c7555efd15f9f72d1860e696d",
10+
"version": "0.5.0"
11+
}
12+
},
13+
{
14+
"package": "swift-prefixed-uuid",
15+
"repositoryURL": "https://github.com/RemiBardon/swift-prefixed-uuid",
16+
"state": {
17+
"branch": null,
18+
"revision": "93e21694b11da9d9ff691f1cda7ac7d4c4bc361a",
19+
"version": "1.0.2"
1120
}
1221
}
1322
]

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let package = Package(
1919
.package(
2020
name: "monki-projects-model",
2121
url: "https://github.com/MonkiProjects/monki-projects-model-swift",
22-
.upToNextMajor(from: "0.4.0")
22+
.upToNextMinor(from: "0.5.0")
2323
),
2424
],
2525
targets: [

Sources/MonkiProjectsAPIClient/MPAPIUserRepository.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ public final class MPAPIUserRepository: WebAPI, WebUserRepository {
3636
return self.authenticatedRequest(endpoints.createUser(), body: create)
3737
}
3838

39-
public func getUser(_ userId: UUID) -> AnyPublisher<User.Public.Full, Error> {
39+
public func getUser(_ userId: User.ID) -> AnyPublisher<User.Public.Full, Error> {
4040
return self.authenticatedRequest(endpoints.getUser(userId))
4141
}
4242

43-
public func updateUser(_ userId: UUID, with update: User.Update) -> AnyPublisher<User.Public.Full, Error> {
43+
public func updateUser(_ userId: User.ID, with update: User.Update) -> AnyPublisher<User.Public.Full, Error> {
4444
return self.authenticatedRequest(endpoints.updateUser(userId), body: update)
4545
}
4646

47-
public func deleteUser(_ userId: UUID) -> AnyPublisher<Void, Error> {
47+
public func deleteUser(_ userId: User.ID) -> AnyPublisher<Void, Error> {
4848
return self.authenticatedRequest(endpoints.deleteUser(userId))
4949
}
5050

@@ -61,17 +61,17 @@ public final class MPAPIUserRepository: WebAPI, WebUserRepository {
6161
}
6262

6363
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
64-
public func getUser(_ userId: UUID) async throws -> User.Public.Full {
64+
public func getUser(_ userId: User.ID) async throws -> User.Public.Full {
6565
return try await self.authenticatedRequest(endpoints.getUser(userId))
6666
}
6767

6868
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
69-
public func updateUser(_ userId: UUID, with update: User.Update) async throws -> User.Public.Full {
69+
public func updateUser(_ userId: User.ID, with update: User.Update) async throws -> User.Public.Full {
7070
return try await self.authenticatedRequest(endpoints.updateUser(userId), body: update)
7171
}
7272

7373
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
74-
public func deleteUser(_ userId: UUID) async throws {
74+
public func deleteUser(_ userId: User.ID) async throws {
7575
return try await self.authenticatedRequest(endpoints.deleteUser(userId))
7676
}
7777

@@ -91,15 +91,15 @@ extension MPAPIUserRepository {
9191
return self.post("/users/v1")
9292
}
9393

94-
func getUser(_ userId: UUID) -> Endpoint {
94+
func getUser(_ userId: User.ID) -> Endpoint {
9595
return self.get("/users/v1/\(userId)")
9696
}
9797

98-
func updateUser(_ userId: UUID) -> Endpoint {
98+
func updateUser(_ userId: User.ID) -> Endpoint {
9999
return self.patch("/users/v1/\(userId)")
100100
}
101101

102-
func deleteUser(_ userId: UUID) -> Endpoint {
102+
func deleteUser(_ userId: User.ID) -> Endpoint {
103103
return self.delete("/users/v1/\(userId)")
104104
}
105105

Sources/MonkiProjectsAPIClient/Protocols/WebUserRepository.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public protocol WebUserRepository: AnyObject, WebAPI {
1919

2020
func createUser(_ create: User.Create) -> AnyPublisher<User.Private, Error>
2121

22-
func getUser(_ userId: UUID) -> AnyPublisher<User.Public.Full, Error>
22+
func getUser(_ userId: User.ID) -> AnyPublisher<User.Public.Full, Error>
2323

24-
func updateUser(_ userId: UUID, with update: User.Update) -> AnyPublisher<User.Public.Full, Error>
24+
func updateUser(_ userId: User.ID, with update: User.Update) -> AnyPublisher<User.Public.Full, Error>
2525

26-
func deleteUser(_ userId: UUID) -> AnyPublisher<Void, Error>
26+
func deleteUser(_ userId: User.ID) -> AnyPublisher<Void, Error>
2727

2828
// MARK: - Swift async/await
2929

@@ -34,13 +34,13 @@ public protocol WebUserRepository: AnyObject, WebAPI {
3434
func createUser(_ create: User.Create) async throws -> User.Private
3535

3636
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
37-
func getUser(_ userId: UUID) async throws -> User.Public.Full
37+
func getUser(_ userId: User.ID) async throws -> User.Public.Full
3838

3939
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
40-
func updateUser(_ userId: UUID, with update: User.Update) async throws -> User.Public.Full
40+
func updateUser(_ userId: User.ID, with update: User.Update) async throws -> User.Public.Full
4141

4242
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
43-
func deleteUser(_ userId: UUID) async throws
43+
func deleteUser(_ userId: User.ID) async throws
4444

4545
}
4646

Tests/MonkiProjectsAPIClientTests/Helpers/XCTestCase+Cleaning.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
import MonkiProjectsAPIClient
1010
import XCTest
1111
import Networking
12+
import MonkiProjectsModel
1213

1314
extension XCTestCase {
1415

1516
/// Delete created user
1617
internal func deletePossiblyCreatedUserAfterTestFinishes(
17-
_ userId: UUID,
18+
_ userId: User.ID,
1819
_ username: String,
1920
_ password: String
2021
) {

0 commit comments

Comments
 (0)