searchRaw method
Launch a search for a specific search provider.
Additional filters are available for each provider. Send a request to /providers endpoint to list providers with their available filters.
This method and the response it returns is experimental. The API might change without a major version bump.
Returns a Future containing a DynamiteRawResponse with the raw HttpClientResponse and serialization helpers. Throws a DynamiteApiException if the API call does not return an expected status code.
Parameters:
termTerm to search. Defaults to''.sortOrderOrder of entries.limitMaximum amount of entries.cursorOffset for searching.fromThe current user URL. Defaults to''.providerIdID of the provider.oCSAPIRequestRequired to be true for the API request to pass. Defaults totrue.
Status codes:
- 200: Search entries returned
- 400: Searching is not possible
See:
- search for an operation that returns a DynamiteResponse with a stable API.
Implementation
@experimental
DynamiteRawResponse<UnifiedSearchSearchResponseApplicationJson, void> searchRaw({
required String providerId,
String? term,
int? sortOrder,
int? limit,
UnifiedSearchSearchCursor? cursor,
String? from,
bool? oCSAPIRequest,
}) {
final _parameters = <String, dynamic>{};
final _headers = <String, String>{
'Accept': 'application/json',
};
// coverage:ignore-start
final authentication = _rootClient.authentications.firstWhereOrNull(
(auth) => switch (auth) {
DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true,
_ => false,
},
);
if (authentication != null) {
_headers.addAll(
authentication.headers,
);
} else {
throw Exception('Missing authentication for bearer_auth or basic_auth');
}
// coverage:ignore-end
final $providerId = jsonSerializers.serialize(providerId, specifiedType: const FullType(String));
_parameters['providerId'] = $providerId;
var $term = jsonSerializers.serialize(term, specifiedType: const FullType(String));
$term ??= '';
_parameters['term'] = $term;
final $sortOrder = jsonSerializers.serialize(sortOrder, specifiedType: const FullType(int));
_parameters['sortOrder'] = $sortOrder;
final $limit = jsonSerializers.serialize(limit, specifiedType: const FullType(int));
_parameters['limit'] = $limit;
final $cursor = jsonSerializers.serialize(cursor, specifiedType: const FullType(UnifiedSearchSearchCursor));
_parameters['cursor'] = $cursor;
var $from = jsonSerializers.serialize(from, specifiedType: const FullType(String));
$from ??= '';
_parameters['from'] = $from;
var $oCSAPIRequest = jsonSerializers.serialize(oCSAPIRequest, specifiedType: const FullType(bool));
$oCSAPIRequest ??= true;
_headers['OCS-APIRequest'] = const dynamite_utils.HeaderEncoder().convert($oCSAPIRequest);
final _path =
UriTemplate('/ocs/v2.php/search/providers/{providerId}/search{?term*,sortOrder*,limit*,cursor*,from*}')
.expand(_parameters);
return DynamiteRawResponse<UnifiedSearchSearchResponseApplicationJson, void>(
response: _rootClient.executeRequest(
'get',
_path,
_headers,
null,
const {200},
),
bodyType: const FullType(UnifiedSearchSearchResponseApplicationJson),
headersType: null,
serializers: jsonSerializers,
);
}