Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public struct AuthAPIRepository: AuthRepository {
}

public func addDevice(fcmToken: String) async throws {
_ = try await apiClient.registerLocal_1(path: .init(id: fcmToken))
_ = try await apiClient.addRegistrationId(path: .init(id: fcmToken))
}

public func logout(fcmToken: String) async throws {
Expand All @@ -104,7 +104,7 @@ public struct AuthAPIRepository: AuthRepository {
}

public func fetchSocialAuthProviderState() async throws -> SocialAuthProviderState {
let result = try await apiClient.getAuthProviders()
let result = try await apiClient.checkAuthProviders()
let json: Components.Schemas.AuthProvidersCheckDto = try result.ok.body.json
return .init(
apple: json.apple ? .linked : .unlinked,
Expand All @@ -120,7 +120,7 @@ public struct AuthAPIRepository: AuthRepository {

extension AuthAPIRepository {
public func getLinkedEmail(localID: String) async throws -> String {
let result = try await apiClient.getMaskedEmail()
let result = try await apiClient.getMaskedEmail(body: .json(.init(user_id: localID)))
let json = try result.ok.body.json
return json.email
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public struct Friend: Sendable, Equatable, Identifiable {
public let nickname: String
public let tag: String
public let displayName: String?
public let createdAt: Date

public var effectiveDisplayName: String {
displayName ?? "\(nickname)#\(tag)"
Expand All @@ -25,14 +24,12 @@ public struct Friend: Sendable, Equatable, Identifiable {
nickname: String,
tag: String,
displayName: String? = nil,
createdAt: Date
) {
self.id = id
self.userId = userId
self.nickname = nickname
self.tag = tag
self.displayName = displayName
self.createdAt = createdAt
}
}

Expand Down Expand Up @@ -63,7 +60,6 @@ public enum FriendState: String, Sendable {
nickname: "김철수",
tag: "1234",
displayName: "철수",
createdAt: Date()
)

public static let preview2 = Friend(
Expand All @@ -72,7 +68,6 @@ public enum FriendState: String, Sendable {
nickname: "이영희",
tag: "5678",
displayName: nil,
createdAt: Date()
)

public static let preview3 = Friend(
Expand All @@ -81,7 +76,6 @@ public enum FriendState: String, Sendable {
nickname: "박민수",
tag: "9012",
displayName: "민수님",
createdAt: Date().addingTimeInterval(-86400)
)

public static let preview4 = Friend(
Expand All @@ -90,7 +84,6 @@ public enum FriendState: String, Sendable {
nickname: "최지현",
tag: "3456",
displayName: nil,
createdAt: Date().addingTimeInterval(-172800)
)

public static let previewRequested = [
Expand All @@ -100,15 +93,13 @@ public enum FriendState: String, Sendable {
nickname: "정수빈",
tag: "7890",
displayName: nil,
createdAt: Date()
),
Friend(
id: "friend5b",
userId: "user5b",
nickname: "김민수",
tag: "7891",
displayName: nil,
createdAt: Date()
),
]

Expand All @@ -118,7 +109,6 @@ public enum FriendState: String, Sendable {
nickname: "강예진",
tag: "2345",
displayName: nil,
createdAt: Date()
)

public static var previews: [Friend] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TimetableInterface
@Spyable
protocol FriendsRepository: Sendable {
func getFriends(state: FriendState) async throws -> [Friend]
func requestFriend(nickname: String) async throws -> [Friend]
func requestFriend(nickname: String) async throws
func acceptFriend(friendID: String) async throws
func declineFriend(friendID: String) async throws
func breakFriend(friendID: String) async throws
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@
}
}

func requestFriend(nickname: String) async throws -> [Friend] {
func requestFriend(nickname: String) async throws {
try await Task.sleep(for: .seconds(1))
let newFriend = Friend(
id: UUID().uuidString,
userId: UUID().uuidString,
nickname: nickname,
tag: String(Int.random(in: 1000...9999)),
displayName: nil,
createdAt: Date()
)
requestingFriends.append(newFriend)
return requestingFriends
}

func acceptFriend(friendID: String) async throws {
Expand Down Expand Up @@ -74,7 +72,6 @@
nickname: friend.nickname,
tag: friend.tag,
displayName: displayName,
createdAt: friend.createdAt
)
}
}
Expand Down Expand Up @@ -111,7 +108,6 @@
nickname: "카카오친구",
tag: String(Int.random(in: 1000...9999)),
displayName: nil,
createdAt: Date()
)
activeFriends.append(newFriend)
return newFriend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,13 @@ struct FriendsAPIRepository: FriendsRepository {
nickname: dto.nickname.nickname,
tag: dto.nickname.tag,
displayName: dto.displayName,
createdAt: dto.createdAt
)
}
}

func requestFriend(nickname: String) async throws -> [Friend] {
func requestFriend(nickname: String) async throws {
let request = Components.Schemas.FriendRequest(nickname: nickname)
let response = try await apiClient.requestFriend(body: .json(request)).ok.body.json
return response.content.map { dto in
Friend(
id: dto.id,
userId: dto.userId,
nickname: dto.nickname.nickname,
tag: dto.nickname.tag,
displayName: dto.displayName,
createdAt: dto.createdAt
)
}
_ = try await apiClient.requestFriend(body: .json(request))
}

func acceptFriend(friendID: String) async throws {
Expand Down Expand Up @@ -80,7 +69,7 @@ struct FriendsAPIRepository: FriendsRepository {
let timetableDto = try await apiClient.getPrimaryTable(
path: .init(friendId: friendID),
query: .init(
semester: String(quarter.semester.rawValue),
semester: require(.init(rawValue: quarter.semester.rawValue)),
year: Int32(quarter.year)
)
).ok.body.json
Expand All @@ -100,12 +89,11 @@ struct FriendsAPIRepository: FriendsRepository {
path: .init(requestToken: requestToken)
).ok.body.json
return Friend(
id: response.id,
userId: response.userId,
nickname: response.nickname.nickname,
tag: response.nickname.tag,
id: response.first.id ?? "",
userId: response.second.id ?? "",
nickname: response.second.nicknameWithoutTag,
tag: String(response.second.nicknameTag),
Comment on lines +92 to +95
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Using optional chaining with empty string fallbacks (e.g., response.first.id ?? '') can mask API contract violations. If these IDs are truly required, the code should fail explicitly rather than silently defaulting to empty strings, which could lead to bugs downstream where empty IDs are used.

Copilot uses AI. Check for mistakes.
displayName: nil,
createdAt: Date()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class FriendRequestViewModel {

/// Request friend by nickname#tag format
func requestFriend(nickname: String) async throws {
_ = try await friendsRepository.requestFriend(nickname: nickname)
try await friendsRepository.requestFriend(nickname: nickname)
// Refresh requested friends list after successful request
try await friendsViewModel.refreshRequestedFriends()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ struct FriendEditDisplayNameSheet: View {
nickname: "홍길동",
tag: "1234",
displayName: nil,
createdAt: Date()
),
viewModel: .init(friendsViewModel: .init())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ extension ManageOptionButton {
nickname: "홍길동",
tag: "1234",
displayName: nil,
createdAt: Date()
),
viewModel: .init(friendsViewModel: .init())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ struct NotificationAPIRepository: NotificationRepository {

func fetchNotifications(offset: Int, limit: Int, markAsRead: Bool) async throws -> [NotificationModel] {
let explicit = markAsRead ? 1 : 0
return try await apiClient.getNotification(
return try await apiClient.getNotifications(
query: .init(
offset: String(offset),
limit: String(limit),
explicit: String(explicit)
offset: Int64(offset),
limit: Int32(limit),
explicit: Int32(explicit)
)
).ok.body.json.compactMap {
try NotificationModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public struct ThemeAPIRepository: ThemeRepository {
public init() {}

public func fetchThemes() async throws -> [Theme] {
try await Task.sleep(for: .seconds(3))
return try await apiClient.getThemes(query: .init(state: "")).ok.body.json
return try await apiClient.getThemes().ok.body.json
.compactMap { dto in
try? dto.toTheme()
}
Expand All @@ -26,25 +25,32 @@ public struct ThemeAPIRepository: ThemeRepository {
try await apiClient.modifyTheme(
path: .init(themeId: theme.id),
body: .json(
theme.toPayload()
theme.toModifyPayload()
)
).ok.body.json.toTheme()
}

public func createTheme(theme: Theme) async throws -> Theme {
try await apiClient.addTheme(
body: .json(
theme.toPayload()
theme.toAddPayload()
)
).ok.body.json.toTheme()
}
}

extension Theme {
fileprivate func toPayload() -> Components.Schemas.TimetableThemeAddRequestDto {
fileprivate func toAddPayload() -> Components.Schemas.TimetableThemeAddRequestDto {
.init(
colors: colors.map { .init(bg: $0.bgHex, fg: $0.fgHex) },
name: name,
name: name
)
}

fileprivate func toModifyPayload() -> Components.Schemas.TimetableThemeModifyRequestDto {
.init(
colors: colors.map { .init(bg: $0.bgHex, fg: $0.fgHex) },
name: name
)
}
Comment on lines 51 to 53
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The toAddPayload() and toModifyPayload() methods contain identical implementations. Consider consolidating them into a single method or extracting the shared logic to avoid duplication.

Copilot uses AI. Check for mistakes.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ struct CourseBookAPIRepository: CourseBookRepository {
@Dependency(\.apiClient) private var apiClient

func fetchCourseBookList() async throws -> [CourseBook] {
let response = try await apiClient.getAllCoursebooks()
let response = try await apiClient.getCoursebooks_1()
let courseBooks = try response.ok.body.json
return courseBooks.map { CourseBook(from: $0) }
}

func fetchRecentCourseBook() async throws -> CourseBook {
let response = try await apiClient.getMostRecentCoursebook()
let response = try await apiClient.getLatestCoursebook()
let courseBook = try response.ok.body.json
return .init(from: courseBook)
}

func fetchSyllabusURL(year: Int, semester: Int, lecture: Lecture) async throws -> Syllabus {
let response = try await apiClient.getSyllabusUrl(
let response = try await apiClient.getCoursebookOfficial(
query: .init(
year: String(year),
semester: String(semester),
year: Int32(year),
semester: try require(.init(rawValue: semester)),
course_number: try require(lecture.courseNumber),
lecture_number: try require(lecture.lectureNumber)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public struct LectureAPIRepository: LectureRepository {
)
return try await apiClient.modifyTimetableLecture(
path: .init(timetableId: timetableID, timetableLectureId: lectureID),
query: .init(isForced: overrideOnConflict.description),
query: .init(isForced: overrideOnConflict),
body: .json(requestDto)
).ok.body.json.toTimetable()
}
Expand Down Expand Up @@ -114,8 +114,11 @@ public struct LectureAPIRepository: LectureRepository {
}

public func fetchBookmarks(quarter: Quarter) async throws -> [Lecture] {
let response = try await apiClient.getBookmark(
query: .init(year: String(quarter.year), semester: String(quarter.semester.rawValue))
let response = try await apiClient.getBookmarks(
query: .init(
year: Int32(quarter.year),
semester: require(.init(rawValue: quarter.semester.rawValue))
)
).ok.body.json
return try response.lectures.map { try $0.toLecture() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ struct LectureSearchAPIRepository: LectureSearchRepository {
title: query,
year: Int32(quarter.year)
)
let response = try await apiClient.searchLecture(body: .json(query))
let response = try await apiClient.searchLectures(body: .json(query))
return try response.ok.body.json.map { try $0.toLecture() }
}

func fetchSearchPredicates(quarter: Quarter) async throws -> [SearchPredicate] {
let response = try await apiClient.getTagList(
path: .init(
year: String(quarter.year),
semester: String(quarter.semester.rawValue)
year: Int32(quarter.year),
semester: require(.init(rawValue: quarter.semester.rawValue))
)
)
let json = try response.ok.body.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public struct TimetableAPIRepository: TimetableRepository {
}

public func fetchTimetableMetadataList() async throws -> [TimetableMetadata] {
try await apiClient.getBrief().ok.body.json.map { try $0.toTimetableMetadata() }
try await apiClient.getTimetableBriefs().ok.body.json.map { try $0.toTimetableMetadata() }
}

public func updateTimetableTitle(timetableID: String, title: String) async throws -> [TimetableMetadata] {
Expand Down Expand Up @@ -73,7 +73,7 @@ public struct TimetableAPIRepository: TimetableRepository {
) async throws -> Timetable {
try await apiClient.addLecture(
path: .init(timetableId: timetableID, lectureId: lectureID),
query: .init(isForced: overrideOnConflict.description)
query: .init(isForced: overrideOnConflict)
).ok.body.json.toTimetable()
}

Expand Down
Loading
Loading