diff --git a/Hyangyu/Hyangyu/Sources/APIServices/AuthAPI/PasswordAPI.swift b/Hyangyu/Hyangyu/Sources/APIServices/AuthAPI/PasswordAPI.swift index 24a8fc4..92a1d52 100644 --- a/Hyangyu/Hyangyu/Sources/APIServices/AuthAPI/PasswordAPI.swift +++ b/Hyangyu/Hyangyu/Sources/APIServices/AuthAPI/PasswordAPI.swift @@ -15,14 +15,16 @@ public class PasswordAPI { public init() { } - func putNewPassword(completion: @escaping (NetworkResult) -> Void, email: String, password: String) { - courseProvider.request(.putChangedPassword(email: email, password: password)) { (result) in + func postNewPassword(completion: @escaping (NetworkResult) -> Void, email: String, password: String) { + courseProvider.request(.postChangedPassword(email: email, password: password)) { (result) in + print(result) switch result { case .success(let response): + print("response 제대로 오는지 확인: ", response) let statusCode = response.statusCode let data = response.data - let networkResult = self.judgeChangePasswordStatus(by: statusCode, data) + let networkResult = self.judgeStatus(by: statusCode, data) completion(networkResult) case .failure(let err): @@ -100,24 +102,4 @@ public class PasswordAPI { return .networkFail } } - -// private func judgeGetEmailCodeStatus(by statusCode: Int, _ data: Data) -> NetworkResult { -// -// let decoder = JSONDecoder() -// guard let decodedData = try? decoder.decode(GenericResponse.self, from: data) else { -// return .pathErr -// } -// -// switch statusCode { -// case 200: -// return .success(decodedData.data) -// case 400..<500: -// return .requestErr(decodedData.message) -// case 500: -// return .serverErr -// default: -// return .networkFail -// } -// } } - diff --git a/Hyangyu/Hyangyu/Sources/APIServices/AuthAPI/PasswordService.swift b/Hyangyu/Hyangyu/Sources/APIServices/AuthAPI/PasswordService.swift index 779a41b..babc1bd 100644 --- a/Hyangyu/Hyangyu/Sources/APIServices/AuthAPI/PasswordService.swift +++ b/Hyangyu/Hyangyu/Sources/APIServices/AuthAPI/PasswordService.swift @@ -9,7 +9,7 @@ import Foundation import Moya enum PasswordService { - case putChangedPassword(email: String, password: String) + case postChangedPassword(email: String, password: String) case postEmailCode(email: String) case checkCode(email: String, authNum: String) @@ -22,7 +22,7 @@ extension PasswordService: TargetType { var path: String { switch self { - case .putChangedPassword(_, _): + case .postChangedPassword(_, _): return Const.URL.passwordURL case .postEmailCode(let email): return Const.URL.findPasswordURL + "/\(email)" @@ -33,8 +33,8 @@ extension PasswordService: TargetType { var method: Moya.Method { switch self { - case .putChangedPassword(_, _): - return .put + case .postChangedPassword(_, _): + return .post case .postEmailCode(_): return .post case .checkCode(_, _): @@ -48,10 +48,11 @@ extension PasswordService: TargetType { var task: Task { switch self { - case .putChangedPassword(let email, let password): + case .postChangedPassword(let email, let password): // body가 있는 request - JSONEncoding.default return .requestParameters(parameters: [ "email": email, + "username": "", "password": password ], encoding: JSONEncoding.default) case .postEmailCode(_):