-
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 pull request #140 from boostcampwm-2022/feature/my-page-flow
MyPage와 관련된 플로우 작성
- Loading branch information
Showing
8 changed files
with
221 additions
and
23 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
32 changes: 32 additions & 0 deletions
32
Segno/Segno/Data/Network/Endpoints/UserDetailEndpoint.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,32 @@ | ||
// | ||
// UserDetailEndpoint.swift | ||
// Segno | ||
// | ||
// Created by 이예준 on 2022/11/30. | ||
// | ||
|
||
import Foundation | ||
|
||
enum UserDetailEndpoint: Endpoint { | ||
case item | ||
|
||
var baseURL: URL? { | ||
return URL(string: BaseURL.urlString) | ||
} | ||
|
||
var httpMethod: HTTPMethod { | ||
return .GET | ||
} | ||
|
||
var path: String { | ||
// TODO: 서버에 맞춰서 path 조정 | ||
return "" | ||
} | ||
|
||
var parameters: HTTPRequestParameter? { | ||
switch self { | ||
case .item: | ||
return HTTPRequestParameter.queries([:]) // TODO: queries로 무언가 들어가야함 | ||
} | ||
} | ||
} |
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,27 @@ | ||
// | ||
// UserDetailDTO.swift | ||
// Segno | ||
// | ||
// Created by 이예준 on 2022/11/30. | ||
// | ||
|
||
struct UserDetailDTO: Decodable { | ||
// TODO: 일단은 UserDetailItem과 동일하게 작성. 이후 서버 사이드에 따라 바꾸겠습니다. | ||
let identifier: String | ||
let nickname: String | ||
let writtenDiary: String | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case identifier = "_id" | ||
case nickname | ||
case writtenDiary = "diary" | ||
} | ||
|
||
#if DEBUG | ||
static let example = UserDetailDTO( | ||
identifier: "id", | ||
nickname: "test123", | ||
writtenDiary: "50000" | ||
) | ||
#endif | ||
} |
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,30 @@ | ||
// | ||
// MyPageRepository.swift | ||
// Segno | ||
// | ||
// Created by 이예준 on 2022/11/30. | ||
// | ||
|
||
import RxSwift | ||
|
||
protocol MyPageRepository { | ||
func getUserDetail() -> Single<UserDetailDTO> | ||
} | ||
|
||
final class MyPageRepositoryImpl: MyPageRepository { | ||
func getUserDetail() -> Single<UserDetailDTO> { | ||
// let endpoint = UserDetailEndpoint.item(id) | ||
// | ||
// return NetworkManager.shared.call(endpoint) | ||
// .map { | ||
// try JSONDecoder().decode(UserDetailDTO.self, from: $0) | ||
// } | ||
|
||
// TODO: 추후에 NetworkManager로 변경 | ||
return Single.create { observer -> Disposable in | ||
observer(.success(UserDetailDTO.example)) | ||
|
||
return Disposables.create() | ||
} | ||
} | ||
} |
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,27 @@ | ||
// | ||
// UserDetailUseCase.swift | ||
// Segno | ||
// | ||
// Created by 이예준 on 2022/11/30. | ||
// | ||
|
||
import RxSwift | ||
|
||
protocol UserDetailUseCase { | ||
func getUserDetail() -> Single<UserDetailItem> | ||
} | ||
|
||
final class UserDetailUseCaseImpl: UserDetailUseCase { | ||
let repository: MyPageRepository | ||
private let disposeBag = DisposeBag() | ||
|
||
init(repository: MyPageRepository = MyPageRepositoryImpl()) { | ||
self.repository = repository | ||
} | ||
|
||
func getUserDetail() -> Single<UserDetailItem> { | ||
return repository.getUserDetail().map { | ||
UserDetailItem(identifier: $0.identifier, nickname: $0.nickname, writtenDiary: $0.writtenDiary) | ||
} | ||
} | ||
} |
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,12 @@ | ||
// | ||
// UserDetailItem.swift | ||
// Segno | ||
// | ||
// Created by 이예준 on 2022/11/30. | ||
// | ||
|
||
struct UserDetailItem: Hashable { | ||
let identifier: String | ||
let nickname: String | ||
let writtenDiary: String | ||
} |
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