Vernissage/PixelfedKit/Sources/PixelfedKit/PixelfedClient+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
2023-02-19 10:43:37 +01:00
public extension PixelfedClientAuthenticated {
2023-01-23 18:01:27 +01:00
2023-02-19 10:43:37 +01:00
func search(query: String, type: Pixelfed.Search.ResultsType) async throws -> SearchResults {
2023-01-23 18:01:27 +01:00
let request = try Self.request(
for: baseURL,
2023-02-19 10:43:37 +01:00
target: Pixelfed.Search.search(query, type, false),
2023-01-23 18:01:27 +01:00
withBearerToken: token
)
return try await downloadJson(SearchResults.self, request: request)
}
}