-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
115 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
PingPong/Projects/Core/Domain/API/Sources/PingPongAPI/PingPongAPIMyPage.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// PingPongAPIMyPage.swift | ||
// API | ||
// | ||
// Created by 서원지 on 10/4/23. | ||
// Copyright © 2023 Wonji Suh. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum PingPongAPIMyPage { | ||
public static let myPageUserPrefURL = String("mypage/user-pref/") | ||
public static let myPageEditUserPrefURL = String("mypage/user-pref/") | ||
public static let myPageScrapURL = String("mypage/scraps/") | ||
public static let myPageLikeURL = String("mypage/likes/") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
PingPong/Projects/Core/Domain/Service/Sources/Service/MyPage/MyPageService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// MyPageService.swift | ||
// Service | ||
// | ||
// Created by 서원지 on 10/4/23. | ||
// Copyright © 2023 Wonji Suh. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import API | ||
import Moya | ||
|
||
|
||
public enum MyPageService { | ||
case myPageUsePref(userId: String) | ||
case myPageEditUserPref(userId: String, userPrefId: String, flavors: [String], sources: [String]) | ||
case myPageScraps(userId: String) | ||
case myPageLikes(userId: String) | ||
} | ||
|
||
extension MyPageService: BaseTargetType { | ||
public var path: String { | ||
switch self { | ||
case .myPageUsePref(let userId): | ||
return "\(PingPongAPIMyPage.myPageEditUserPrefURL)\(userId)" | ||
case .myPageEditUserPref(let userId, _, _, _): | ||
return "\(PingPongAPIMyPage.myPageEditUserPrefURL)\(userId)" | ||
case .myPageScraps(let userId): | ||
return "\(PingPongAPIMyPage.myPageScrapURL)\(userId)" | ||
case .myPageLikes(let userId): | ||
return "\(PingPongAPIMyPage.myPageLikeURL)\(userId)" | ||
} | ||
} | ||
|
||
public var method: Moya.Method { | ||
switch self { | ||
case .myPageUsePref: | ||
return .get | ||
case .myPageEditUserPref: | ||
return .put | ||
case .myPageScraps: | ||
return .get | ||
case .myPageLikes: | ||
return .get | ||
} | ||
} | ||
|
||
public var task: Moya.Task { | ||
switch self { | ||
case .myPageUsePref(let userId): | ||
let parameters : [String : Any] = [ | ||
"userId": userId | ||
] | ||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) | ||
|
||
case .myPageEditUserPref(let userId, let userPrefId, let flavors, let sources): | ||
let parameters : [String : Any] = [ | ||
"userId": userId, | ||
"userPrefId": userPrefId, | ||
"flavors": flavors, | ||
"sources" : sources | ||
] | ||
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default) | ||
|
||
case .myPageScraps(let userId): | ||
let parameters : [String : Any] = [ | ||
"userId": userId | ||
] | ||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) | ||
|
||
case .myPageLikes(let userId): | ||
let parameters : [String : Any] = [ | ||
"userId": userId | ||
] | ||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters