toJson method
Returns a JSON map for the request body.
Implementation
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (displayName != null) map['display_name'] = displayName;
if (note != null) map['note'] = note;
if (avatar != null) map['avatar'] = avatar;
if (header != null) map['header'] = header;
if (locked != null) map['locked'] = locked;
if (bot != null) map['bot'] = bot;
if (discoverable != null) map['discoverable'] = discoverable;
if (hideCollections != null) map['hide_collections'] = hideCollections;
if (indexable != null) map['indexable'] = indexable;
if (attributionDomains != null) {
map['attribution_domains'] = attributionDomains;
}
if (fieldsAttributes != null) {
map['fields_attributes'] = fieldsAttributes!
.map(
(f) => <String, dynamic>{
'name': f.name,
'value': f.value,
},
)
.toList();
}
if (sourcePrivacy != null ||
sourceSensitive != null ||
sourceLanguage != null ||
sourceQuotePolicy != null) {
map['source'] = <String, dynamic>{
if (sourcePrivacy != null) 'privacy': sourcePrivacy,
if (sourceSensitive != null) 'sensitive': sourceSensitive,
if (sourceLanguage != null) 'language': sourceLanguage,
if (sourceQuotePolicy != null) 'quote_policy': sourceQuotePolicy,
};
}
return map;
}