Line data Source code
1 : import 'dart:async'; 2 : import 'package:contentstack/client.dart'; 3 : import 'package:contentstack/src/base_query.dart'; 4 : 5 : /// Assets refer to all the media files (images, videos, PDFs, audio files, and so on) 6 : /// uploaded in your Contentstack repository for future use. These files can be 7 : /// attached and used in multiple entries. Learn more about Assets. 8 : /// https://www.contentstack.com/docs/content-managers/work-with-assets 9 : /// 10 : /// * All Assets 11 : /// This call fetches the list of all the assets of a particular stack 12 : /// Learn more about All Assets. 13 : /// https://www.contentstack.com/docs/developers/apis/content-delivery-api/#get-all-assets 14 : /// 15 : class AssetQuery extends BaseQuery { 16 : final HttpClient _client; 17 : String _urlPath; 18 : 19 1 : AssetQuery([this._client]) { 20 5 : queryParameter['environment'] = _client.stackHeaders['environment']; 21 5 : _urlPath = '/${_client.stack.apiVersion}/assets'; 22 : } 23 : 24 : /// 25 : /// Enter the name of the [environment] if you wish to retrieve 26 : /// the assets published in a particular environment. 27 : /// [environment] required 28 : /// 29 1 : void environment(String environment) { 30 2 : queryParameter['environment'] = environment; 31 : } 32 : 33 : /// 34 : /// Specify the version number of the asset that you wish to retrieve. 35 : /// If the version is not specified, the details of the latest version will be retrieved. 36 : /// To retrieve a specific version, keep the environment parameter blank. 37 : /// [version] required 38 : /// 39 1 : void version(int version) { 40 3 : queryParameter['version'] = version.toString(); 41 : } 42 : 43 : /// 44 : /// include the dimensions (height and width) of the image in the response. 45 : /// Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, and PSD. 46 : /// 47 1 : void includeDimension() { 48 2 : queryParameter['include_dimension'] = 'true'; 49 : } 50 : 51 : /// 52 : /// include the relative URLs of the assets in the response. 53 : /// 54 1 : void relativeUrls() { 55 2 : queryParameter['relative_urls'] = 'true'; 56 : } 57 : 58 1 : void includeCount() { 59 2 : queryParameter['include_count'] = 'true'; 60 : } 61 : 62 : /// find is applicable for getting all the available assets based on the query 63 1 : Future<T> find<T, K>() async { 64 7 : final uri = Uri.https(_client.stack.endpoint, '$_urlPath', queryParameter); 65 2 : return _client.sendRequest<T, K>(uri); 66 : } 67 : }