SiteConfig.fromJson constructor

SiteConfig.fromJson(
  1. Json j
)

Parses the wire shape, keeping unknown fields in raw.

Implementation

factory SiteConfig.fromJson(Json j) => SiteConfig(
  siteId: strOr(j, 'site_id'),
  name: strOr(j, 'name'),
  color: strOr(j, 'color', '#0ea5e9'),
  position: strOr(j, 'position', 'right'),
  localeDefault: strOr(j, 'locale_default', 'auto'),
  greeting: stringMapOf(j, 'greeting'),
  awayMessage: stringMapOf(j, 'away_message'),
  offlineCapture: OfflineCapture.parse(str(j, 'offline_capture')),
  hideWhenOffline: boolOr(j, 'hide_when_offline'),
  theme: SiteTheme.parse(str(j, 'theme')),
  botEnabled: boolOr(j, 'bot_enabled'),
  agentAvatars: [for (final a in mapListOf(j, 'agent_avatars')) AgentAvatar.fromJson(a)],
  launcher: switch (mapOf(j, 'launcher')) {
    final l? => LauncherConfig.fromJson(l),
    null => const LauncherConfig(),
  },
  header: switch (mapOf(j, 'header')) {
    final h? => HeaderConfig.fromJson(h),
    null => null,
  },
  greetingOptions: switch (mapOf(j, 'greeting_options')) {
    final g? => GreetingOptions.fromJson(g),
    null => null,
  },
  contactButtons: [for (final c in mapListOf(j, 'contact_buttons')) ?ContactButton.tryParse(c)],
  raw: j,
);