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

[2.0.0] 회원 등록 api 추가 요청 대응 #204

Merged
merged 13 commits into from
Apr 30, 2024
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "7f5095b25e2d0a629176f0ebc41ee16d8e7d8c6c0e326ede18f4df4abbe75d63",
"originHash" : "a70bf5bcda18b73a91398005590ea6f3e124d517cc68deffb3c56506da7c3f07",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand Down
15 changes: 15 additions & 0 deletions package-kuring/Sources/Models/AuthRequestQuery.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Copyright (c) 2024 쿠링
// See the 'License.txt' file for licensing information.
//

import Foundation

/// 계정 정보
public struct AuthRequest: Encodable {
Copy link
Contributor

@x-0o0 x-0o0 Apr 20, 2024

Choose a reason for hiding this comment

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

파일명과 타입명 불일치

public let token: String

public init(fcmToken: String) {
self.token = fcmToken
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ extension KuringLink: DependencyKey {
)
}
return NoticeProvider.departments
}, registerAuthorization: {
let response: EmptyResponse = try await satellite
.response(
for: Path.registerAuthorization.path,
httpMethod: .post,
httpHeaders: [
"Content-Type": "application/json",
],
httpBody: AuthRequest(fcmToken: fcmToken)
)
let isSucceed = (200 ..< 300) ~= response.code
return isSucceed
}
)
}
Expand Down Expand Up @@ -289,6 +301,8 @@ extension KuringLink {
category: .학과
)
]
}, registerAuthorization: {
return true
}
)
}
3 changes: 3 additions & 0 deletions package-kuring/Sources/Networks/KuringLink/API.Path.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum Path {
case searchNotices
case searchStaffs
case sendFeedback
case registerAuthorization

var path: String {
switch self {
Expand All @@ -39,6 +40,8 @@ enum Path {
return "api/v2/staffs/search"
case .sendFeedback:
return "api/v2/users/feedbacks"
case .registerAuthorization:
return "api/v2/users"
}
}
}
2 changes: 2 additions & 0 deletions package-kuring/Sources/Networks/KuringLink/KuringLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@ public struct KuringLink {
public var getAllUnivNoticeType: () async throws -> [NoticeProvider]
/// 모든 학과 공지 카테고리 가져오기
public var getAllDepartments: () async throws -> [NoticeProvider]
/// 계정 정보 등록
public var registerAuthorization: () async throws -> Bool
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ struct MyDepartmentSelector: View {
.tag(Step.addedDepartment.id)
}
.padding(.top, 56)

.onAppear {
Task {
lgvv marked this conversation as resolved.
Show resolved Hide resolved
try? await kuringLink.registerAuthorization()
}
}
// 하단 버튼 영역
if currentStep == .selectDepartment {
Button(StringSet.button_complete.rawValue) {
Expand Down