mastodon-ios/Mastodon/Service/APIService/APIService+Onboarding.swift

33 lines
942 B
Swift
Raw Normal View History

//
// APIService+Onboarding.swift
// Mastodon
//
// Created by MainasuK Cirno on 2021-2-19.
//
import Foundation
import Combine
import MastodonSDK
extension APIService {
func servers(
language: String?,
category: String?
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Server]>, Error> {
let query = Mastodon.API.Onboarding.ServersQuery(language: language, category: category)
return Mastodon.API.Onboarding.servers(session: session, query: query)
}
func categories() -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Category]>, Error> {
return Mastodon.API.Onboarding.categories(session: session)
}
static func stubCategories() -> [Mastodon.Entity.Category] {
2021-02-19 05:17:12 +01:00
return Mastodon.Entity.Category.Kind.allCases.map { kind in
return Mastodon.Entity.Category(category: kind.rawValue, serversCount: 0)
}
}
}