62 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  SearchRepository.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 3/27/25.
 | 
						|
//
 | 
						|
 | 
						|
import Foundation
 | 
						|
import CombineMoya
 | 
						|
import Combine
 | 
						|
import Moya
 | 
						|
 | 
						|
final class SearchRepository {
 | 
						|
    private let api = MoyaProvider<SearchApi>()
 | 
						|
    
 | 
						|
    func searchUnified(keyword: String) -> AnyPublisher<Response, MoyaError> {
 | 
						|
        return api.requestPublisher(
 | 
						|
            .searchUnified(
 | 
						|
                keyword: keyword,
 | 
						|
                isAdultContentVisible: UserDefaults.isAdultContentVisible(),
 | 
						|
                contentType: ContentType(rawValue: UserDefaults.string(forKey: .contentPreference)) ?? ContentType.ALL
 | 
						|
            )
 | 
						|
        )
 | 
						|
    }
 | 
						|
    
 | 
						|
    func searchCreatorList(keyword: String, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
 | 
						|
        return api.requestPublisher(
 | 
						|
            .searchCreatorList(
 | 
						|
                keyword: keyword,
 | 
						|
                isAdultContentVisible: UserDefaults.isAdultContentVisible(),
 | 
						|
                contentType: ContentType(rawValue: UserDefaults.string(forKey: .contentPreference)) ?? ContentType.ALL,
 | 
						|
                page: page,
 | 
						|
                size: size
 | 
						|
            )
 | 
						|
        )
 | 
						|
    }
 | 
						|
    
 | 
						|
    func searchContentList(keyword: String, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
 | 
						|
        return api.requestPublisher(
 | 
						|
            .searchContentList(
 | 
						|
                keyword: keyword,
 | 
						|
                isAdultContentVisible: UserDefaults.isAdultContentVisible(),
 | 
						|
                contentType: ContentType(rawValue: UserDefaults.string(forKey: .contentPreference)) ?? ContentType.ALL,
 | 
						|
                page: page,
 | 
						|
                size: size
 | 
						|
            )
 | 
						|
        )
 | 
						|
    }
 | 
						|
    
 | 
						|
    func searchSeriesList(keyword: String, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
 | 
						|
        return api.requestPublisher(
 | 
						|
            .searchSeriesList(
 | 
						|
                keyword: keyword,
 | 
						|
                isAdultContentVisible: UserDefaults.isAdultContentVisible(),
 | 
						|
                contentType: ContentType(rawValue: UserDefaults.string(forKey: .contentPreference)) ?? ContentType.ALL,
 | 
						|
                page: page,
 | 
						|
                size: size
 | 
						|
            )
 | 
						|
        )
 | 
						|
    }
 | 
						|
}
 |