LCOV - code coverage report
Current view: top level - lib/src - contenttype_query.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 12 12 100.0 %
Date: 2021-05-07 19:45:01 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:async';
       2             : 
       3             : import 'package:contentstack/client.dart';
       4             : import 'package:contentstack/src/base_query.dart';
       5             : 
       6             : /// This call returns comprehensive information of all the content types
       7             : /// available in a particular stack in your account.
       8             : /// [ContentType](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#all-content-types).
       9             : class ContentTypeQuery extends BaseQuery {
      10             :   final HttpClient _client;
      11             :   String _urlPath;
      12           1 : 
      13           5 :   ContentTypeQuery([this._client]) {
      14           5 :     queryParameter['environment'] = _client.stackHeaders['environment'];
      15             :     _urlPath = '/${_client.stack.apiVersion}/content_types';
      16             :   }
      17             : 
      18             :   /// This call returns comprehensive information of all the content types
      19             :   /// available in a particular stack in your account.
      20             :   ///
      21             :   /// Example:
      22             :   ///
      23             :   /// ```dart
      24             :   /// final stack = contentstack.Stack('apiKey','deliveryToken','environment');
      25             :   /// final contentTypeQuery = stack.contentType().query()
      26             :   /// final response = contentTypeQuery.includeCount().find();
      27             :   /// print(response);
      28             :   /// ```
      29           1 :   ///
      30           2 :   Future<T> find<T, K>({Map<String, String> queryParams}) async {
      31             :     if (queryParams != null && queryParams.isNotEmpty) {
      32             :       queryParameter.addAll(queryParams);
      33             :     }
      34             :     final uri = Uri.https(_client.stack.endpoint, _urlPath, queryParameter);
      35             :     return _client.sendRequest<T, K>(uri);
      36             :   }
      37             : 
      38             :   ///
      39             :   /// This method includes the includeCount method facilitate to
      40             :   /// find the total count of content types available in your stack
      41             :   ///
      42             :   /// Example:
      43             :   /// ```dart
      44           1 :   /// final stack = contentstack.Stack('apiKey','deliveryToken','environment');
      45           2 :   /// final contentTypeQuery = stack.contentType().query()
      46             :   /// final response = contentTypeQuery.includeCount().find();
      47             :   /// print(response);
      48             :   /// ```
      49             :   ///
      50             :   void includeCount() {
      51             :     queryParameter['include_count'] = 'true';
      52             :   }
      53             : 
      54             :   /// This method includes the Global field's schema
      55             :   /// along with the content type schema
      56             :   ///
      57             :   /// Example:
      58             :   ///
      59             :   /// ```dart
      60           1 :   /// final stack = contentstack.Stack('apiKey','deliveryToken','environment');
      61           1 :   /// final contentTypeQuery = stack.contentType().query()
      62           2 :   /// final response = contentTypeQuery.includeGlobalField().find();
      63             :   /// print(response);
      64           6 :   /// ```
      65           2 :   void includeGlobalField() {
      66             :     queryParameter['include_global_field_schema'] = 'true';
      67             :   }
      68             : }

Generated by: LCOV version 1.15