sync<T, K> method

Future<T> sync<T, K>(
  1. {String contentTypeUid,
  2. String fromDate,
  3. String locale,
  4. PublishType publishType}
)

////////////////////////////////////////////// //////////////////////////////////////////////

  • contentTypeUid -- You can also initialize sync with entries of only specific content_type. To do this, use syncContentType and specify the content type uid as its value. However, if you do this, the subsequent syncs will only include the entries of the specified content_type.

  • fromDate -- You can also initialize sync with entries published after a specific date. To do this, use from_date and specify the start date as its value.

  • locale -- You can also initialize sync with entries of only specific locales. To do this, use syncLocale and specify the locale code as its value. However, if you do this, the subsequent syncs will only include the entries of the specified locales.

  • publishType -- Use the type parameter to get a specific type of content. If you do not specify any value, it will bring all published entries and published assets.

Returns: List Of SyncResult

Implementation

//    ---------[Synchronization]----------     //
/////////////////////////////////////////////////

/// * [contentTypeUid] -- You can also initialize sync with entries of
/// only specific content_type. To do this, use syncContentType and specify
/// the content type uid as its value. However, if you do this,
/// the subsequent syncs will only include the entries of the
/// specified content_type.
///
/// * [fromDate] -- You can also initialize sync with entries published
/// after a specific date. To do this, use from_date
/// and specify the start date as its value.
///
/// * [locale] -- You can also initialize sync with entries of
/// only specific locales.
/// To do this, use syncLocale and specify the locale code as its value.
/// However, if you do this, the subsequent syncs will only include
/// the entries of the specified locales.
///
/// * [publishType] -- Use the type parameter
/// to get a specific type of content.
/// If you do not specify any value,
/// it will bring all published entries and published assets.
///
/// Returns: List Of [SyncResult]
///
Future<T> sync<T, K>(
    {String contentTypeUid,
    String fromDate,
    String locale,
    PublishType publishType}) async {
  final parameter = <String, String>{};
  parameter['init'] = 'true';
  if (contentTypeUid != null && contentTypeUid.isNotEmpty) {
    parameter['content_type_uid'] = contentTypeUid;
  }
  if (fromDate != null && fromDate.isNotEmpty) {
    parameter['from_date'] = fromDate;
  }
  if (locale != null && locale.isNotEmpty) {
    parameter['locale'] = locale;
  }
  if (publishType != null) {
    publishType.when(assetPublished: (result) {
      parameter['publish_type'] = 'asset_published';
    }, entryPublished: (result) {
      parameter['publish_type'] = 'entry_published';
    }, assetUnpublished: (result) {
      parameter['publish_type'] = 'asset_unpublished';
    }, assetDeleted: (result) {
      parameter['publish_type'] = 'asset_deleted';
    }, entryUnpublished: (result) {
      parameter['publish_type'] = 'entry_unpublished';
    }, entryDeleted: (result) {
      parameter['publish_type'] = 'entry_deleted';
    }, contentTypeDeleted: (result) {
      parameter['publish_type'] = 'content_type_deleted';
    });
  }

  return _syncRequest<T, K>(parameter);
}