feat: add additionalProperties in PusherData

This commit is contained in:
Lukas Lihotzki 2021-12-07 03:44:35 +01:00
parent 454e27239c
commit 793ddddd3f
1 changed files with 8 additions and 1 deletions

View File

@ -1281,15 +1281,20 @@ class PusherData {
PusherData({ PusherData({
this.format, this.format,
this.url, this.url,
this.additionalProperties = const {},
}); });
PusherData.fromJson(Map<String, dynamic> json) PusherData.fromJson(Map<String, dynamic> json)
: format = ((v) => v != null ? v as String : null)(json['format']), : format = ((v) => v != null ? v as String : null)(json['format']),
url = ((v) => v != null ? Uri.parse(v) : null)(json['url']); url = ((v) => v != null ? Uri.parse(v) : null)(json['url']),
additionalProperties = Map.fromEntries(json.entries
.where((e) => !['format', 'url'].contains(e.key))
.map((e) => MapEntry(e.key, e.value as dynamic)));
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final format = this.format; final format = this.format;
final url = this.url; final url = this.url;
return { return {
...additionalProperties,
if (format != null) 'format': format, if (format != null) 'format': format,
if (url != null) 'url': url.toString(), if (url != null) 'url': url.toString(),
}; };
@ -1302,6 +1307,8 @@ class PusherData {
/// Required if `kind` is `http`. The URL to use to send /// Required if `kind` is `http`. The URL to use to send
/// notifications to. /// notifications to.
Uri? url; Uri? url;
Map<String, dynamic> additionalProperties;
} }
@_NameSource('spec') @_NameSource('spec')