-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Refactor/#184 demo
- Loading branch information
Showing
47 changed files
with
1,302 additions
and
1,635 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+27.7 KB
(180%)
....xcodeproj/project.xcworkspace/xcuserdata/soop.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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
43 changes: 43 additions & 0 deletions
43
iOS/RollTheDice/RollTheDice/Source/Domain/ScoopAPI/ScoopAPIDebate.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,43 @@ | ||
// | ||
// ScoopAPIDebate.swift | ||
// RollTheDice | ||
// | ||
// Created by Subeen on 9/19/24. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum ScoopAPIDebate { | ||
case getDebates | ||
case createDebates | ||
case saveDebatesHuman(Int) // [인간] 토론 메세지 저장 | ||
case saveDebatesAI(Int) // [AI] 토론 메세지 저장 | ||
case getDebatesSum(Int) | ||
case sumDebates(Int) | ||
case getDebatesMsg(Int) | ||
case deleteDebatesRoom(Int) | ||
case endDebatesRoom(Int) | ||
|
||
public var apiDesc: String { | ||
switch self { | ||
case .getDebates: | ||
"/debates" | ||
case .createDebates: | ||
"/debates" | ||
case .saveDebatesHuman(let roomId): | ||
"/debates/\(roomId)/human" | ||
case .saveDebatesAI(let roomId): | ||
"/debates/\(roomId)/ai" | ||
case .getDebatesSum(let roomId): | ||
"/debates/summary/\(roomId)" | ||
case .sumDebates(let roomId): | ||
"/debates/summary/\(roomId)" | ||
case .getDebatesMsg(let roomId): | ||
"/debates/\(roomId)" | ||
case .deleteDebatesRoom(let roomId): | ||
"/debates/\(roomId)" | ||
case .endDebatesRoom(let roomId): | ||
"/debates/\(roomId)" | ||
} | ||
} | ||
} |
153 changes: 153 additions & 0 deletions
153
iOS/RollTheDice/RollTheDice/Source/Domain/Service/DebateService.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,153 @@ | ||
// | ||
// DebateTarget.swift | ||
// RollTheDice | ||
// | ||
// Created by Subeen on 9/19/24. | ||
// | ||
|
||
import Foundation | ||
import Moya | ||
|
||
enum DebateService { | ||
case getDebates(page: Int, size: Int, accessToken: String) // 토론방 전체 조회 | ||
case createDebates(topic: String, accessToken: String) | ||
case saveDebatesHuman(roomId: Int, message: String, accessToken: String) // [인간] 토론 메세지 저장 | ||
case saveDebatesAI(roomId: Int, message: String, accessToken: String) // [AI] 토론 메세지 저장 | ||
case getDebatesSum(roomId: Int, accessToken: String) | ||
case sumDebates(roomId: Int, accessToken: String) | ||
case getDebatesMsg(roomId: Int, accessToken: String) | ||
case deleteDebatesRoom(roomId: Int, accessToken: String) | ||
case endDebatesRoom(roomId: Int, accessToken: String) | ||
} | ||
|
||
extension DebateService: BaseTargetType { | ||
var path: String { | ||
switch self { | ||
case .getDebates(_, _, _): | ||
return ScoopAPIDebate.getDebates.apiDesc | ||
|
||
case .createDebates(_, _): | ||
return ScoopAPIDebate.createDebates.apiDesc | ||
|
||
case .saveDebatesHuman(let roomId, _, _): | ||
return ScoopAPIDebate.saveDebatesHuman(roomId).apiDesc | ||
|
||
case .saveDebatesAI(let roomId, _, _): | ||
return ScoopAPIDebate.saveDebatesAI(roomId).apiDesc | ||
|
||
case .getDebatesSum(let roomId, _): | ||
return ScoopAPIDebate.getDebatesSum(roomId).apiDesc | ||
|
||
case .sumDebates(let roomId, _): | ||
return ScoopAPIDebate.sumDebates(roomId).apiDesc | ||
|
||
case .getDebatesMsg(let roomId, _): | ||
return ScoopAPIDebate.getDebatesMsg(roomId).apiDesc | ||
|
||
case .deleteDebatesRoom(let roomId, _): | ||
return ScoopAPIDebate.deleteDebatesRoom(roomId).apiDesc | ||
|
||
case .endDebatesRoom(let roomId, _): | ||
return ScoopAPIDebate.endDebatesRoom(roomId).apiDesc | ||
} | ||
} | ||
|
||
var method: Moya.Method { | ||
switch self { | ||
case .getDebates: | ||
return .get | ||
|
||
case .createDebates: | ||
return .post | ||
|
||
case .saveDebatesHuman: | ||
return .post | ||
|
||
case .saveDebatesAI: | ||
return .post | ||
|
||
case .getDebatesSum: | ||
return .get | ||
|
||
case .sumDebates: | ||
return .post | ||
|
||
case .getDebatesMsg: | ||
return .get | ||
|
||
case .deleteDebatesRoom: | ||
return .delete | ||
|
||
case .endDebatesRoom: | ||
return .patch | ||
} | ||
} | ||
|
||
var task: Moya.Task { | ||
switch self { | ||
case .getDebates(let page, let size, _): | ||
let parameters : [String : Any] = [ | ||
"page" : page, | ||
"size" : size | ||
] | ||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) | ||
|
||
case .createDebates(let topic, _): | ||
let parameters : [String : Any] = [ | ||
"topic" : topic | ||
] | ||
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default) | ||
|
||
case .saveDebatesHuman(_, let message, _): | ||
let parameters : [String : Any] = [ | ||
"message" : message | ||
] | ||
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default) | ||
|
||
case .saveDebatesAI(_, let message, _): | ||
let parameters : [String : Any] = [ | ||
"message" : message | ||
] | ||
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default) | ||
|
||
case .getDebatesSum: | ||
return .requestPlain | ||
|
||
case .sumDebates: | ||
return .requestPlain | ||
|
||
case .getDebatesMsg: | ||
return .requestPlain | ||
|
||
case .deleteDebatesRoom: | ||
return .requestPlain | ||
|
||
case .endDebatesRoom: | ||
return .requestPlain | ||
} | ||
} | ||
|
||
var headers: [String : String]? { | ||
|
||
let token: String | ||
|
||
switch self { | ||
|
||
case .getDebates(_, _, let accessToken), | ||
.createDebates(_, let accessToken), | ||
.saveDebatesHuman(_, _, let accessToken), | ||
.saveDebatesAI(_, _, let accessToken), | ||
.getDebatesSum(_, let accessToken), | ||
.sumDebates(_, let accessToken), | ||
.getDebatesMsg(_, let accessToken), | ||
.deleteDebatesRoom(_, let accessToken), | ||
.endDebatesRoom(_, let accessToken): | ||
token = accessToken | ||
return [ | ||
"Authorization": "Bearer \(token)", | ||
"X-Content-Type_Options" : "nosniff" | ||
] | ||
} | ||
} | ||
} | ||
|
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
Oops, something went wrong.