Skip to content

Commit

Permalink
Merge pull request #245 from Nexters/release/1.0.7
Browse files Browse the repository at this point in the history
release/1.0.7 -> main
  • Loading branch information
leemhyungyu authored Sep 17, 2024
2 parents 7fbf36e + f7e98eb commit ef162e7
Show file tree
Hide file tree
Showing 32 changed files with 562 additions and 318 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public extension ModulePath {

public extension ModulePath {
enum Domain: String, CaseIterable {
case Error
case User
case Report
case WebView
Expand Down
7 changes: 7 additions & 0 deletions Projects/Domain/Auth/Interface/Sources/API/AuthAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum AuthAPI {
case logout(_ logOutRequestDTO: LogOutRequestDTO)
case revoke
case profile(_ requestDTO: ProfileRequestDTO)
case updateVersion
}

extension AuthAPI: BaseTargetType {
Expand All @@ -35,6 +36,8 @@ extension AuthAPI: BaseTargetType {
return "api/v1/auth/apple/revoke"
case .profile:
return "api/v2/auth/profile"
case .updateVersion:
return "api/v1/auth/app-version"
}
}

Expand All @@ -52,6 +55,8 @@ extension AuthAPI: BaseTargetType {
return .get
case .profile:
return .post
case .updateVersion:
return .get
}
}

Expand All @@ -69,6 +74,8 @@ extension AuthAPI: BaseTargetType {
return .requestPlain
case .profile(let requestDTO):
return .requestJSONEncodable(requestDTO)
case .updateVersion:
return .requestPlain
}
}
}
9 changes: 8 additions & 1 deletion Projects/Domain/Auth/Interface/Sources/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public struct AuthClient {
private let fetchAppleClientSecret: () async throws -> String
private let registerUserProfile: (String) async throws -> Void
private let _removeAllToken: () -> Void
private let checkUpdateVersion: () async throws -> Void

public init(
signInWithKakao: @escaping () async throws -> UserInfo,
Expand All @@ -31,7 +32,8 @@ public struct AuthClient {
revokeAppleLogin: @escaping () async throws -> Void,
fetchAppleClientSecret: @escaping () async throws -> String,
registerUserProfile: @escaping (String) async throws -> Void,
removeAllToken: @escaping () -> Void
removeAllToken: @escaping () -> Void,
checkUpdateVersion: @escaping () async throws -> Void
) {
self.signInWithKakao = signInWithKakao
self.signInWithApple = signInWithApple
Expand All @@ -44,6 +46,7 @@ public struct AuthClient {
self.fetchAppleClientSecret = fetchAppleClientSecret
self.registerUserProfile = registerUserProfile
self._removeAllToken = removeAllToken
self.checkUpdateVersion = checkUpdateVersion
}

public func signInWithKakao() async throws -> UserInfo {
Expand Down Expand Up @@ -88,5 +91,9 @@ public struct AuthClient {
public func removeAllToken() {
_removeAllToken()
}

public func checkUpdateVersion() async throws {
return try await checkUpdateVersion()
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// UpdateVersionResponseDTO.swift
// DomainAuthInterface
//
// Created by JongHoon on 9/10/24.
//

import Foundation

public struct UpdateVersionResponseDTO: Decodable {
public let minimumIosVersion: Int?
}
3 changes: 2 additions & 1 deletion Projects/Domain/Auth/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ let project = Project.makeModule(
implements: .Auth,
factory: .init(
dependencies: [
.domain(interface: .Auth)
.domain(interface: .Auth),
.domain(interface: .Error)
]
)
),
Expand Down
17 changes: 17 additions & 0 deletions Projects/Domain/Auth/Sources/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation

import DomainAuthInterface
import DomainErrorInterface
import DomainUser

import CoreNetwork
Expand Down Expand Up @@ -91,6 +92,22 @@ extension AuthClient: DependencyKey {
},
removeAllToken: {
LocalAuthDataSourceImpl.removeAllToken()
},
checkUpdateVersion: {
let minimumIosBuildNumber = try await networkManager.reqeust(api: .apiType(AuthAPI.updateVersion), dto: UpdateVersionResponseDTO.self).minimumIosVersion

guard let buildNumberString = Bundle.main.infoDictionary?["CFBundleVersion"] as? String,
let buildNumber = Int(buildNumberString)
else {
Log.assertion(message: "no build number")
throw DomainError.unknown("no build number")
}
let minimumBuildNumber = minimumIosBuildNumber ?? buildNumber

guard minimumBuildNumber <= buildNumber
else {
throw DomainError.AuthError.needUpdateAppVersion
}
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,11 @@ public struct BottlePingPongResponseDTO: Decodable {
letters: (letters?.map { $0.toDomain() }) ?? [],
matchResult: matchResult?.toDomain() ?? MatchResult(
isFirstSelect: false,
matchStatus: .inConversation,
matchStatus: .disabled,
otherContact: "",
shouldAnswer: false,
meetingPlace: nil,
meetingPlaceImageUrl: nil
),
photo: photo?.toDomain() ?? Photo(
isDone: false,
shouldAnswer: false
),
photo: photo?.toDomain() ?? Photo(photoStatus: .disabled),
stopUserName: stopUserName,
userProfile: userProfile?.toDomain() ?? UserProfile(
userId: -1,
Expand Down Expand Up @@ -81,47 +76,54 @@ public struct BottlePingPongResponseDTO: Decodable {
let matchStatus: String?
let otherContact: String?
let shouldAnswer: Bool?
let meetingPlace: String?
let meetingPlaceImageUrl: String?

public func toDomain() -> MatchResult {
let matchStatus: BottleMatchStatus = switch matchStatus {
case "IN_CONVERSATION": .inConversation
case "MATCH_SUCCEEDED": .matchSucceeded
let matchStatus: PingPongMatchStatus = switch matchStatus {
case "NONE": .disabled
case "REQUIRE_SELECT": .requireSelect
case "WAITING_OTHER_ANSWER": .waitingOtherAnswer
case "MATCH_FAILED": .matchFailed
case "NONE": .inConversation
case "REQUIRE_SELECT": .inConversation
case "WAITING_OTHER_ANSWER": .inConversation
default: .matchFailed
case "MATCH_SUCCEEDED": .matchSucceeded
default: .disabled
}

return .init(
isFirstSelect: isFirstSelect ?? false,
matchStatus: matchStatus,
otherContact: otherContact ?? "",
shouldAnswer: shouldAnswer ?? false,
meetingPlace: meetingPlace,
meetingPlaceImageUrl: meetingPlaceImageUrl
shouldAnswer: shouldAnswer ?? false
)
}
}

public struct PhotoDTO: Decodable {
let isDone: Bool?
let myAnswer: Bool?
let photoStatus: String?
let myImageUrl: String?
let otherAnswer: Bool?
let otherImageUrl: String?
let shouldAnswer: Bool?

public func toDomain() -> Photo {
let photoStatus: PingPongPhotoStatus = switch photoStatus {
case "BOTH_AGREE":
.bothAgree
case "MY_REJECT":
.myReject
case "NONE":
.disabled
case "OTHER_REJECT":
.otherReject
case "REQUIRE_SELECT_OTHER_SELECT":
.requireSelect(otherSelected: true)
case "REQUIRE_SELECT_OTHER_NOT_SELECT":
.requireSelect(otherSelected: false)
case "WAITING_OTHER_ANSWER":
.waitingOtherAnswer
default:
.disabled
}
return .init(
isDone: isDone ?? false,
myAnswer: myAnswer,
myImageURL: myImageUrl,
otherAnswer: otherAnswer,
otherImageURL: otherImageUrl,
shouldAnswer: shouldAnswer ?? false
photoStatus: photoStatus,
myProfileImageURL: myImageUrl,
otherProfileImageURL: otherImageUrl
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,60 +78,61 @@ public struct Letter: Equatable {

public struct MatchResult: Equatable {
public let isFirstSelect: Bool
public let matchStatus: BottleMatchStatus
public let matchStatus: PingPongMatchStatus
public let otherContact: String
public let shouldAnswer: Bool
public let meetingPlace: String?
public let meetingPlaceImageURL: String?

init(
isFirstSelect: Bool,
matchStatus: BottleMatchStatus,
matchStatus: PingPongMatchStatus,
otherContact: String,
shouldAnswer: Bool,
meetingPlace: String?,
meetingPlaceImageUrl: String?
shouldAnswer: Bool
) {
self.isFirstSelect = isFirstSelect
self.matchStatus = matchStatus
self.otherContact = otherContact
self.shouldAnswer = shouldAnswer
self.meetingPlace = meetingPlace
self.meetingPlaceImageURL = meetingPlaceImageUrl
}
}

public enum BottleMatchStatus {
case inConversation
public enum PingPongMatchStatus {
/// 최종 선택 단계 X
case disabled
/// 최종 선택해야 함
case requireSelect
/// 상대방의 답변을 기다리는 상황
case waitingOtherAnswer
/// 매칭 실패
case matchFailed
/// 매칭 성공
case matchSucceeded
}

public struct Photo: Equatable {
public let isDone: Bool
public let myAnswer: Bool?
public let myImageURL: String?
public let otherAnswer: Bool?
public let otherImageURL: String?
public let shouldAnswer: Bool
public let photoStatus: PingPongPhotoStatus
public let myProfileImageURL: String?
public let otherProfileImageURL: String?

init(
isDone: Bool,
myAnswer: Bool? = nil,
myImageURL: String? = nil,
otherAnswer: Bool? = nil,
otherImageURL: String? = nil,
shouldAnswer: Bool
public init(
photoStatus: PingPongPhotoStatus,
myProfileImageURL: String? = nil,
otherProfileImageURL: String? = nil
) {
self.isDone = isDone
self.myAnswer = myAnswer
self.myImageURL = myImageURL
self.otherAnswer = otherAnswer
self.otherImageURL = otherImageURL
self.shouldAnswer = shouldAnswer
self.photoStatus = photoStatus
self.myProfileImageURL = myProfileImageURL
self.otherProfileImageURL = otherProfileImageURL
}
}

public enum PingPongPhotoStatus: Equatable {
case disabled
case bothAgree
case myReject
case otherReject
case requireSelect(otherSelected: Bool)
case waitingOtherAnswer
}

public struct UserProfile: Equatable {
public let userId: Int
public let age: Int
Expand Down
16 changes: 16 additions & 0 deletions Projects/Domain/Error/Interface/Sources/DomainError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// DomainError.swift
// DomainError
//
// Created by JongHoon on 9/11/24.
//

import Foundation

public enum DomainError: Error {
public enum AuthError: Error {
case needUpdateAppVersion
}

case unknown(_ message: String? = nil)
}
22 changes: 22 additions & 0 deletions Projects/Domain/Error/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.makeModule(
name: ModulePath.Domain.name+ModulePath.Domain.Error.rawValue,
targets: [
.domain(
interface: .Error,
factory: .init()
),
.domain(
implements: .Error,
factory: .init(
dependencies: [
.domain(interface: .Error)
]
)
),

]
)
1 change: 1 addition & 0 deletions Projects/Domain/Error/Sources/Source.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This is for Tuist
Loading

0 comments on commit ef162e7

Please sign in to comment.