fromJson static method
Returns a new PostsInput instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static PostsInput? 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'user_id'), 'Required key "PostsInput[user_id]" is missing from JSON.');
assert(json[r'user_id'] != null, 'Required key "PostsInput[user_id]" has a null value in JSON.');
assert(json.containsKey(r'company_id'), 'Required key "PostsInput[company_id]" is missing from JSON.');
assert(json[r'company_id'] != null, 'Required key "PostsInput[company_id]" has a null value in JSON.');
assert(json.containsKey(r'title'), 'Required key "PostsInput[title]" is missing from JSON.');
assert(json[r'title'] != null, 'Required key "PostsInput[title]" has a null value in JSON.');
assert(json.containsKey(r'content_html'), 'Required key "PostsInput[content_html]" is missing from JSON.');
assert(json[r'content_html'] != null, 'Required key "PostsInput[content_html]" has a null value in JSON.');
return true;
}());
return PostsInput(
userId: mapValueOfType<String>(json, r'user_id')!,
companyId: mapValueOfType<String>(json, r'company_id')!,
title: mapValueOfType<String>(json, r'title')!,
category: mapValueOfType<String>(json, r'category'),
teaser: mapValueOfType<String>(json, r'teaser'),
contentHtml: mapValueOfType<String>(json, r'content_html')!,
insightsUsed: mapValueOfType<Object>(json, r'insights_used'),
generationCreativity: mapValueOfType<int>(json, r'generation_creativity'),
generationTargetWordCount: mapValueOfType<int>(json, r'generation_target_word_count'),
generationTone: mapValueOfType<String>(json, r'generation_tone'),
generationIncludeCitations: mapValueOfType<bool>(json, r'generation_include_citations'),
generationSubheadingCount: mapValueOfType<int>(json, r'generation_subheading_count'),
generationTemperature: mapValueOfType<double>(json, r'generation_temperature'),
dataCostCredits: mapValueOfType<int>(json, r'data_cost_credits'),
serviceCostCredits: mapValueOfType<int>(json, r'service_cost_credits'),
totalCostCredits: mapValueOfType<int>(json, r'total_cost_credits'),
successfulInsightsCount: mapValueOfType<int>(json, r'successful_insights_count'),
failedInsightsCount: mapValueOfType<int>(json, r'failed_insights_count'),
generationTimeMs: mapValueOfType<int>(json, r'generation_time_ms'),
isPublished: mapValueOfType<bool>(json, r'is_published'),
publishedAt: mapDateTime(json, r'published_at', r''),
viewCount: mapValueOfType<int>(json, r'view_count'),
lastEditedAt: mapDateTime(json, r'last_edited_at', r''),
);
}
return null;
}