Skip to content

Models: preferences

Topics, channels and choices, from package:crm_sdk/wire.dart.

import 'package:crm_sdk/wire.dart';
NameWhat it is
CrmExportConsentChangeOne change of the guest’s choices, in their export: a topic’s, or a channel’s own switch (topic empty).
CrmExportSubscriptionOne of the guest’s choices about a topic by a channel, in their export.
CrmPreferenceChoiceOne choice: a topic, a channel, in or out.
CrmPreferenceStateOne channel of a topic, and whether the guest is subscribed by it.
CrmPreferenceTopicOne of the app’s topics, as the guest sees it.
CrmPreferencesThe guest’s preferences: every topic of the app’s not archived, and whether all their marketing is off.
CrmPreferencesBodyThe guest’s choices, kept as a change only where each differs from what they had; or allOff, “Unsubscribe from all marketing”. wording is the version of the words they agreed under.
CrmPublicPreferencesWhat PurrCRM’s public preference centre shows: the app’s brand, the address with most of it hidden, and the guest’s preferences.
crmMaxPreferenceChoicesThe most choices one body makes.
crmMaxPreferenceWordingThe longest wording version a body names.
crmPreferencesWordingThe wording version the package’s own preferences screen sends, so that what a guest agreed under is on record (the screen’s words are the package’s l10n strings, versioned with it).
class CrmExportConsentChange

One change of the guest’s choices, in their export: a topic’s, or a channel’s own switch (topic empty).

factory CrmExportConsentChange.fromJson(Map<String, Object?> json)
const CrmExportConsentChange({required DateTime at, required CrmPreferenceChannel channel, required bool subscribed, required String source, String topic = '', String wording = ''})
final DateTime at
final CrmPreferenceChannel channel
final String source
final bool subscribed
final String topic
final String wording
class CrmExportSubscription

One of the guest’s choices about a topic by a channel, in their export.

factory CrmExportSubscription.fromJson(Map<String, Object?> json)
const CrmExportSubscription({required String topic, required CrmPreferenceChannel channel, required bool subscribed, required DateTime changedAt, required String source, String wording = ''})
final DateTime changedAt
final CrmPreferenceChannel channel
final String source

How it was made, in PurrCRM’s word: page, email, staff, import, api, sdk or migration.

final bool subscribed
final String topic

The topic’s name.

final String wording
class CrmPreferenceChoice

One choice: a topic, a channel, in or out.

factory CrmPreferenceChoice.fromJson(Map<String, Object?> json)
const CrmPreferenceChoice({required String topicId, required CrmPreferenceChannel channel, required bool subscribed})
final CrmPreferenceChannel channel
final bool subscribed
final String topicId
Map<String, Object?> toJson()
class CrmPreferenceState

One channel of a topic, and whether the guest is subscribed by it.

factory CrmPreferenceState.fromJson(Map<String, Object?> json)
const CrmPreferenceState({required CrmPreferenceChannel channel, required bool subscribed})
final CrmPreferenceChannel channel
final bool subscribed
class CrmPreferenceTopic

One of the app’s topics, as the guest sees it.

factory CrmPreferenceTopic.fromJson(Map<String, Object?> json)
const CrmPreferenceTopic({required String id, required String name, String description = '', List<CrmPreferenceState> channels = const <CrmPreferenceState>[]})
final List<CrmPreferenceState> channels

The channels it goes by, in PurrCRM’s order, a channel this package does not know yet left for the screen to skip.

final String description
final String id
final String name
class CrmPreferences

The guest’s preferences: every topic of the app’s not archived, and whether all their marketing is off.

factory CrmPreferences.fromJson(Map<String, Object?> json)
const CrmPreferences({List<CrmPreferenceTopic> topics = const <CrmPreferenceTopic>[], bool allOff = false})
final bool allOff

Every channel’s own switch is off: no topic reaches them until they choose one again.

final List<CrmPreferenceTopic> topics
class CrmPreferencesBody

The guest’s choices, kept as a change only where each differs from what they had; or allOff, “Unsubscribe from all marketing”. wording is the version of the words they agreed under.

factory CrmPreferencesBody.fromJson(Map<String, Object?> json)
const CrmPreferencesBody({List<CrmPreferenceChoice> choices = const <CrmPreferenceChoice>[], bool allOff = false, String wording = ''})
final bool allOff
final List<CrmPreferenceChoice> choices
final String wording
Map<String, Object?> toJson()
class CrmPublicPreferences

What PurrCRM’s public preference centre shows: the app’s brand, the address with most of it hidden, and the guest’s preferences. The package never asks for it (the page is PurrCRM’s site’s); it is here so that every fixture has a model.

factory CrmPublicPreferences.fromJson(Map<String, Object?> json)
const CrmPublicPreferences({required String product, String accent = '', String logoUrl = '', String email = '', CrmPreferences preferences = const CrmPreferences()})
final String accent
final String email
final String logoUrl
final CrmPreferences preferences
final String product
const int crmMaxPreferenceChoices

The most choices one body makes. The Go constant is MaxPreferenceChoices.

const int crmMaxPreferenceWording

The longest wording version a body names. The Go constant is MaxPreferenceWording.

const String crmPreferencesWording

The wording version the package’s own preferences screen sends, so that what a guest agreed under is on record (the screen’s words are the package’s l10n strings, versioned with it).

Protocol data: PurrCRM keeps it beside every consent given through the screen, so it stays byte for byte while the screen’s words stay as they are. Only a change to those words takes a new id (crm_sdk/preferences-2, say), with a CHANGELOG entry.