Skip to content

Commit

Permalink
close #145 #146 feat: NetworkManager에 NickName 변경 요청 후 Response 받아 전달
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEYOONJONG committed Dec 1, 2022
1 parent 4e35893 commit 158b2e3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Segno/Segno/Data/Network/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typealias Body = Encodable

// MARK: HTTP 요청 메서드
enum HTTPMethod: String {
case GET, POST, PUT, DELETE
case GET, POST, PUT, DELETE, PATCH
}

// MARK: 요청 파라미터
Expand Down
31 changes: 31 additions & 0 deletions Segno/Segno/Data/Network/Endpoints/ChangeNicknameEndpoint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// SettingsEndpoint.swift
// Segno
//
// Created by YOONJONG on 2022/12/01.
//

import Foundation

enum ChangeNicknameEndpoint: Endpoint {
case item(String, String)

var baseURL: URL? {
return URL(string: BaseURL.urlString)
}

var httpMethod: HTTPMethod {
return .PATCH
}

var path: String {
return "user"
}

var parameters: HTTPRequestParameter? {
switch self {
case .item(let token, let nickName):
return HTTPRequestParameter.body(["token": token, "nickName": nickName])
}
}
}
12 changes: 10 additions & 2 deletions Segno/Segno/Data/Repository/SettingsRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
import RxSwift

protocol SettingsRepository {

func changeNickname(to nickname: String) -> Single<Bool>
}

final class SettingsRepositoryImpl: SettingsRepository {

func changeNickname(to nickname: String) -> Single<Bool> {
// TODO: Keychain으로부터 토큰 가져오기
let token = "/43JoWf24Y7SS8yJj3oIPqIFGZRD3P7u9kUZVwkMwug="
let endpoint = ChangeNicknameEndpoint.item(token, nickname)
return NetworkManager.shared.call(endpoint)
.map { _ in
return true
}
}
}

0 comments on commit 158b2e3

Please sign in to comment.