Vernissage/PixelfedKit/Sources/PixelfedKit/MastodonClient+Search.swift

21 lines
581 B
Swift
Raw Normal View History

2023-01-23 18:01:27 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License.
//
import Foundation
public extension MastodonClientAuthenticated {
func search(query: String, type: Mastodon.Search.ResultsType) async throws -> SearchResults {
let request = try Self.request(
for: baseURL,
target: Mastodon.Search.search(query, type, false),
withBearerToken: token
)
return try await downloadJson(SearchResults.self, request: request)
}
}