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

[Feat] #468 - 회원 탈퇴 서버통신 연결 #469

Merged
merged 2 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Spark-iOS/Spark-iOS/Source/NetworkServices/Auth/AuthAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,20 @@ public class AuthAPI {
return .networkFail
}
}

func withdrawal(completion: @escaping (NetworkResult<Any>) -> Void) {
userProvider.request(.withdrawal) { result in
switch result {
case .success(let response):
let statusCode = response.statusCode
let data = response.data

let networkResult = self.judgeStatus(by: statusCode, data)
completion(networkResult)

case .failure(let err):
print(err)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum AuthService {
case signup(socialID: String, profileImg: UIImage?, nickname: String, fcmToken: String)
case login(socialID: String, fcmToken: String)
case signout
case withdrawal
}

extension AuthService: TargetType {
Expand All @@ -27,6 +28,8 @@ extension AuthService: TargetType {
return "/auth/doorbell"
case .signout:
return "/auth/signout"
case .withdrawal:
return "/auth/user"
}
}

Expand All @@ -38,6 +41,8 @@ extension AuthService: TargetType {
return .get
case .signout:
return .post
case .withdrawal:
return .delete
}
}

Expand All @@ -64,6 +69,8 @@ extension AuthService: TargetType {
encoding: URLEncoding.queryString)
case .signout:
return .requestPlain
case .withdrawal:
return .requestPlain
}
}

Expand All @@ -75,6 +82,8 @@ extension AuthService: TargetType {
return Const.Header.basicHeader()
case .signout:
return Const.Header.authorizationHeader()
case .withdrawal:
return Const.Header.authorizationHeader()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,28 @@ extension WithdrawalVC {

@objc
private func touchWithdrawalButtonButton() {
// TODO: - 탈퇴하기 서버통신
guard let dialogueVC = UIStoryboard(name: Const.Storyboard.Name.dialogue, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.dialogue) as? DialogueVC else { return }
dialogueVC.modalPresentationStyle = .overFullScreen
dialogueVC.modalTransitionStyle = .crossDissolve
dialogueVC.dialogueType = .withdrawal
dialogueVC.clousure = {
if UserDefaults.standard.bool(forKey: Const.UserDefaultsKey.isAppleLogin) {
self.unlink()
} else {
UserApi.shared.unlink { error in
if let error = error {
print("kakao unlink error: \(error).")
} else {
// unlink success.
self.unlink()
withdrawalWithAPI {
guard let dialogueVC = UIStoryboard(name: Const.Storyboard.Name.dialogue, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.dialogue) as? DialogueVC else { return }
dialogueVC.modalPresentationStyle = .overFullScreen
dialogueVC.modalTransitionStyle = .crossDissolve
dialogueVC.dialogueType = .withdrawal
dialogueVC.clousure = {
if UserDefaults.standard.bool(forKey: Const.UserDefaultsKey.isAppleLogin) {
self.unlink()
} else {
UserApi.shared.unlink { error in
if let error = error {
print("kakao unlink error: \(error).")
} else {
// unlink success.
self.unlink()
}
Copy link
Member

Choose a reason for hiding this comment

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

회원탈퇴 서버 통신 후에 다이얼로그 띄워주능건가여?

Copy link
Member Author

@hyun99999 hyun99999 Apr 1, 2022

Choose a reason for hiding this comment

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

아이고... 급하게 한다는게 에휴 네에... 나란넘

Copy link
Member Author

Choose a reason for hiding this comment

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

코리 반영했습니다!

}
}
}

self.present(dialogueVC, animated: true, completion: nil)
}

present(dialogueVC, animated: true, completion: nil)
}

private func unlink() {
Expand All @@ -144,3 +145,26 @@ extension WithdrawalVC {
}
}
}

// MARK: - Network

extension WithdrawalVC {
private func withdrawalWithAPI(completion: @escaping () -> Void) {
AuthAPI.shared.withdrawal { response in
switch response {
case .success(let message):
completion()

print("withdrawalWithAPI - success: \(message)")
case .requestErr(let message):
print("withdrawalWithAPI - requestErr: \(message)")
case .pathErr:
print("withdrawalWithAPI - pathErr")
case .serverErr:
print("withdrawalWithAPI - serverErr")
case .networkFail:
print("withdrawalWithAPI - networkFail")
}
}
}
}