fromJson static method

MentorFromTemplateWithSettingRequest? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static MentorFromTemplateWithSettingRequest? 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(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "MentorFromTemplateWithSettingRequest[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "MentorFromTemplateWithSettingRequest[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return MentorFromTemplateWithSettingRequest(
      templateName: mapValueOfType<String>(json, r'template_name')!,
      displayName: mapValueOfType<String>(json, r'display_name')!,
      description: mapValueOfType<String>(json, r'description')!,
      profileImage: mapValueOfType<String>(json, r'profile_image')!,
      initialMessage: mapValueOfType<String>(json, r'initial_message')!,
      suggestedMessage: mapValueOfType<String>(json, r'suggested_message')!,
      theme: mapValueOfType<String>(json, r'theme')!,
      userMessageColor: mapValueOfType<String>(json, r'user_message_color')!,
      mentorBubbleColor: mapValueOfType<String>(json, r'mentor_bubble_color')!,
      alignMentorBubble: mapValueOfType<String>(json, r'align_mentor_bubble')!,
      systemPrompt: mapValueOfType<String>(json, r'system_prompt'),
      llmName: mapValueOfType<String>(json, r'llm_name'),
      mentorVisibility: mapValueOfType<String>(json, r'mentor_visibility'),
      enableImageGeneration: mapValueOfType<bool>(json, r'enable_image_generation'),
    );
  }
  return null;
}