라이브 메인 페이지
This commit is contained in:
21
SodaLive/Sources/Settings/Event/Event.swift
Normal file
21
SodaLive/Sources/Settings/Event/Event.swift
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Event.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/09.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct GetEventResponse: Decodable {
|
||||
let totalCount: Int
|
||||
let eventList: [EventItem]
|
||||
}
|
||||
|
||||
struct EventItem: Decodable, Hashable {
|
||||
let id: Int
|
||||
let thumbnailImageUrl: String
|
||||
let detailImageUrl: String?
|
||||
let popupImageUrl: String?
|
||||
let link: String?
|
||||
}
|
48
SodaLive/Sources/Settings/Event/EventApi.swift
Normal file
48
SodaLive/Sources/Settings/Event/EventApi.swift
Normal file
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// EventApi.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/09.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Moya
|
||||
|
||||
enum EventApi {
|
||||
case getEvents
|
||||
case getEventPopup
|
||||
}
|
||||
|
||||
extension EventApi: TargetType {
|
||||
var baseURL: URL {
|
||||
return URL(string: BASE_URL)!
|
||||
}
|
||||
|
||||
var path: String {
|
||||
switch self {
|
||||
case .getEvents:
|
||||
return "/event"
|
||||
|
||||
case .getEventPopup:
|
||||
return "/event/popup"
|
||||
}
|
||||
}
|
||||
|
||||
var method: Moya.Method {
|
||||
switch self {
|
||||
case .getEvents, .getEventPopup:
|
||||
return .get
|
||||
}
|
||||
}
|
||||
|
||||
var task: Task {
|
||||
switch self {
|
||||
case .getEvents, .getEventPopup:
|
||||
return .requestPlain
|
||||
}
|
||||
}
|
||||
|
||||
var headers: [String : String]? {
|
||||
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
|
||||
}
|
||||
}
|
24
SodaLive/Sources/Settings/Event/EventRepository.swift
Normal file
24
SodaLive/Sources/Settings/Event/EventRepository.swift
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// EventRepository.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/09.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CombineMoya
|
||||
import Combine
|
||||
import Moya
|
||||
|
||||
final class EventRepository {
|
||||
private let api = MoyaProvider<EventApi>()
|
||||
|
||||
func getEvents() -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getEvents)
|
||||
}
|
||||
|
||||
func getEventPopup() -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getEventPopup)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user