Skip to content

Commit

Permalink
Merge branch 'Dev' of github.com:DDD-Community/PINGPONG-IOS into Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lainyzine committed Oct 4, 2023
2 parents 5a328ab + e3d56d2 commit 792ae2e
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public enum PingPongAPIAuthorization {
public static let validateNickNameURL = String("validate-nickname")
public static let searchUserByUidURL = String("search-user-by-uid")
public static let searchUserByidURL = String("search-user-by-id")
public static let withdrawal = String("withdrawal")
public static let userInfo = String("user-info/")
public static let withdrawalURL = String("withdrawal")
public static let userInfoURL = String("user-info/")
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
import Foundation

public enum PingPongAPIOnBoarding {
public static let userPrefURL = String("onboard/user-pref/1")
public static let userPrefURL = String("onboard/user-pref/")
public static let searchUserPrefURL = String("onboard/search-user-pref-codes")
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public enum PingPongAPIHome {
public static let homeRandomQuote = String("home/random-quote")
public static let homeBakeQuote = String("home/bake-quote")
public static let homeLike = String("home/like")
public static let homeScarp = String("home/like")
public static let userPref = String("mypage/user-pref/")
public static let homeScarp = String("home/scrap")

}
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/")

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public enum PingPongAPISearch {
public static let searchQuote = String("/search/quote")
public static let searchQuote = String("search/quote")
public static let searchCommonCode = String("code/saerch-comm-cd/")

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum AuthorizationService {
case validateName(nickname: String)
case searchUserByUid(uid: String)
case searchUserByid(id: String)
case changeUserInfo(userId: String)
}

extension AuthorizationService: BaseTargetType {
Expand All @@ -31,6 +32,8 @@ extension AuthorizationService: BaseTargetType {
return "\(PingPongAPIAuthorization.searchUserByUidURL)/\(uid)"
case .searchUserByid(let id):
return "\(PingPongAPIAuthorization.searchUserByidURL)/\(id)"
case .changeUserInfo(let userId):
return "\(PingPongAPIAuthorization.userInfoURL)\(userId)"
}
}

Expand All @@ -46,6 +49,8 @@ extension AuthorizationService: BaseTargetType {
return .get
case .searchUserByid:
return .get
case .changeUserInfo:
return .put
}
}

Expand Down Expand Up @@ -81,6 +86,12 @@ extension AuthorizationService: BaseTargetType {
// "id": id
]
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)

case .changeUserInfo(let userId):
let parameters : [String : Any] = [
"userId": userId
]
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public enum HomeService {
case homeBakeQuote(userId: String, flavor: String, source: String, mood: String)
case homeLike(userId: String, quoteId: Int)
case homeQuoteScrap(userId: String, quoteId: Int)
case userPref(userId: String)
}


Expand All @@ -30,8 +29,6 @@ extension HomeService: BaseTargetType {
return PingPongAPIHome.homeLike
case .homeQuoteScrap:
return PingPongAPIHome.homeScarp
case .userPref(let userId):
return "\(PingPongAPIHome.userPref)\(userId)"

}
}
Expand All @@ -46,8 +43,6 @@ extension HomeService: BaseTargetType {
return .post
case .homeQuoteScrap:
return .post
case .userPref:
return .get
}
}

Expand Down Expand Up @@ -86,13 +81,6 @@ extension HomeService: BaseTargetType {
]
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default)

case .userPref(let userId):
let parameters : [String : Any] = [
"userId": userId


]
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
}
}
}
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)

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public enum OnBoardingService {
extension OnBoardingService: BaseTargetType {
public var path: String {
switch self {
case .userPreferenceRegister:
return PingPongAPIOnBoarding.userPrefURL
case .userPreferenceRegister(let userId):
return "\(PingPongAPIOnBoarding.userPrefURL)\(userId)"
case .searchUserPreferenceRegister:
return PingPongAPIOnBoarding.searchUserPrefURL
}
Expand All @@ -44,6 +44,7 @@ extension OnBoardingService: BaseTargetType {
"sources": sources
]
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)

case .searchUserPreferenceRegister:
let parameters : [String : Any] = [:]
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
Expand Down

0 comments on commit 792ae2e

Please sign in to comment.