2023-01-23 18:01:27 +01:00
|
|
|
//
|
|
|
|
// https://mczachurski.dev
|
|
|
|
// Copyright © 2023 Marcin Czachurski and the repository contributors.
|
2023-03-28 10:35:38 +02:00
|
|
|
// Licensed under the Apache License 2.0.
|
2023-01-23 18:01:27 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2023-02-19 10:43:37 +01:00
|
|
|
public extension PixelfedClientAuthenticated {
|
2023-01-23 18:01:27 +01:00
|
|
|
|
2023-03-07 16:45:44 +01:00
|
|
|
func search(query: String, type: Pixelfed.Search.ResultsType, limit: Int = 20, page: Int = 1) async throws -> SearchResults {
|
2023-01-23 18:01:27 +01:00
|
|
|
let request = try Self.request(
|
|
|
|
for: baseURL,
|
2023-03-07 16:45:44 +01:00
|
|
|
target: Pixelfed.Search.search(query, type, false, nil, nil, nil, limit, page),
|
2023-01-23 18:01:27 +01:00
|
|
|
withBearerToken: token
|
|
|
|
)
|
|
|
|
|
|
|
|
return try await downloadJson(SearchResults.self, request: request)
|
|
|
|
}
|
|
|
|
}
|