-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/suyeon'
Conflicts: KkuMulKum.xcodeproj/project.pbxproj
- Loading branch information
Showing
109 changed files
with
2,271 additions
and
682 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// UserService.swift | ||
// KkuMulKum | ||
// | ||
// Created by 이지훈 on 8/22/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import Moya | ||
|
||
final class MyPageUserService: MyPageUserServiceType { | ||
private var provider = MoyaProvider<UserTargetType>() | ||
|
||
init(provider: MoyaProvider<UserTargetType> = MoyaProvider(plugins: [MoyaLoggingPlugin()])) { | ||
self.provider = provider | ||
} | ||
|
||
func getUserInfo() async throws -> LoginUserModel { | ||
return try await performRequest(.getUserInfo) | ||
} | ||
|
||
func performRequest<T: ResponseModelType>(_ target: UserTargetType) async throws -> T { | ||
return try await withCheckedThrowingContinuation { continuation in | ||
provider.request(target) { result in | ||
switch result { | ||
case .success(let response): | ||
do { | ||
let decodedResponse = try JSONDecoder().decode(ResponseBodyDTO<T>.self, from: response.data) | ||
guard decodedResponse.success, let data = decodedResponse.data else { | ||
throw decodedResponse.error.map(NetworkErrorMapper.mapErrorResponse) ?? | ||
NetworkError.unknownError("Unknown error occurred") | ||
} | ||
continuation.resume(returning: data) | ||
} catch { | ||
continuation.resume(throwing: error is NetworkError ? error : NetworkError.decodingError) | ||
} | ||
case .failure(let error): | ||
continuation.resume(throwing: NetworkError.networkError(error)) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.