ToneSnap_FSX_Flutter/lib/data/models/search_suggestions_model.dart
2024-08-01 13:38:25 +08:00

306 lines
8.6 KiB
Dart

// Author: fengshengxiong
// Date: 2024/7/28
// Description: 搜索建议模型
import 'dart:convert';
class SearchSuggestionsModel {
ResponseContext? responseContext;
List<SearchSuggestionsModelContent>? contents;
String? trackingParams;
SearchSuggestionsModel({
this.responseContext,
this.contents,
this.trackingParams,
});
factory SearchSuggestionsModel.fromJson(String str) => SearchSuggestionsModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory SearchSuggestionsModel.fromMap(Map<String, dynamic> json) => SearchSuggestionsModel(
responseContext: json["responseContext"] == null ? null : ResponseContext.fromMap(json["responseContext"]),
contents: json["contents"] == null ? [] : List<SearchSuggestionsModelContent>.from(json["contents"]!.map((x) => SearchSuggestionsModelContent.fromMap(x))),
trackingParams: json["trackingParams"],
);
Map<String, dynamic> toMap() => {
"responseContext": responseContext?.toMap(),
"contents": contents == null ? [] : List<dynamic>.from(contents!.map((x) => x.toMap())),
"trackingParams": trackingParams,
};
}
class SearchSuggestionsModelContent {
SearchSuggestionsSectionRenderer? searchSuggestionsSectionRenderer;
SearchSuggestionsModelContent({
this.searchSuggestionsSectionRenderer,
});
factory SearchSuggestionsModelContent.fromJson(String str) => SearchSuggestionsModelContent.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory SearchSuggestionsModelContent.fromMap(Map<String, dynamic> json) => SearchSuggestionsModelContent(
searchSuggestionsSectionRenderer: json["searchSuggestionsSectionRenderer"] == null ? null : SearchSuggestionsSectionRenderer.fromMap(json["searchSuggestionsSectionRenderer"]),
);
Map<String, dynamic> toMap() => {
"searchSuggestionsSectionRenderer": searchSuggestionsSectionRenderer?.toMap(),
};
}
class SearchSuggestionsSectionRenderer {
List<SearchSuggestionsSectionRendererContent>? contents;
SearchSuggestionsSectionRenderer({
this.contents,
});
factory SearchSuggestionsSectionRenderer.fromJson(String str) => SearchSuggestionsSectionRenderer.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory SearchSuggestionsSectionRenderer.fromMap(Map<String, dynamic> json) => SearchSuggestionsSectionRenderer(
contents: json["contents"] == null ? [] : List<SearchSuggestionsSectionRendererContent>.from(json["contents"]!.map((x) => SearchSuggestionsSectionRendererContent.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"contents": contents == null ? [] : List<dynamic>.from(contents!.map((x) => x.toMap())),
};
}
class SearchSuggestionsSectionRendererContent {
SearchSuggestionRenderer? searchSuggestionRenderer;
SearchSuggestionsSectionRendererContent({
this.searchSuggestionRenderer,
});
factory SearchSuggestionsSectionRendererContent.fromJson(String str) => SearchSuggestionsSectionRendererContent.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory SearchSuggestionsSectionRendererContent.fromMap(Map<String, dynamic> json) => SearchSuggestionsSectionRendererContent(
searchSuggestionRenderer: json["searchSuggestionRenderer"] == null ? null : SearchSuggestionRenderer.fromMap(json["searchSuggestionRenderer"]),
);
Map<String, dynamic> toMap() => {
"searchSuggestionRenderer": searchSuggestionRenderer?.toMap(),
};
}
class SearchSuggestionRenderer {
Suggestion? suggestion;
NavigationEndpoint? navigationEndpoint;
String? trackingParams;
Icon? icon;
SearchSuggestionRenderer({
this.suggestion,
this.navigationEndpoint,
this.trackingParams,
this.icon,
});
factory SearchSuggestionRenderer.fromJson(String str) => SearchSuggestionRenderer.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory SearchSuggestionRenderer.fromMap(Map<String, dynamic> json) => SearchSuggestionRenderer(
suggestion: json["suggestion"] == null ? null : Suggestion.fromMap(json["suggestion"]),
navigationEndpoint: json["navigationEndpoint"] == null ? null : NavigationEndpoint.fromMap(json["navigationEndpoint"]),
trackingParams: json["trackingParams"],
icon: json["icon"] == null ? null : Icon.fromMap(json["icon"]),
);
Map<String, dynamic> toMap() => {
"suggestion": suggestion?.toMap(),
"navigationEndpoint": navigationEndpoint?.toMap(),
"trackingParams": trackingParams,
"icon": icon?.toMap(),
};
}
class Icon {
String? iconType;
Icon({
this.iconType,
});
factory Icon.fromJson(String str) => Icon.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory Icon.fromMap(Map<String, dynamic> json) => Icon(
iconType: json["iconType"],
);
Map<String, dynamic> toMap() => {
"iconType": iconType,
};
}
class NavigationEndpoint {
String? clickTrackingParams;
SearchEndpoint? searchEndpoint;
NavigationEndpoint({
this.clickTrackingParams,
this.searchEndpoint,
});
factory NavigationEndpoint.fromJson(String str) => NavigationEndpoint.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory NavigationEndpoint.fromMap(Map<String, dynamic> json) => NavigationEndpoint(
clickTrackingParams: json["clickTrackingParams"],
searchEndpoint: json["searchEndpoint"] == null ? null : SearchEndpoint.fromMap(json["searchEndpoint"]),
);
Map<String, dynamic> toMap() => {
"clickTrackingParams": clickTrackingParams,
"searchEndpoint": searchEndpoint?.toMap(),
};
}
class SearchEndpoint {
String? query;
SearchEndpoint({
this.query,
});
factory SearchEndpoint.fromJson(String str) => SearchEndpoint.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory SearchEndpoint.fromMap(Map<String, dynamic> json) => SearchEndpoint(
query: json["query"],
);
Map<String, dynamic> toMap() => {
"query": query,
};
}
class Suggestion {
List<Run>? runs;
Suggestion({
this.runs,
});
factory Suggestion.fromJson(String str) => Suggestion.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory Suggestion.fromMap(Map<String, dynamic> json) => Suggestion(
runs: json["runs"] == null ? [] : List<Run>.from(json["runs"]!.map((x) => Run.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"runs": runs == null ? [] : List<dynamic>.from(runs!.map((x) => x.toMap())),
};
}
class Run {
String? text;
bool? bold;
Run({
this.text,
this.bold,
});
factory Run.fromJson(String str) => Run.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory Run.fromMap(Map<String, dynamic> json) => Run(
text: json["text"],
bold: json["bold"],
);
Map<String, dynamic> toMap() => {
"text": text,
"bold": bold,
};
}
class ResponseContext {
String? visitorData;
List<ServiceTrackingParam>? serviceTrackingParams;
ResponseContext({
this.visitorData,
this.serviceTrackingParams,
});
factory ResponseContext.fromJson(String str) => ResponseContext.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory ResponseContext.fromMap(Map<String, dynamic> json) => ResponseContext(
visitorData: json["visitorData"],
serviceTrackingParams: json["serviceTrackingParams"] == null ? [] : List<ServiceTrackingParam>.from(json["serviceTrackingParams"]!.map((x) => ServiceTrackingParam.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"visitorData": visitorData,
"serviceTrackingParams": serviceTrackingParams == null ? [] : List<dynamic>.from(serviceTrackingParams!.map((x) => x.toMap())),
};
}
class ServiceTrackingParam {
String? service;
List<Param>? params;
ServiceTrackingParam({
this.service,
this.params,
});
factory ServiceTrackingParam.fromJson(String str) => ServiceTrackingParam.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory ServiceTrackingParam.fromMap(Map<String, dynamic> json) => ServiceTrackingParam(
service: json["service"],
params: json["params"] == null ? [] : List<Param>.from(json["params"]!.map((x) => Param.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"service": service,
"params": params == null ? [] : List<dynamic>.from(params!.map((x) => x.toMap())),
};
}
class Param {
String? key;
String? value;
Param({
this.key,
this.value,
});
factory Param.fromJson(String str) => Param.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory Param.fromMap(Map<String, dynamic> json) => Param(
key: json["key"],
value: json["value"],
);
Map<String, dynamic> toMap() => {
"key": key,
"value": value,
};
}