-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from zerosome-dev/feature/home
✨[Feat] add logout, revoke, mypage api
- Loading branch information
Showing
16 changed files
with
353 additions
and
61 deletions.
There are no files selected for viewing
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
14 changes: 14 additions & 0 deletions
14
Projects/App/Sources/Data/DTO/Mypage/MemberBasicInfoResponseDTO.swift
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,14 @@ | ||
// | ||
// MemberBasicInfoResponseDTO.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/29. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct MemberBasicInfoResponseDTO: Decodable { | ||
var nickname: String? | ||
var rivewCnt: Int? | ||
} |
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
18 changes: 18 additions & 0 deletions
18
Projects/App/Sources/Data/Mapper/Mypage/MypageMapper.swift
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,18 @@ | ||
// | ||
// MypageMapper.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/29. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class MypageMapper { | ||
static func toMemberBasicInfo(response: MemberBasicInfoResponseDTO) -> MemberBasicInfoResult { | ||
return MemberBasicInfoResult( | ||
nickname: response.nickname ?? "", | ||
rivewCnt: response.rivewCnt ?? 0 | ||
) | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
Projects/App/Sources/Data/Repository/Mypage/MypageRepository.swift
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,79 @@ | ||
// | ||
// MypageRepository.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/30. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
final class MypageRepository: MypageRepositoryProtocol { | ||
|
||
private let apiService: ApiService | ||
|
||
init(apiService: ApiService) { | ||
self.apiService = apiService | ||
} | ||
|
||
func getUserBasicInfo() -> Future<MemberBasicInfoResult, NetworkError> { | ||
return Future { promise in | ||
Task { | ||
let response: Result<MemberBasicInfoResponseDTO, NetworkError> = await self.apiService.request( | ||
httpMethod: .get, | ||
endPoint: APIEndPoint.url(for: .userInfo), | ||
header: AccountStorage.shared.accessToken | ||
) | ||
|
||
switch response { | ||
case .success(let success): | ||
let mappedResult = MypageMapper.toMemberBasicInfo(response: success) | ||
promise(.success(mappedResult)) | ||
case .failure(let failure): | ||
debugPrint("Mypage UserInfo failed \(failure.localizedDescription)") | ||
promise(.failure(NetworkError.badRequest)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func logout() -> Future<Bool, NetworkError> { | ||
return Future { promise in | ||
Task { | ||
let response: Result<NoneDecodeResponse, NetworkError> = await self.apiService.request( | ||
httpMethod: .delete, | ||
endPoint: APIEndPoint.url(for: .logout), | ||
header: AccountStorage.shared.accessToken | ||
) | ||
|
||
switch response { | ||
case .success(let success): | ||
promise(.success(true)) | ||
case .failure(let failure): | ||
debugPrint("Failure to Logout!! \(failure.localizedDescription)") | ||
promise(.failure(NetworkError.badRequest)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func revoke() -> Future<Bool, NetworkError> { | ||
return Future { promise in | ||
Task { | ||
let response: Result<NoneDecodeResponse, NetworkError> = await self.apiService.request( | ||
httpMethod: .delete, | ||
endPoint: APIEndPoint.url(for: .signIn), | ||
header: AccountStorage.shared.accessToken | ||
) | ||
|
||
switch response { | ||
case .success(let success): | ||
promise(.success(true)) | ||
case .failure(let failure): | ||
debugPrint("Failure to Revoke!! \(failure.localizedDescription)") | ||
promise(.failure(NetworkError.badRequest)) | ||
} | ||
} | ||
} | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
Projects/App/Sources/Domain/Entity/Mypage/MemberBasicInfoResult.swift
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,14 @@ | ||
// | ||
// MemberBasicInfoResult.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/29. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct MemberBasicInfoResult { | ||
var nickname: String | ||
var rivewCnt: Int | ||
} |
15 changes: 15 additions & 0 deletions
15
Projects/App/Sources/Domain/Repository/MypageRepositoryProtocol.swift
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,15 @@ | ||
// | ||
// MypageRepositoryProtocol.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/30. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
protocol MypageRepositoryProtocol { | ||
func getUserBasicInfo() -> Future<MemberBasicInfoResult, NetworkError> | ||
func logout() -> Future<Bool, NetworkError> | ||
func revoke() -> Future<Bool, NetworkError> | ||
} |
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,25 @@ | ||
// | ||
// MypageUsecase.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/30. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
struct MypageUsecase { | ||
let mypageRepoProtocol: MypageRepositoryProtocol | ||
|
||
func getUserBasicInfo() -> Future<MemberBasicInfoResult, NetworkError> { | ||
return mypageRepoProtocol.getUserBasicInfo() | ||
} | ||
|
||
func logout() -> Future<Bool, NetworkError> { | ||
return mypageRepoProtocol.logout() | ||
} | ||
|
||
func revoke() -> Future<Bool, NetworkError> { | ||
return mypageRepoProtocol.revoke() | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
Projects/App/Sources/Presentation/Mypage/Main/MypageInfoView.swift
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,53 @@ | ||
// | ||
// MypageInfoView.swift | ||
// App | ||
// | ||
// Created by 박서연 on 2024/08/30. | ||
// Copyright © 2024 iOS. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import DesignSystem | ||
|
||
struct MypageInfoView: View { | ||
var body: some View { | ||
VStack { | ||
ForEach(MypageCenter.allCases, id: \.self) { center in | ||
Text(center.rawValue) | ||
.applyFont(font: .body3) | ||
.foregroundStyle(Color.neutral300) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.padding(.bottom, 10) | ||
.padding(.top, 20) | ||
|
||
ForEach(center.type, id: \.self) { type in | ||
HStack { | ||
Text(type) | ||
.applyFont(font: .body2) | ||
.foregroundStyle(Color.neutral900) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
|
||
Spacer() | ||
|
||
if type == MypageCenter.service.type.last! { | ||
Text("앱 버전1.201.23") | ||
.applyFont(font: .body2) | ||
.foregroundStyle(Color.neutral500) | ||
} else { | ||
ZerosomeAsset.ic_arrow_after | ||
.resizable() | ||
.frame(width: 24, height: 24) | ||
} | ||
|
||
} | ||
.onTapGesture { | ||
print("case 별로 이동 처리 추가 예정") | ||
} | ||
} | ||
.padding(.bottom, 10) | ||
DivideRectangle(height: 1, color: Color.neutral100) | ||
} | ||
} | ||
.padding(.horizontal, 22) | ||
} | ||
} |
Oops, something went wrong.