Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Network] #88 - Mypage api 연결 #94

Merged
merged 8 commits into from
Jul 18, 2024
Merged

[Network] #88 - Mypage api 연결 #94

merged 8 commits into from
Jul 18, 2024

Conversation

shimseohyun
Copy link
Contributor

🔥 Pull requests

👷 작업한 내용

  • my profile user 정보 불러오기
  • 제보한 식당 보기
  • 좋아요한 식당 보기
  • 족보 리스트 보기

🚨 참고 사항

var headers: [String: String]? {
        var header = ["Content-Type": "application/json"]
        switch headerType {
        case .loginHeader(let accessToken):
            header["Authorization"] = "\(accessToken)"
        default:
            let accessToken = UserDefaults.standard.getAccesshToken()
            header["Authorization"] = URLConstant.bearer + "\(accessToken)"
        }
        return header
    }

Header Type 을 지정합니다.
login Header의 경우 Bearer을 붙이지 않기 위해 별도로 헤더를 선택합니다.
필요한 헤더 타입이 있다면 추가해서 작성해주세요.

📸 스크린샷

구현 내용 15 pro
GIF

🖥️ 주요 코드 설명

HankkiListViewModel.swift

func getMeHankkiList(_ type: UserTargetType, completion: @escaping (Bool) -> Void) {
        NetworkService.shared.userService.getMeHankkiList(type) { result in
            switch result {
            case .success(let response):
                if let responseData = response {
                    self.hankkiList = responseData.data.stores.map {
                        return HankkiListTableViewCell.DataStruct(id: $0.id,
                                                                  name: $0.name,
                                                                  imageURL: $0.imageUrl,
                                                                  category: $0.category,
                                                                  lowestPrice: $0.lowestPrice,
                                                                  heartCount: $0.heartCount)
                    }
                } else { print("레전드 오류 발생") }
                completion(true)
            case .unAuthorized, .networkFail:
                print("Failed to fetch university list.")
                completion(false)
            default:
                return
            }
        }
    }

식당 리스트의 경우, 같은 뷰와, Data를 쓰기 때문에, .type으로 다른 API 를 호출할 수 있도록 설정했습니다.

✅ Check List

  • Merge 대상 브랜치가 올바른가?
  • 최종 코드가 에러 없이 잘 동작하는가?
  • 전체 변경사항이 500줄을 넘지 않는가?

📟 관련 이슈

@shimseohyun shimseohyun added 🤹🏻‍♀️ 서현 서현 공주 작업 🛜 Network API 연결 labels Jul 18, 2024
@shimseohyun shimseohyun self-assigned this Jul 18, 2024
Copy link
Member

@EunsuSeo01 EunsuSeo01 left a comment

Choose a reason for hiding this comment

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

내 기분이 좋소이다.

@@ -97,6 +82,15 @@ final class HankkiListViewController: BaseViewController {
}

private extension HankkiListViewController {
private func setupViewModel() {
Copy link
Member

Choose a reason for hiding this comment

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

p3: bindViewModel은 어떠하시오?

Comment on lines +21 to +23
extension HankkiListViewModel {
func getMeHankkiList(_ type: UserTargetType, completion: @escaping (Bool) -> Void) {
NetworkService.shared.userService.getMeHankkiList(type) { result in
Copy link
Member

Choose a reason for hiding this comment

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

type 아주 좋소

Copy link
Member

@mcrkgus mcrkgus left a comment

Choose a reason for hiding this comment

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

APPLETV

struct GetMeHankkiHeartListResponseData: Codable {
let stored: [GetMeHankkiHeartResponseData]
struct GetMeHankkiListResponseData: Codable {
let stores: [GetMeHankkiResponseData]
Copy link
Member

Choose a reason for hiding this comment

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

p3
GetHankkiListData가 어떠할까요 아가낭자공주님

}

struct GetMeHankkiHeartResponseData: Codable {
struct GetMeHankkiResponseData: Codable {
Copy link
Member

Choose a reason for hiding this comment

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

p3
네이밍컨벤션 부탁드리옵나이다 아기님


var userTargetType: UserTargetType {
switch self {
case .repoted:
Copy link
Member

Choose a reason for hiding this comment

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

p3
오타인 것 같소

Comment on lines +71 to +76
extension MypageHeaderView {
struct DataStruct {
let image: UIImage
let name: String
}
}
Copy link
Member

Choose a reason for hiding this comment

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

p3
Model 로 분리해주세요

@shimseohyun shimseohyun merged commit 2f30036 into develop Jul 18, 2024
@shimseohyun shimseohyun deleted the network/#88 branch July 19, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛜 Network API 연결 🤹🏻‍♀️ 서현 서현 공주 작업
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Network] Mypage API 연동
3 participants