fromJson static method

CreateTenantUserBody? fromJson(
  1. dynamic value
)

Returns a new CreateTenantUserBody instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static CreateTenantUserBody? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      assert(json.containsKey(r'username'), 'Required key "CreateTenantUserBody[username]" is missing from JSON.');
      assert(json[r'username'] != null, 'Required key "CreateTenantUserBody[username]" has a null value in JSON.');
      assert(json.containsKey(r'email'), 'Required key "CreateTenantUserBody[email]" is missing from JSON.');
      assert(json[r'email'] != null, 'Required key "CreateTenantUserBody[email]" has a null value in JSON.');
      return true;
    }());

    return CreateTenantUserBody(
      username: mapValueOfType<String>(json, r'username')!,
      email: mapValueOfType<String>(json, r'email')!,
      displayName: mapValueOfType<String>(json, r'displayName'),
      websiteUrl: mapValueOfType<String>(json, r'websiteUrl'),
      signUpDate: mapValueOfType<double>(json, r'signUpDate'),
      locale: mapValueOfType<String>(json, r'locale'),
      verified: mapValueOfType<bool>(json, r'verified'),
      loginCount: mapValueOfType<double>(json, r'loginCount'),
      optedInNotifications: mapValueOfType<bool>(json, r'optedInNotifications'),
      optedInTenantNotifications: mapValueOfType<bool>(json, r'optedInTenantNotifications'),
      hideAccountCode: mapValueOfType<bool>(json, r'hideAccountCode'),
      avatarSrc: mapValueOfType<String>(json, r'avatarSrc'),
      isHelpRequestAdmin: mapValueOfType<bool>(json, r'isHelpRequestAdmin'),
      isAccountOwner: mapValueOfType<bool>(json, r'isAccountOwner'),
      isAdminAdmin: mapValueOfType<bool>(json, r'isAdminAdmin'),
      isBillingAdmin: mapValueOfType<bool>(json, r'isBillingAdmin'),
      isAnalyticsAdmin: mapValueOfType<bool>(json, r'isAnalyticsAdmin'),
      isCustomizationAdmin: mapValueOfType<bool>(json, r'isCustomizationAdmin'),
      isManageDataAdmin: mapValueOfType<bool>(json, r'isManageDataAdmin'),
      isCommentModeratorAdmin: mapValueOfType<bool>(json, r'isCommentModeratorAdmin'),
      isAPIAdmin: mapValueOfType<bool>(json, r'isAPIAdmin'),
      moderatorIds: json[r'moderatorIds'] is Iterable
          ? (json[r'moderatorIds'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      digestEmailFrequency: mapValueOfType<double>(json, r'digestEmailFrequency'),
      displayLabel: mapValueOfType<String>(json, r'displayLabel'),
    );
  }
  return null;
}