getStories method
Future<List<Story<StoryContent> > >
getStories({
- String? startsWith,
- String? searchTerm,
- String? sortBy,
- Pagination? pagination,
- List<
String> ? byFullSlugs, - List<
String> ? excludingFullSlugs, - DateTime? publishedAfter,
- DateTime? publishedBefore,
- DateTime? firstPublishedAfter,
- DateTime? firstPublishedBefore,
- List<
int> ? inWorkflowStages, - String? contentType,
- int? level,
- List<
String> ? resolveRelations, - List<
String> ? excludingIDs, - ({bool ordered, List<
String> uuids})? byUUIDs, - List<
String> ? withTags, - bool? isStartpage,
- ResolveLinks? resolveLinks,
- bool resolveLinks2Levels = true,
- String? fromRelease,
- String? fallbackLanguage,
- String? language,
- List<
String> ? excludingFields, - int? resolveAssets,
Retrieve multiple stories
Implementation
Future<List<Story<StoryContent>>> getStories({
String? startsWith,
String? searchTerm,
String? sortBy,
Pagination? pagination,
List<String>? byFullSlugs,
List<String>? excludingFullSlugs,
DateTime? publishedAfter,
DateTime? publishedBefore,
DateTime? firstPublishedAfter,
DateTime? firstPublishedBefore,
List<int>? inWorkflowStages,
String? contentType,
int? level,
List<String>? resolveRelations,
List<String>? excludingIDs,
({List<String> uuids, bool ordered})? byUUIDs,
List<String>? withTags,
bool? isStartpage,
ResolveLinks? resolveLinks,
bool resolveLinks2Levels = true,
String? fromRelease,
String? fallbackLanguage,
String? language,
// TODO: filter_query
List<String>? excludingFields,
int? resolveAssets,
}) async {
final json = await _getRequest(
path: _pathStories,
queryParameters: {
if (_cacheVersion != null) "cv": _cacheVersion.toString(),
if (_version != null) "version": _version.name,
if (startsWith != null) "starts_with": startsWith,
if (searchTerm != null) "search_term": searchTerm,
if (sortBy != null) "sort_by": sortBy,
if (pagination != null) ...pagination.toParameters(),
if (byFullSlugs != null) "by_slugs": byFullSlugs.join(","),
if (excludingFullSlugs != null) "excluding_slugs": excludingFullSlugs.join(","),
if (publishedAfter != null) "published_at_gt": publishedAfter.format(),
if (publishedBefore != null) "published_at_lt": publishedBefore.format(),
if (firstPublishedAfter != null) "first_published_at_gt": firstPublishedAfter.format(),
if (firstPublishedBefore != null) "first_published_at_lt": firstPublishedBefore.format(),
if (inWorkflowStages != null) "in_workflow_stages": inWorkflowStages.join(","),
if (contentType != null) "content_type": contentType,
if (level != null) "level": level.toString(),
if (resolveRelations != null && resolveRelations.isNotEmpty) "resolve_relations": resolveRelations.join(","),
if (excludingIDs != null) "excluding_ids": excludingIDs.join(","),
if (byUUIDs != null) byUUIDs.ordered ? "by_uuids_ordered" : "by_uuids": byUUIDs.uuids.join(","),
if (withTags != null) "with_tag": withTags.join(","),
if (isStartpage != null) "is_startpage": isStartpage ? "1" : "0",
if (resolveLinks != null) "resolve_links": resolveLinks.name,
if (resolveLinks2Levels) "resolve_links_level": "2",
if (fromRelease != null) "from_release": fromRelease,
if (fallbackLanguage != null) "fallback_lang": fallbackLanguage,
if (language != null) "language": language,
// TODO: filter_query
if (excludingFields != null) "excluding_fields": excludingFields.join(","),
if (resolveAssets != null) "resolve_assets": resolveAssets.toString(),
},
);
if (resolveLinks != null) {
_handleResolvedLinks(resolveLinks, json);
}
if (resolveRelations != null && resolveRelations.isNotEmpty) {
_handleResolvedRelations(json);
}
final stories = List<JSONMap>.from(json["stories"]) //
.map((e) => Story<StoryContent>.fromJson(e, _storyContentBuilder))
.toList();
return stories;
}