diff --git a/analysis_options.yaml b/analysis_options.yaml index 9d860e8..bdb673a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,5 +1,6 @@ include: package:effective_dart/analysis_options.yaml + linter: rules: - valid_regexps @@ -60,3 +61,4 @@ linter: analyzer: exclude: - example\** + - src\**.g.gdart diff --git a/lib/src/reverse_engineering/responses/generated/player_response.g.dart b/lib/src/reverse_engineering/responses/generated/player_response.g.dart index 21f62aa..a69bf0a 100644 --- a/lib/src/reverse_engineering/responses/generated/player_response.g.dart +++ b/lib/src/reverse_engineering/responses/generated/player_response.g.dart @@ -46,42 +46,75 @@ class PlayerResponseJson { factory PlayerResponseJson.fromJson(Map json) => PlayerResponseJson( - responseContext: ResponseContext.fromJson(json["responseContext"]), - playabilityStatus: - PlayabilityStatus.fromJson(json["playabilityStatus"]), - streamingData: StreamingData.fromJson(json["streamingData"]), - playbackTracking: PlaybackTracking.fromJson(json["playbackTracking"]), - captions: Captions.fromJson(json["captions"]), - videoDetails: VideoDetails.fromJson(json["videoDetails"]), - annotations: List.from( - json["annotations"].map((x) => Annotation.fromJson(x))), - playerConfig: PlayerConfig.fromJson(json["playerConfig"]), - storyboards: Storyboards.fromJson(json["storyboards"]), - microformat: Microformat.fromJson(json["microformat"]), - cards: Cards.fromJson(json["cards"]), - trackingParams: json["trackingParams"], - attestation: Attestation.fromJson(json["attestation"]), - messages: List.from( - json["messages"].map((x) => Message.fromJson(x))), - endscreen: Endscreen.fromJson(json["endscreen"]), + responseContext: json["responseContext"] == null + ? null + : ResponseContext.fromJson(json["responseContext"]), + playabilityStatus: json["playabilityStatus"] == null + ? null + : PlayabilityStatus.fromJson(json["playabilityStatus"]), + streamingData: json["streamingData"] == null + ? null + : StreamingData.fromJson(json["streamingData"]), + playbackTracking: json["playbackTracking"] == null + ? null + : PlaybackTracking.fromJson(json["playbackTracking"]), + captions: json["captions"] == null + ? null + : Captions.fromJson(json["captions"]), + videoDetails: json["videoDetails"] == null + ? null + : VideoDetails.fromJson(json["videoDetails"]), + annotations: json["annotations"] == null + ? null + : List.from( + json["annotations"].map((x) => Annotation.fromJson(x))), + playerConfig: json["playerConfig"] == null + ? null + : PlayerConfig.fromJson(json["playerConfig"]), + storyboards: json["storyboards"] == null + ? null + : Storyboards.fromJson(json["storyboards"]), + microformat: json["microformat"] == null + ? null + : Microformat.fromJson(json["microformat"]), + cards: json["cards"] == null ? null : Cards.fromJson(json["cards"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + attestation: json["attestation"] == null + ? null + : Attestation.fromJson(json["attestation"]), + messages: json["messages"] == null + ? null + : List.from( + json["messages"].map((x) => Message.fromJson(x))), + endscreen: json["endscreen"] == null + ? null + : Endscreen.fromJson(json["endscreen"]), ); Map toJson() => { - "responseContext": responseContext.toJson(), - "playabilityStatus": playabilityStatus.toJson(), - "streamingData": streamingData.toJson(), - "playbackTracking": playbackTracking.toJson(), - "captions": captions.toJson(), - "videoDetails": videoDetails.toJson(), - "annotations": List.from(annotations.map((x) => x.toJson())), - "playerConfig": playerConfig.toJson(), - "storyboards": storyboards.toJson(), - "microformat": microformat.toJson(), - "cards": cards.toJson(), - "trackingParams": trackingParams, - "attestation": attestation.toJson(), - "messages": List.from(messages.map((x) => x.toJson())), - "endscreen": endscreen.toJson(), + "responseContext": + responseContext == null ? null : responseContext.toJson(), + "playabilityStatus": + playabilityStatus == null ? null : playabilityStatus.toJson(), + "streamingData": streamingData == null ? null : streamingData.toJson(), + "playbackTracking": + playbackTracking == null ? null : playbackTracking.toJson(), + "captions": captions == null ? null : captions.toJson(), + "videoDetails": videoDetails == null ? null : videoDetails.toJson(), + "annotations": annotations == null + ? null + : List.from(annotations.map((x) => x.toJson())), + "playerConfig": playerConfig == null ? null : playerConfig.toJson(), + "storyboards": storyboards == null ? null : storyboards.toJson(), + "microformat": microformat == null ? null : microformat.toJson(), + "cards": cards == null ? null : cards.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, + "attestation": attestation == null ? null : attestation.toJson(), + "messages": messages == null + ? null + : List.from(messages.map((x) => x.toJson())), + "endscreen": endscreen == null ? null : endscreen.toJson(), }; } @@ -99,13 +132,17 @@ class Annotation { factory Annotation.fromJson(Map json) => Annotation( playerAnnotationsExpandedRenderer: - PlayerAnnotationsExpandedRenderer.fromJson( - json["playerAnnotationsExpandedRenderer"]), + json["playerAnnotationsExpandedRenderer"] == null + ? null + : PlayerAnnotationsExpandedRenderer.fromJson( + json["playerAnnotationsExpandedRenderer"]), ); Map toJson() => { "playerAnnotationsExpandedRenderer": - playerAnnotationsExpandedRenderer.toJson(), + playerAnnotationsExpandedRenderer == null + ? null + : playerAnnotationsExpandedRenderer.toJson(), }; } @@ -128,15 +165,22 @@ class PlayerAnnotationsExpandedRenderer { factory PlayerAnnotationsExpandedRenderer.fromJson( Map json) => PlayerAnnotationsExpandedRenderer( - featuredChannel: FeaturedChannel.fromJson(json["featuredChannel"]), - allowSwipeDismiss: json["allowSwipeDismiss"], - annotationId: json["annotationId"], + featuredChannel: json["featuredChannel"] == null + ? null + : FeaturedChannel.fromJson(json["featuredChannel"]), + allowSwipeDismiss: json["allowSwipeDismiss"] == null + ? null + : json["allowSwipeDismiss"], + annotationId: + json["annotationId"] == null ? null : json["annotationId"], ); Map toJson() => { - "featuredChannel": featuredChannel.toJson(), - "allowSwipeDismiss": allowSwipeDismiss, - "annotationId": annotationId, + "featuredChannel": + featuredChannel == null ? null : featuredChannel.toJson(), + "allowSwipeDismiss": + allowSwipeDismiss == null ? null : allowSwipeDismiss, + "annotationId": annotationId == null ? null : annotationId, }; } @@ -166,23 +210,32 @@ class FeaturedChannel { factory FeaturedChannel.fromJson(Map json) => FeaturedChannel( - startTimeMs: json["startTimeMs"], - endTimeMs: json["endTimeMs"], - watermark: IconClass.fromJson(json["watermark"]), - trackingParams: json["trackingParams"], - navigationEndpoint: Endpoint.fromJson(json["navigationEndpoint"]), - channelName: json["channelName"], - subscribeButton: SubscribeButtonClass.fromJson(json["subscribeButton"]), + startTimeMs: json["startTimeMs"] == null ? null : json["startTimeMs"], + endTimeMs: json["endTimeMs"] == null ? null : json["endTimeMs"], + watermark: json["watermark"] == null + ? null + : IconClass.fromJson(json["watermark"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + navigationEndpoint: json["navigationEndpoint"] == null + ? null + : Endpoint.fromJson(json["navigationEndpoint"]), + channelName: json["channelName"] == null ? null : json["channelName"], + subscribeButton: json["subscribeButton"] == null + ? null + : SubscribeButtonClass.fromJson(json["subscribeButton"]), ); Map toJson() => { - "startTimeMs": startTimeMs, - "endTimeMs": endTimeMs, - "watermark": watermark.toJson(), - "trackingParams": trackingParams, - "navigationEndpoint": navigationEndpoint.toJson(), - "channelName": channelName, - "subscribeButton": subscribeButton.toJson(), + "startTimeMs": startTimeMs == null ? null : startTimeMs, + "endTimeMs": endTimeMs == null ? null : endTimeMs, + "watermark": watermark == null ? null : watermark.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, + "navigationEndpoint": + navigationEndpoint == null ? null : navigationEndpoint.toJson(), + "channelName": channelName == null ? null : channelName, + "subscribeButton": + subscribeButton == null ? null : subscribeButton.toJson(), }; } @@ -205,9 +258,13 @@ class Endpoint { String toRawJson() => json.encode(toJson()); factory Endpoint.fromJson(Map json) => Endpoint( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - NavigationEndpointCommandMetadata.fromJson(json["commandMetadata"]), + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + commandMetadata: json["commandMetadata"] == null + ? null + : NavigationEndpointCommandMetadata.fromJson( + json["commandMetadata"]), browseEndpoint: json["browseEndpoint"] == null ? null : BrowseEndpoint.fromJson(json["browseEndpoint"]), @@ -217,8 +274,10 @@ class Endpoint { ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "commandMetadata": + commandMetadata == null ? null : commandMetadata.toJson(), "browseEndpoint": browseEndpoint == null ? null : browseEndpoint.toJson(), "watchEndpoint": watchEndpoint == null ? null : watchEndpoint.toJson(), @@ -238,11 +297,11 @@ class BrowseEndpoint { String toRawJson() => json.encode(toJson()); factory BrowseEndpoint.fromJson(Map json) => BrowseEndpoint( - browseId: json["browseId"], + browseId: json["browseId"] == null ? null : json["browseId"], ); Map toJson() => { - "browseId": browseId, + "browseId": browseId == null ? null : browseId, }; } @@ -261,12 +320,14 @@ class NavigationEndpointCommandMetadata { factory NavigationEndpointCommandMetadata.fromJson( Map json) => NavigationEndpointCommandMetadata( - webCommandMetadata: - PurpleWebCommandMetadata.fromJson(json["webCommandMetadata"]), + webCommandMetadata: json["webCommandMetadata"] == null + ? null + : PurpleWebCommandMetadata.fromJson(json["webCommandMetadata"]), ); Map toJson() => { - "webCommandMetadata": webCommandMetadata.toJson(), + "webCommandMetadata": + webCommandMetadata == null ? null : webCommandMetadata.toJson(), }; } @@ -288,15 +349,18 @@ class PurpleWebCommandMetadata { factory PurpleWebCommandMetadata.fromJson(Map json) => PurpleWebCommandMetadata( - url: json["url"], - webPageType: webPageTypeValues.map[json["webPageType"]], - rootVe: json["rootVe"], + url: json["url"] == null ? null : json["url"], + webPageType: json["webPageType"] == null + ? null + : webPageTypeValues.map[json["webPageType"]], + rootVe: json["rootVe"] == null ? null : json["rootVe"], ); Map toJson() => { - "url": url, - "webPageType": webPageTypeValues.reverse[webPageType], - "rootVe": rootVe, + "url": url == null ? null : url, + "webPageType": + webPageType == null ? null : webPageTypeValues.reverse[webPageType], + "rootVe": rootVe == null ? null : rootVe, }; } @@ -328,12 +392,12 @@ class NavigationEndpointWatchEndpoint { factory NavigationEndpointWatchEndpoint.fromJson(Map json) => NavigationEndpointWatchEndpoint( - videoId: json["videoId"], + videoId: json["videoId"] == null ? null : json["videoId"], playlistId: json["playlistId"] == null ? null : json["playlistId"], ); Map toJson() => { - "videoId": videoId, + "videoId": videoId == null ? null : videoId, "playlistId": playlistId == null ? null : playlistId, }; } @@ -352,12 +416,15 @@ class SubscribeButtonClass { factory SubscribeButtonClass.fromJson(Map json) => SubscribeButtonClass( - subscribeButtonRenderer: - SubscribeButtonRenderer.fromJson(json["subscribeButtonRenderer"]), + subscribeButtonRenderer: json["subscribeButtonRenderer"] == null + ? null + : SubscribeButtonRenderer.fromJson(json["subscribeButtonRenderer"]), ); Map toJson() => { - "subscribeButtonRenderer": subscribeButtonRenderer.toJson(), + "subscribeButtonRenderer": subscribeButtonRenderer == null + ? null + : subscribeButtonRenderer.toJson(), }; } @@ -389,7 +456,7 @@ class SubscribeButtonRenderer { final MessageTitle unsubscribedButtonText; final String trackingParams; final MessageTitle unsubscribeButtonText; - final List serviceEndpoints; + final List serviceEndpoints; final SubscribeAccessibilityClass subscribeAccessibility; final SubscribeAccessibilityClass unsubscribeAccessibility; final SigninEndpoint signInEndpoint; @@ -401,45 +468,68 @@ class SubscribeButtonRenderer { factory SubscribeButtonRenderer.fromJson(Map json) => SubscribeButtonRenderer( - buttonText: MessageTitle.fromJson(json["buttonText"]), - subscribed: json["subscribed"], - enabled: json["enabled"], - type: json["type"], - channelId: json["channelId"], - showPreferences: json["showPreferences"], - subscribedButtonText: - MessageTitle.fromJson(json["subscribedButtonText"]), - unsubscribedButtonText: - MessageTitle.fromJson(json["unsubscribedButtonText"]), - trackingParams: json["trackingParams"], - unsubscribeButtonText: - MessageTitle.fromJson(json["unsubscribeButtonText"]), - serviceEndpoints: List.from( - json["serviceEndpoints"].map((x) => ServiceEndpoint.fromJson(x))), - subscribeAccessibility: SubscribeAccessibilityClass.fromJson( - json["subscribeAccessibility"]), - unsubscribeAccessibility: SubscribeAccessibilityClass.fromJson( - json["unsubscribeAccessibility"]), + buttonText: json["buttonText"] == null + ? null + : MessageTitle.fromJson(json["buttonText"]), + subscribed: json["subscribed"] == null ? null : json["subscribed"], + enabled: json["enabled"] == null ? null : json["enabled"], + type: json["type"] == null ? null : json["type"], + channelId: json["channelId"] == null ? null : json["channelId"], + showPreferences: + json["showPreferences"] == null ? null : json["showPreferences"], + subscribedButtonText: json["subscribedButtonText"] == null + ? null + : MessageTitle.fromJson(json["subscribedButtonText"]), + unsubscribedButtonText: json["unsubscribedButtonText"] == null + ? null + : MessageTitle.fromJson(json["unsubscribedButtonText"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + unsubscribeButtonText: json["unsubscribeButtonText"] == null + ? null + : MessageTitle.fromJson(json["unsubscribeButtonText"]), + serviceEndpoints: json["serviceEndpoints"] == null + ? null + : List.from(json["serviceEndpoints"] + .map((x) => SubscribeCommand.fromJson(x))), + subscribeAccessibility: json["subscribeAccessibility"] == null + ? null + : SubscribeAccessibilityClass.fromJson( + json["subscribeAccessibility"]), + unsubscribeAccessibility: json["unsubscribeAccessibility"] == null + ? null + : SubscribeAccessibilityClass.fromJson( + json["unsubscribeAccessibility"]), signInEndpoint: json["signInEndpoint"] == null ? null : SigninEndpoint.fromJson(json["signInEndpoint"]), ); Map toJson() => { - "buttonText": buttonText.toJson(), - "subscribed": subscribed, - "enabled": enabled, - "type": type, - "channelId": channelId, - "showPreferences": showPreferences, - "subscribedButtonText": subscribedButtonText.toJson(), - "unsubscribedButtonText": unsubscribedButtonText.toJson(), - "trackingParams": trackingParams, - "unsubscribeButtonText": unsubscribeButtonText.toJson(), - "serviceEndpoints": - List.from(serviceEndpoints.map((x) => x.toJson())), - "subscribeAccessibility": subscribeAccessibility.toJson(), - "unsubscribeAccessibility": unsubscribeAccessibility.toJson(), + "buttonText": buttonText == null ? null : buttonText.toJson(), + "subscribed": subscribed == null ? null : subscribed, + "enabled": enabled == null ? null : enabled, + "type": type == null ? null : type, + "channelId": channelId == null ? null : channelId, + "showPreferences": showPreferences == null ? null : showPreferences, + "subscribedButtonText": + subscribedButtonText == null ? null : subscribedButtonText.toJson(), + "unsubscribedButtonText": unsubscribedButtonText == null + ? null + : unsubscribedButtonText.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, + "unsubscribeButtonText": unsubscribeButtonText == null + ? null + : unsubscribeButtonText.toJson(), + "serviceEndpoints": serviceEndpoints == null + ? null + : List.from(serviceEndpoints.map((x) => x.toJson())), + "subscribeAccessibility": subscribeAccessibility == null + ? null + : subscribeAccessibility.toJson(), + "unsubscribeAccessibility": unsubscribeAccessibility == null + ? null + : unsubscribeAccessibility.toJson(), "signInEndpoint": signInEndpoint == null ? null : signInEndpoint.toJson(), }; @@ -458,11 +548,15 @@ class MessageTitle { String toRawJson() => json.encode(toJson()); factory MessageTitle.fromJson(Map json) => MessageTitle( - runs: List.from(json["runs"].map((x) => Run.fromJson(x))), + runs: json["runs"] == null + ? null + : List.from(json["runs"].map((x) => Run.fromJson(x))), ); Map toJson() => { - "runs": List.from(runs.map((x) => x.toJson())), + "runs": runs == null + ? null + : List.from(runs.map((x) => x.toJson())), }; } @@ -478,16 +572,16 @@ class Run { String toRawJson() => json.encode(toJson()); factory Run.fromJson(Map json) => Run( - text: json["text"], + text: json["text"] == null ? null : json["text"], ); Map toJson() => { - "text": text, + "text": text == null ? null : text, }; } -class ServiceEndpoint { - ServiceEndpoint({ +class SubscribeCommand { + SubscribeCommand({ this.clickTrackingParams, this.commandMetadata, this.subscribeEndpoint, @@ -495,20 +589,23 @@ class ServiceEndpoint { }); final String clickTrackingParams; - final ServiceEndpointCommandMetadata commandMetadata; + final SubscribeCommandCommandMetadata commandMetadata; final SubscribeEndpoint subscribeEndpoint; final SignalServiceEndpoint signalServiceEndpoint; - factory ServiceEndpoint.fromRawJson(String str) => - ServiceEndpoint.fromJson(json.decode(str)); + factory SubscribeCommand.fromRawJson(String str) => + SubscribeCommand.fromJson(json.decode(str)); String toRawJson() => json.encode(toJson()); - factory ServiceEndpoint.fromJson(Map json) => - ServiceEndpoint( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - ServiceEndpointCommandMetadata.fromJson(json["commandMetadata"]), + factory SubscribeCommand.fromJson(Map json) => + SubscribeCommand( + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + commandMetadata: json["commandMetadata"] == null + ? null + : SubscribeCommandCommandMetadata.fromJson(json["commandMetadata"]), subscribeEndpoint: json["subscribeEndpoint"] == null ? null : SubscribeEndpoint.fromJson(json["subscribeEndpoint"]), @@ -518,8 +615,10 @@ class ServiceEndpoint { ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "commandMetadata": + commandMetadata == null ? null : commandMetadata.toJson(), "subscribeEndpoint": subscribeEndpoint == null ? null : subscribeEndpoint.toJson(), "signalServiceEndpoint": signalServiceEndpoint == null @@ -528,26 +627,28 @@ class ServiceEndpoint { }; } -class ServiceEndpointCommandMetadata { - ServiceEndpointCommandMetadata({ +class SubscribeCommandCommandMetadata { + SubscribeCommandCommandMetadata({ this.webCommandMetadata, }); final FluffyWebCommandMetadata webCommandMetadata; - factory ServiceEndpointCommandMetadata.fromRawJson(String str) => - ServiceEndpointCommandMetadata.fromJson(json.decode(str)); + factory SubscribeCommandCommandMetadata.fromRawJson(String str) => + SubscribeCommandCommandMetadata.fromJson(json.decode(str)); String toRawJson() => json.encode(toJson()); - factory ServiceEndpointCommandMetadata.fromJson(Map json) => - ServiceEndpointCommandMetadata( - webCommandMetadata: - FluffyWebCommandMetadata.fromJson(json["webCommandMetadata"]), + factory SubscribeCommandCommandMetadata.fromJson(Map json) => + SubscribeCommandCommandMetadata( + webCommandMetadata: json["webCommandMetadata"] == null + ? null + : FluffyWebCommandMetadata.fromJson(json["webCommandMetadata"]), ); Map toJson() => { - "webCommandMetadata": webCommandMetadata.toJson(), + "webCommandMetadata": + webCommandMetadata == null ? null : webCommandMetadata.toJson(), }; } @@ -569,14 +670,14 @@ class FluffyWebCommandMetadata { factory FluffyWebCommandMetadata.fromJson(Map json) => FluffyWebCommandMetadata( - url: urlValues.map[json["url"]], - sendPost: json["sendPost"], + url: json["url"] == null ? null : urlValues.map[json["url"]], + sendPost: json["sendPost"] == null ? null : json["sendPost"], apiUrl: json["apiUrl"] == null ? null : json["apiUrl"], ); Map toJson() => { - "url": urlValues.reverse[url], - "sendPost": sendPost, + "url": url == null ? null : urlValues.reverse[url], + "sendPost": sendPost == null ? null : sendPost, "apiUrl": apiUrl == null ? null : apiUrl, }; } @@ -601,14 +702,18 @@ class SignalServiceEndpoint { factory SignalServiceEndpoint.fromJson(Map json) => SignalServiceEndpoint( - signal: json["signal"], - actions: List.from(json["actions"] - .map((x) => SignalServiceEndpointAction.fromJson(x))), + signal: json["signal"] == null ? null : json["signal"], + actions: json["actions"] == null + ? null + : List.from(json["actions"] + .map((x) => SignalServiceEndpointAction.fromJson(x))), ); Map toJson() => { - "signal": signal, - "actions": List.from(actions.map((x) => x.toJson())), + "signal": signal == null ? null : signal, + "actions": actions == null + ? null + : List.from(actions.map((x) => x.toJson())), }; } @@ -628,14 +733,19 @@ class SignalServiceEndpointAction { factory SignalServiceEndpointAction.fromJson(Map json) => SignalServiceEndpointAction( - clickTrackingParams: json["clickTrackingParams"], - openPopupAction: - ActionOpenPopupAction.fromJson(json["openPopupAction"]), + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + openPopupAction: json["openPopupAction"] == null + ? null + : ActionOpenPopupAction.fromJson(json["openPopupAction"]), ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "openPopupAction": openPopupAction.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "openPopupAction": + openPopupAction == null ? null : openPopupAction.toJson(), }; } @@ -655,13 +765,14 @@ class ActionOpenPopupAction { factory ActionOpenPopupAction.fromJson(Map json) => ActionOpenPopupAction( - popup: PurplePopup.fromJson(json["popup"]), - popupType: json["popupType"], + popup: + json["popup"] == null ? null : PurplePopup.fromJson(json["popup"]), + popupType: json["popupType"] == null ? null : json["popupType"], ); Map toJson() => { - "popup": popup.toJson(), - "popupType": popupType, + "popup": popup == null ? null : popup.toJson(), + "popupType": popupType == null ? null : popupType, }; } @@ -678,12 +789,15 @@ class PurplePopup { String toRawJson() => json.encode(toJson()); factory PurplePopup.fromJson(Map json) => PurplePopup( - confirmDialogRenderer: - ConfirmDialogRenderer.fromJson(json["confirmDialogRenderer"]), + confirmDialogRenderer: json["confirmDialogRenderer"] == null + ? null + : ConfirmDialogRenderer.fromJson(json["confirmDialogRenderer"]), ); Map toJson() => { - "confirmDialogRenderer": confirmDialogRenderer.toJson(), + "confirmDialogRenderer": confirmDialogRenderer == null + ? null + : confirmDialogRenderer.toJson(), }; } @@ -709,21 +823,30 @@ class ConfirmDialogRenderer { factory ConfirmDialogRenderer.fromJson(Map json) => ConfirmDialogRenderer( - trackingParams: json["trackingParams"], - dialogMessages: List.from( - json["dialogMessages"].map((x) => MessageTitle.fromJson(x))), - confirmButton: CancelButtonClass.fromJson(json["confirmButton"]), - cancelButton: CancelButtonClass.fromJson(json["cancelButton"]), - primaryIsCancel: json["primaryIsCancel"], + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + dialogMessages: json["dialogMessages"] == null + ? null + : List.from( + json["dialogMessages"].map((x) => MessageTitle.fromJson(x))), + confirmButton: json["confirmButton"] == null + ? null + : CancelButtonClass.fromJson(json["confirmButton"]), + cancelButton: json["cancelButton"] == null + ? null + : CancelButtonClass.fromJson(json["cancelButton"]), + primaryIsCancel: + json["primaryIsCancel"] == null ? null : json["primaryIsCancel"], ); Map toJson() => { - "trackingParams": trackingParams, - "dialogMessages": - List.from(dialogMessages.map((x) => x.toJson())), - "confirmButton": confirmButton.toJson(), - "cancelButton": cancelButton.toJson(), - "primaryIsCancel": primaryIsCancel, + "trackingParams": trackingParams == null ? null : trackingParams, + "dialogMessages": dialogMessages == null + ? null + : List.from(dialogMessages.map((x) => x.toJson())), + "confirmButton": confirmButton == null ? null : confirmButton.toJson(), + "cancelButton": cancelButton == null ? null : cancelButton.toJson(), + "primaryIsCancel": primaryIsCancel == null ? null : primaryIsCancel, }; } @@ -741,12 +864,14 @@ class CancelButtonClass { factory CancelButtonClass.fromJson(Map json) => CancelButtonClass( - buttonRenderer: - CancelButtonButtonRenderer.fromJson(json["buttonRenderer"]), + buttonRenderer: json["buttonRenderer"] == null + ? null + : CancelButtonButtonRenderer.fromJson(json["buttonRenderer"]), ); Map toJson() => { - "buttonRenderer": buttonRenderer.toJson(), + "buttonRenderer": + buttonRenderer == null ? null : buttonRenderer.toJson(), }; } @@ -776,24 +901,27 @@ class CancelButtonButtonRenderer { factory CancelButtonButtonRenderer.fromJson(Map json) => CancelButtonButtonRenderer( - style: json["style"], - size: json["size"], - isDisabled: json["isDisabled"], - text: MessageTitle.fromJson(json["text"]), - accessibility: AccessibilityDataClass.fromJson(json["accessibility"]), - trackingParams: json["trackingParams"], + style: json["style"] == null ? null : json["style"], + size: json["size"] == null ? null : json["size"], + isDisabled: json["isDisabled"] == null ? null : json["isDisabled"], + text: json["text"] == null ? null : MessageTitle.fromJson(json["text"]), + accessibility: json["accessibility"] == null + ? null + : AccessibilityDataClass.fromJson(json["accessibility"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], serviceEndpoint: json["serviceEndpoint"] == null ? null : UnsubscribeCommand.fromJson(json["serviceEndpoint"]), ); Map toJson() => { - "style": style, - "size": size, - "isDisabled": isDisabled, - "text": text.toJson(), - "accessibility": accessibility.toJson(), - "trackingParams": trackingParams, + "style": style == null ? null : style, + "size": size == null ? null : size, + "isDisabled": isDisabled == null ? null : isDisabled, + "text": text == null ? null : text.toJson(), + "accessibility": accessibility == null ? null : accessibility.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, "serviceEndpoint": serviceEndpoint == null ? null : serviceEndpoint.toJson(), }; @@ -813,11 +941,11 @@ class AccessibilityDataClass { factory AccessibilityDataClass.fromJson(Map json) => AccessibilityDataClass( - label: json["label"], + label: json["label"] == null ? null : json["label"], ); Map toJson() => { - "label": label, + "label": label == null ? null : label, }; } @@ -829,7 +957,7 @@ class UnsubscribeCommand { }); final String clickTrackingParams; - final ServiceEndpointCommandMetadata commandMetadata; + final SubscribeCommandCommandMetadata commandMetadata; final SubscribeEndpoint unsubscribeEndpoint; factory UnsubscribeCommand.fromRawJson(String str) => @@ -839,17 +967,24 @@ class UnsubscribeCommand { factory UnsubscribeCommand.fromJson(Map json) => UnsubscribeCommand( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - ServiceEndpointCommandMetadata.fromJson(json["commandMetadata"]), - unsubscribeEndpoint: - SubscribeEndpoint.fromJson(json["unsubscribeEndpoint"]), + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + commandMetadata: json["commandMetadata"] == null + ? null + : SubscribeCommandCommandMetadata.fromJson(json["commandMetadata"]), + unsubscribeEndpoint: json["unsubscribeEndpoint"] == null + ? null + : SubscribeEndpoint.fromJson(json["unsubscribeEndpoint"]), ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), - "unsubscribeEndpoint": unsubscribeEndpoint.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "commandMetadata": + commandMetadata == null ? null : commandMetadata.toJson(), + "unsubscribeEndpoint": + unsubscribeEndpoint == null ? null : unsubscribeEndpoint.toJson(), }; } @@ -869,13 +1004,17 @@ class SubscribeEndpoint { factory SubscribeEndpoint.fromJson(Map json) => SubscribeEndpoint( - channelIds: List.from(json["channelIds"].map((x) => x)), - params: json["params"], + channelIds: json["channelIds"] == null + ? null + : List.from(json["channelIds"].map((x) => x)), + params: json["params"] == null ? null : json["params"], ); Map toJson() => { - "channelIds": List.from(channelIds.map((x) => x)), - "params": params, + "channelIds": channelIds == null + ? null + : List.from(channelIds.map((x) => x)), + "params": params == null ? null : params, }; } @@ -892,11 +1031,14 @@ class SigninEndpoint { String toRawJson() => json.encode(toJson()); factory SigninEndpoint.fromJson(Map json) => SigninEndpoint( - clickTrackingParams: json["clickTrackingParams"], + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, }; } @@ -914,12 +1056,14 @@ class SubscribeAccessibilityClass { factory SubscribeAccessibilityClass.fromJson(Map json) => SubscribeAccessibilityClass( - accessibilityData: - AccessibilityDataClass.fromJson(json["accessibilityData"]), + accessibilityData: json["accessibilityData"] == null + ? null + : AccessibilityDataClass.fromJson(json["accessibilityData"]), ); Map toJson() => { - "accessibilityData": accessibilityData.toJson(), + "accessibilityData": + accessibilityData == null ? null : accessibilityData.toJson(), }; } @@ -936,12 +1080,16 @@ class IconClass { String toRawJson() => json.encode(toJson()); factory IconClass.fromJson(Map json) => IconClass( - thumbnails: List.from( - json["thumbnails"].map((x) => ThumbnailThumbnail.fromJson(x))), + thumbnails: json["thumbnails"] == null + ? null + : List.from( + json["thumbnails"].map((x) => ThumbnailThumbnail.fromJson(x))), ); Map toJson() => { - "thumbnails": List.from(thumbnails.map((x) => x.toJson())), + "thumbnails": thumbnails == null + ? null + : List.from(thumbnails.map((x) => x.toJson())), }; } @@ -963,15 +1111,15 @@ class ThumbnailThumbnail { factory ThumbnailThumbnail.fromJson(Map json) => ThumbnailThumbnail( - url: json["url"], - width: json["width"], - height: json["height"], + url: json["url"] == null ? null : json["url"], + width: json["width"] == null ? null : json["width"], + height: json["height"] == null ? null : json["height"], ); Map toJson() => { - "url": url, - "width": width, - "height": height, + "url": url == null ? null : url, + "width": width == null ? null : width, + "height": height == null ? null : height, }; } @@ -988,12 +1136,16 @@ class Attestation { String toRawJson() => json.encode(toJson()); factory Attestation.fromJson(Map json) => Attestation( - playerAttestationRenderer: PlayerAttestationRenderer.fromJson( - json["playerAttestationRenderer"]), + playerAttestationRenderer: json["playerAttestationRenderer"] == null + ? null + : PlayerAttestationRenderer.fromJson( + json["playerAttestationRenderer"]), ); Map toJson() => { - "playerAttestationRenderer": playerAttestationRenderer.toJson(), + "playerAttestationRenderer": playerAttestationRenderer == null + ? null + : playerAttestationRenderer.toJson(), }; } @@ -1013,13 +1165,15 @@ class PlayerAttestationRenderer { factory PlayerAttestationRenderer.fromJson(Map json) => PlayerAttestationRenderer( - challenge: json["challenge"], - botguardData: BotguardData.fromJson(json["botguardData"]), + challenge: json["challenge"] == null ? null : json["challenge"], + botguardData: json["botguardData"] == null + ? null + : BotguardData.fromJson(json["botguardData"]), ); Map toJson() => { - "challenge": challenge, - "botguardData": botguardData.toJson(), + "challenge": challenge == null ? null : challenge, + "botguardData": botguardData == null ? null : botguardData.toJson(), }; } @@ -1038,13 +1192,14 @@ class BotguardData { String toRawJson() => json.encode(toJson()); factory BotguardData.fromJson(Map json) => BotguardData( - program: json["program"], - interpreterUrl: json["interpreterUrl"], + program: json["program"] == null ? null : json["program"], + interpreterUrl: + json["interpreterUrl"] == null ? null : json["interpreterUrl"], ); Map toJson() => { - "program": program, - "interpreterUrl": interpreterUrl, + "program": program == null ? null : program, + "interpreterUrl": interpreterUrl == null ? null : interpreterUrl, }; } @@ -1063,17 +1218,24 @@ class Captions { String toRawJson() => json.encode(toJson()); factory Captions.fromJson(Map json) => Captions( - playerCaptionsRenderer: - PlayerCaptionsRenderer.fromJson(json["playerCaptionsRenderer"]), + playerCaptionsRenderer: json["playerCaptionsRenderer"] == null + ? null + : PlayerCaptionsRenderer.fromJson(json["playerCaptionsRenderer"]), playerCaptionsTracklistRenderer: - PlayerCaptionsTracklistRenderer.fromJson( - json["playerCaptionsTracklistRenderer"]), + json["playerCaptionsTracklistRenderer"] == null + ? null + : PlayerCaptionsTracklistRenderer.fromJson( + json["playerCaptionsTracklistRenderer"]), ); Map toJson() => { - "playerCaptionsRenderer": playerCaptionsRenderer.toJson(), + "playerCaptionsRenderer": playerCaptionsRenderer == null + ? null + : playerCaptionsRenderer.toJson(), "playerCaptionsTracklistRenderer": - playerCaptionsTracklistRenderer.toJson(), + playerCaptionsTracklistRenderer == null + ? null + : playerCaptionsTracklistRenderer.toJson(), }; } @@ -1093,13 +1255,13 @@ class PlayerCaptionsRenderer { factory PlayerCaptionsRenderer.fromJson(Map json) => PlayerCaptionsRenderer( - baseUrl: json["baseUrl"], - visibility: json["visibility"], + baseUrl: json["baseUrl"] == null ? null : json["baseUrl"], + visibility: json["visibility"] == null ? null : json["visibility"], ); Map toJson() => { - "baseUrl": baseUrl, - "visibility": visibility, + "baseUrl": baseUrl == null ? null : baseUrl, + "visibility": visibility == null ? null : visibility, }; } @@ -1123,23 +1285,35 @@ class PlayerCaptionsTracklistRenderer { factory PlayerCaptionsTracklistRenderer.fromJson(Map json) => PlayerCaptionsTracklistRenderer( - captionTracks: List.from( - json["captionTracks"].map((x) => CaptionTrack.fromJson(x))), - audioTracks: List.from( - json["audioTracks"].map((x) => AudioTrack.fromJson(x))), - translationLanguages: List.from( - json["translationLanguages"] + captionTracks: json["captionTracks"] == null + ? null + : List.from( + json["captionTracks"].map((x) => CaptionTrack.fromJson(x))), + audioTracks: json["audioTracks"] == null + ? null + : List.from( + json["audioTracks"].map((x) => AudioTrack.fromJson(x))), + translationLanguages: json["translationLanguages"] == null + ? null + : List.from(json["translationLanguages"] .map((x) => TranslationLanguage.fromJson(x))), - defaultAudioTrackIndex: json["defaultAudioTrackIndex"], + defaultAudioTrackIndex: json["defaultAudioTrackIndex"] == null + ? null + : json["defaultAudioTrackIndex"], ); Map toJson() => { - "captionTracks": - List.from(captionTracks.map((x) => x.toJson())), - "audioTracks": List.from(audioTracks.map((x) => x.toJson())), - "translationLanguages": - List.from(translationLanguages.map((x) => x.toJson())), - "defaultAudioTrackIndex": defaultAudioTrackIndex, + "captionTracks": captionTracks == null + ? null + : List.from(captionTracks.map((x) => x.toJson())), + "audioTracks": audioTracks == null + ? null + : List.from(audioTracks.map((x) => x.toJson())), + "translationLanguages": translationLanguages == null + ? null + : List.from(translationLanguages.map((x) => x.toJson())), + "defaultAudioTrackIndex": + defaultAudioTrackIndex == null ? null : defaultAudioTrackIndex, }; } @@ -1162,19 +1336,25 @@ class AudioTrack { String toRawJson() => json.encode(toJson()); factory AudioTrack.fromJson(Map json) => AudioTrack( - captionTrackIndices: - List.from(json["captionTrackIndices"].map((x) => x)), - defaultCaptionTrackIndex: json["defaultCaptionTrackIndex"], - visibility: json["visibility"], - hasDefaultTrack: json["hasDefaultTrack"], + captionTrackIndices: json["captionTrackIndices"] == null + ? null + : List.from(json["captionTrackIndices"].map((x) => x)), + defaultCaptionTrackIndex: json["defaultCaptionTrackIndex"] == null + ? null + : json["defaultCaptionTrackIndex"], + visibility: json["visibility"] == null ? null : json["visibility"], + hasDefaultTrack: + json["hasDefaultTrack"] == null ? null : json["hasDefaultTrack"], ); Map toJson() => { - "captionTrackIndices": - List.from(captionTrackIndices.map((x) => x)), - "defaultCaptionTrackIndex": defaultCaptionTrackIndex, - "visibility": visibility, - "hasDefaultTrack": hasDefaultTrack, + "captionTrackIndices": captionTrackIndices == null + ? null + : List.from(captionTrackIndices.map((x) => x)), + "defaultCaptionTrackIndex": + defaultCaptionTrackIndex == null ? null : defaultCaptionTrackIndex, + "visibility": visibility == null ? null : visibility, + "hasDefaultTrack": hasDefaultTrack == null ? null : hasDefaultTrack, }; } @@ -1199,19 +1379,21 @@ class CaptionTrack { String toRawJson() => json.encode(toJson()); factory CaptionTrack.fromJson(Map json) => CaptionTrack( - baseUrl: json["baseUrl"], - name: HeaderText.fromJson(json["name"]), - vssId: json["vssId"], - languageCode: json["languageCode"], - isTranslatable: json["isTranslatable"], + baseUrl: json["baseUrl"] == null ? null : json["baseUrl"], + name: json["name"] == null ? null : HeaderText.fromJson(json["name"]), + vssId: json["vssId"] == null ? null : json["vssId"], + languageCode: + json["languageCode"] == null ? null : json["languageCode"], + isTranslatable: + json["isTranslatable"] == null ? null : json["isTranslatable"], ); Map toJson() => { - "baseUrl": baseUrl, - "name": name.toJson(), - "vssId": vssId, - "languageCode": languageCode, - "isTranslatable": isTranslatable, + "baseUrl": baseUrl == null ? null : baseUrl, + "name": name == null ? null : name.toJson(), + "vssId": vssId == null ? null : vssId, + "languageCode": languageCode == null ? null : languageCode, + "isTranslatable": isTranslatable == null ? null : isTranslatable, }; } @@ -1228,11 +1410,11 @@ class HeaderText { String toRawJson() => json.encode(toJson()); factory HeaderText.fromJson(Map json) => HeaderText( - simpleText: json["simpleText"], + simpleText: json["simpleText"] == null ? null : json["simpleText"], ); Map toJson() => { - "simpleText": simpleText, + "simpleText": simpleText == null ? null : simpleText, }; } @@ -1252,13 +1434,16 @@ class TranslationLanguage { factory TranslationLanguage.fromJson(Map json) => TranslationLanguage( - languageCode: json["languageCode"], - languageName: HeaderText.fromJson(json["languageName"]), + languageCode: + json["languageCode"] == null ? null : json["languageCode"], + languageName: json["languageName"] == null + ? null + : HeaderText.fromJson(json["languageName"]), ); Map toJson() => { - "languageCode": languageCode, - "languageName": languageName.toJson(), + "languageCode": languageCode == null ? null : languageCode, + "languageName": languageName == null ? null : languageName.toJson(), }; } @@ -1274,12 +1459,15 @@ class Cards { String toRawJson() => json.encode(toJson()); factory Cards.fromJson(Map json) => Cards( - cardCollectionRenderer: - CardCollectionRenderer.fromJson(json["cardCollectionRenderer"]), + cardCollectionRenderer: json["cardCollectionRenderer"] == null + ? null + : CardCollectionRenderer.fromJson(json["cardCollectionRenderer"]), ); Map toJson() => { - "cardCollectionRenderer": cardCollectionRenderer.toJson(), + "cardCollectionRenderer": cardCollectionRenderer == null + ? null + : cardCollectionRenderer.toJson(), }; } @@ -1309,23 +1497,38 @@ class CardCollectionRenderer { factory CardCollectionRenderer.fromJson(Map json) => CardCollectionRenderer( - cards: List.from(json["cards"].map((x) => Card.fromJson(x))), - headerText: HeaderText.fromJson(json["headerText"]), - icon: CloseButton.fromJson(json["icon"]), - closeButton: CloseButton.fromJson(json["closeButton"]), - trackingParams: json["trackingParams"], - allowTeaserDismiss: json["allowTeaserDismiss"], - logIconVisibilityUpdates: json["logIconVisibilityUpdates"], + cards: json["cards"] == null + ? null + : List.from(json["cards"].map((x) => Card.fromJson(x))), + headerText: json["headerText"] == null + ? null + : HeaderText.fromJson(json["headerText"]), + icon: json["icon"] == null ? null : CloseButton.fromJson(json["icon"]), + closeButton: json["closeButton"] == null + ? null + : CloseButton.fromJson(json["closeButton"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + allowTeaserDismiss: json["allowTeaserDismiss"] == null + ? null + : json["allowTeaserDismiss"], + logIconVisibilityUpdates: json["logIconVisibilityUpdates"] == null + ? null + : json["logIconVisibilityUpdates"], ); Map toJson() => { - "cards": List.from(cards.map((x) => x.toJson())), - "headerText": headerText.toJson(), - "icon": icon.toJson(), - "closeButton": closeButton.toJson(), - "trackingParams": trackingParams, - "allowTeaserDismiss": allowTeaserDismiss, - "logIconVisibilityUpdates": logIconVisibilityUpdates, + "cards": cards == null + ? null + : List.from(cards.map((x) => x.toJson())), + "headerText": headerText == null ? null : headerText.toJson(), + "icon": icon == null ? null : icon.toJson(), + "closeButton": closeButton == null ? null : closeButton.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, + "allowTeaserDismiss": + allowTeaserDismiss == null ? null : allowTeaserDismiss, + "logIconVisibilityUpdates": + logIconVisibilityUpdates == null ? null : logIconVisibilityUpdates, }; } @@ -1341,11 +1544,13 @@ class Card { String toRawJson() => json.encode(toJson()); factory Card.fromJson(Map json) => Card( - cardRenderer: CardRenderer.fromJson(json["cardRenderer"]), + cardRenderer: json["cardRenderer"] == null + ? null + : CardRenderer.fromJson(json["cardRenderer"]), ); Map toJson() => { - "cardRenderer": cardRenderer.toJson(), + "cardRenderer": cardRenderer == null ? null : cardRenderer.toJson(), }; } @@ -1374,24 +1579,30 @@ class CardRenderer { String toRawJson() => json.encode(toJson()); factory CardRenderer.fromJson(Map json) => CardRenderer( - teaser: Teaser.fromJson(json["teaser"]), - content: Content.fromJson(json["content"]), - cueRanges: List.from( - json["cueRanges"].map((x) => CueRange.fromJson(x))), - icon: CloseButton.fromJson(json["icon"]), - trackingParams: json["trackingParams"], - cardId: json["cardId"], - feature: json["feature"], + teaser: json["teaser"] == null ? null : Teaser.fromJson(json["teaser"]), + content: + json["content"] == null ? null : Content.fromJson(json["content"]), + cueRanges: json["cueRanges"] == null + ? null + : List.from( + json["cueRanges"].map((x) => CueRange.fromJson(x))), + icon: json["icon"] == null ? null : CloseButton.fromJson(json["icon"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + cardId: json["cardId"] == null ? null : json["cardId"], + feature: json["feature"] == null ? null : json["feature"], ); Map toJson() => { - "teaser": teaser.toJson(), - "content": content.toJson(), - "cueRanges": List.from(cueRanges.map((x) => x.toJson())), - "icon": icon.toJson(), - "trackingParams": trackingParams, - "cardId": cardId, - "feature": feature, + "teaser": teaser == null ? null : teaser.toJson(), + "content": content == null ? null : content.toJson(), + "cueRanges": cueRanges == null + ? null + : List.from(cueRanges.map((x) => x.toJson())), + "icon": icon == null ? null : icon.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, + "cardId": cardId == null ? null : cardId, + "feature": feature == null ? null : feature, }; } @@ -1458,26 +1669,37 @@ class SimpleCardContentRenderer { factory SimpleCardContentRenderer.fromJson(Map json) => SimpleCardContentRenderer( - image: IconClass.fromJson(json["image"]), - title: HeaderText.fromJson(json["title"]), - actionButton: SimpleCardContentRendererActionButton.fromJson( - json["actionButton"]), - trackingParams: json["trackingParams"], - displayDomain: HeaderText.fromJson(json["displayDomain"]), - showLinkIcon: json["showLinkIcon"], - callToAction: HeaderText.fromJson(json["callToAction"]), - command: NavigationEndpoint.fromJson(json["command"]), + image: json["image"] == null ? null : IconClass.fromJson(json["image"]), + title: + json["title"] == null ? null : HeaderText.fromJson(json["title"]), + actionButton: json["actionButton"] == null + ? null + : SimpleCardContentRendererActionButton.fromJson( + json["actionButton"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + displayDomain: json["displayDomain"] == null + ? null + : HeaderText.fromJson(json["displayDomain"]), + showLinkIcon: + json["showLinkIcon"] == null ? null : json["showLinkIcon"], + callToAction: json["callToAction"] == null + ? null + : HeaderText.fromJson(json["callToAction"]), + command: json["command"] == null + ? null + : NavigationEndpoint.fromJson(json["command"]), ); Map toJson() => { - "image": image.toJson(), - "title": title.toJson(), - "actionButton": actionButton.toJson(), - "trackingParams": trackingParams, - "displayDomain": displayDomain.toJson(), - "showLinkIcon": showLinkIcon, - "callToAction": callToAction.toJson(), - "command": command.toJson(), + "image": image == null ? null : image.toJson(), + "title": title == null ? null : title.toJson(), + "actionButton": actionButton == null ? null : actionButton.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, + "displayDomain": displayDomain == null ? null : displayDomain.toJson(), + "showLinkIcon": showLinkIcon == null ? null : showLinkIcon, + "callToAction": callToAction == null ? null : callToAction.toJson(), + "command": command == null ? null : command.toJson(), }; } @@ -1496,12 +1718,16 @@ class SimpleCardContentRendererActionButton { factory SimpleCardContentRendererActionButton.fromJson( Map json) => SimpleCardContentRendererActionButton( - simpleCardButtonRenderer: - SimpleCardButtonRenderer.fromJson(json["simpleCardButtonRenderer"]), + simpleCardButtonRenderer: json["simpleCardButtonRenderer"] == null + ? null + : SimpleCardButtonRenderer.fromJson( + json["simpleCardButtonRenderer"]), ); Map toJson() => { - "simpleCardButtonRenderer": simpleCardButtonRenderer.toJson(), + "simpleCardButtonRenderer": simpleCardButtonRenderer == null + ? null + : simpleCardButtonRenderer.toJson(), }; } @@ -1523,15 +1749,18 @@ class SimpleCardButtonRenderer { factory SimpleCardButtonRenderer.fromJson(Map json) => SimpleCardButtonRenderer( - text: HeaderText.fromJson(json["text"]), - action: NavigationEndpoint.fromJson(json["action"]), - trackingParams: json["trackingParams"], + text: json["text"] == null ? null : HeaderText.fromJson(json["text"]), + action: json["action"] == null + ? null + : NavigationEndpoint.fromJson(json["action"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], ); Map toJson() => { - "text": text.toJson(), - "action": action.toJson(), - "trackingParams": trackingParams, + "text": text == null ? null : text.toJson(), + "action": action == null ? null : action.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, }; } @@ -1553,16 +1782,24 @@ class NavigationEndpoint { factory NavigationEndpoint.fromJson(Map json) => NavigationEndpoint( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - NavigationEndpointCommandMetadata.fromJson(json["commandMetadata"]), - urlEndpoint: UrlEndpoint.fromJson(json["urlEndpoint"]), + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + commandMetadata: json["commandMetadata"] == null + ? null + : NavigationEndpointCommandMetadata.fromJson( + json["commandMetadata"]), + urlEndpoint: json["urlEndpoint"] == null + ? null + : UrlEndpoint.fromJson(json["urlEndpoint"]), ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), - "urlEndpoint": urlEndpoint.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "commandMetadata": + commandMetadata == null ? null : commandMetadata.toJson(), + "urlEndpoint": urlEndpoint == null ? null : urlEndpoint.toJson(), }; } @@ -1581,13 +1818,13 @@ class UrlEndpoint { String toRawJson() => json.encode(toJson()); factory UrlEndpoint.fromJson(Map json) => UrlEndpoint( - url: json["url"], - target: json["target"], + url: json["url"] == null ? null : json["url"], + target: json["target"] == null ? null : json["target"], ); Map toJson() => { - "url": url, - "target": target, + "url": url == null ? null : url, + "target": target == null ? null : target, }; } @@ -1617,23 +1854,37 @@ class VideoInfoCardContentRenderer { factory VideoInfoCardContentRenderer.fromJson(Map json) => VideoInfoCardContentRenderer( - videoThumbnail: IconClass.fromJson(json["videoThumbnail"]), - lengthString: Title.fromJson(json["lengthString"]), - videoTitle: HeaderText.fromJson(json["videoTitle"]), - channelName: HeaderText.fromJson(json["channelName"]), - viewCountText: HeaderText.fromJson(json["viewCountText"]), - action: VideoInfoCardContentRendererAction.fromJson(json["action"]), - trackingParams: json["trackingParams"], + videoThumbnail: json["videoThumbnail"] == null + ? null + : IconClass.fromJson(json["videoThumbnail"]), + lengthString: json["lengthString"] == null + ? null + : Title.fromJson(json["lengthString"]), + videoTitle: json["videoTitle"] == null + ? null + : HeaderText.fromJson(json["videoTitle"]), + channelName: json["channelName"] == null + ? null + : HeaderText.fromJson(json["channelName"]), + viewCountText: json["viewCountText"] == null + ? null + : HeaderText.fromJson(json["viewCountText"]), + action: json["action"] == null + ? null + : VideoInfoCardContentRendererAction.fromJson(json["action"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], ); Map toJson() => { - "videoThumbnail": videoThumbnail.toJson(), - "lengthString": lengthString.toJson(), - "videoTitle": videoTitle.toJson(), - "channelName": channelName.toJson(), - "viewCountText": viewCountText.toJson(), - "action": action.toJson(), - "trackingParams": trackingParams, + "videoThumbnail": + videoThumbnail == null ? null : videoThumbnail.toJson(), + "lengthString": lengthString == null ? null : lengthString.toJson(), + "videoTitle": videoTitle == null ? null : videoTitle.toJson(), + "channelName": channelName == null ? null : channelName.toJson(), + "viewCountText": viewCountText == null ? null : viewCountText.toJson(), + "action": action == null ? null : action.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, }; } @@ -1656,16 +1907,24 @@ class VideoInfoCardContentRendererAction { factory VideoInfoCardContentRendererAction.fromJson( Map json) => VideoInfoCardContentRendererAction( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - NavigationEndpointCommandMetadata.fromJson(json["commandMetadata"]), - watchEndpoint: ActionWatchEndpoint.fromJson(json["watchEndpoint"]), + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + commandMetadata: json["commandMetadata"] == null + ? null + : NavigationEndpointCommandMetadata.fromJson( + json["commandMetadata"]), + watchEndpoint: json["watchEndpoint"] == null + ? null + : ActionWatchEndpoint.fromJson(json["watchEndpoint"]), ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), - "watchEndpoint": watchEndpoint.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "commandMetadata": + commandMetadata == null ? null : commandMetadata.toJson(), + "watchEndpoint": watchEndpoint == null ? null : watchEndpoint.toJson(), }; } @@ -1683,11 +1942,11 @@ class ActionWatchEndpoint { factory ActionWatchEndpoint.fromJson(Map json) => ActionWatchEndpoint( - videoId: json["videoId"], + videoId: json["videoId"] == null ? null : json["videoId"], ); Map toJson() => { - "videoId": videoId, + "videoId": videoId == null ? null : videoId, }; } @@ -1705,14 +1964,15 @@ class Title { String toRawJson() => json.encode(toJson()); factory Title.fromJson(Map json) => Title( - accessibility: - SubscribeAccessibilityClass.fromJson(json["accessibility"]), - simpleText: json["simpleText"], + accessibility: json["accessibility"] == null + ? null + : SubscribeAccessibilityClass.fromJson(json["accessibility"]), + simpleText: json["simpleText"] == null ? null : json["simpleText"], ); Map toJson() => { - "accessibility": accessibility.toJson(), - "simpleText": simpleText, + "accessibility": accessibility == null ? null : accessibility.toJson(), + "simpleText": simpleText == null ? null : simpleText, }; } @@ -1735,17 +1995,25 @@ class CueRange { String toRawJson() => json.encode(toJson()); factory CueRange.fromJson(Map json) => CueRange( - startCardActiveMs: json["startCardActiveMs"], - endCardActiveMs: json["endCardActiveMs"], - teaserDurationMs: json["teaserDurationMs"], - iconAfterTeaserMs: json["iconAfterTeaserMs"], + startCardActiveMs: json["startCardActiveMs"] == null + ? null + : json["startCardActiveMs"], + endCardActiveMs: + json["endCardActiveMs"] == null ? null : json["endCardActiveMs"], + teaserDurationMs: + json["teaserDurationMs"] == null ? null : json["teaserDurationMs"], + iconAfterTeaserMs: json["iconAfterTeaserMs"] == null + ? null + : json["iconAfterTeaserMs"], ); Map toJson() => { - "startCardActiveMs": startCardActiveMs, - "endCardActiveMs": endCardActiveMs, - "teaserDurationMs": teaserDurationMs, - "iconAfterTeaserMs": iconAfterTeaserMs, + "startCardActiveMs": + startCardActiveMs == null ? null : startCardActiveMs, + "endCardActiveMs": endCardActiveMs == null ? null : endCardActiveMs, + "teaserDurationMs": teaserDurationMs == null ? null : teaserDurationMs, + "iconAfterTeaserMs": + iconAfterTeaserMs == null ? null : iconAfterTeaserMs, }; } @@ -1762,12 +2030,14 @@ class CloseButton { String toRawJson() => json.encode(toJson()); factory CloseButton.fromJson(Map json) => CloseButton( - infoCardIconRenderer: - InfoCardIconRenderer.fromJson(json["infoCardIconRenderer"]), + infoCardIconRenderer: json["infoCardIconRenderer"] == null + ? null + : InfoCardIconRenderer.fromJson(json["infoCardIconRenderer"]), ); Map toJson() => { - "infoCardIconRenderer": infoCardIconRenderer.toJson(), + "infoCardIconRenderer": + infoCardIconRenderer == null ? null : infoCardIconRenderer.toJson(), }; } @@ -1785,11 +2055,12 @@ class InfoCardIconRenderer { factory InfoCardIconRenderer.fromJson(Map json) => InfoCardIconRenderer( - trackingParams: json["trackingParams"], + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], ); Map toJson() => { - "trackingParams": trackingParams, + "trackingParams": trackingParams == null ? null : trackingParams, }; } @@ -1805,12 +2076,16 @@ class Teaser { String toRawJson() => json.encode(toJson()); factory Teaser.fromJson(Map json) => Teaser( - simpleCardTeaserRenderer: - SimpleCardTeaserRenderer.fromJson(json["simpleCardTeaserRenderer"]), + simpleCardTeaserRenderer: json["simpleCardTeaserRenderer"] == null + ? null + : SimpleCardTeaserRenderer.fromJson( + json["simpleCardTeaserRenderer"]), ); Map toJson() => { - "simpleCardTeaserRenderer": simpleCardTeaserRenderer.toJson(), + "simpleCardTeaserRenderer": simpleCardTeaserRenderer == null + ? null + : simpleCardTeaserRenderer.toJson(), }; } @@ -1834,17 +2109,23 @@ class SimpleCardTeaserRenderer { factory SimpleCardTeaserRenderer.fromJson(Map json) => SimpleCardTeaserRenderer( - message: HeaderText.fromJson(json["message"]), - trackingParams: json["trackingParams"], - prominent: json["prominent"], - logVisibilityUpdates: json["logVisibilityUpdates"], + message: json["message"] == null + ? null + : HeaderText.fromJson(json["message"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + prominent: json["prominent"] == null ? null : json["prominent"], + logVisibilityUpdates: json["logVisibilityUpdates"] == null + ? null + : json["logVisibilityUpdates"], ); Map toJson() => { - "message": message.toJson(), - "trackingParams": trackingParams, - "prominent": prominent, - "logVisibilityUpdates": logVisibilityUpdates, + "message": message == null ? null : message.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, + "prominent": prominent == null ? null : prominent, + "logVisibilityUpdates": + logVisibilityUpdates == null ? null : logVisibilityUpdates, }; } @@ -1861,12 +2142,14 @@ class Endscreen { String toRawJson() => json.encode(toJson()); factory Endscreen.fromJson(Map json) => Endscreen( - endscreenRenderer: - EndscreenRenderer.fromJson(json["endscreenRenderer"]), + endscreenRenderer: json["endscreenRenderer"] == null + ? null + : EndscreenRenderer.fromJson(json["endscreenRenderer"]), ); Map toJson() => { - "endscreenRenderer": endscreenRenderer.toJson(), + "endscreenRenderer": + endscreenRenderer == null ? null : endscreenRenderer.toJson(), }; } @@ -1888,16 +2171,21 @@ class EndscreenRenderer { factory EndscreenRenderer.fromJson(Map json) => EndscreenRenderer( - elements: List.from( - json["elements"].map((x) => Element.fromJson(x))), - startMs: json["startMs"], - trackingParams: json["trackingParams"], + elements: json["elements"] == null + ? null + : List.from( + json["elements"].map((x) => Element.fromJson(x))), + startMs: json["startMs"] == null ? null : json["startMs"], + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], ); Map toJson() => { - "elements": List.from(elements.map((x) => x.toJson())), - "startMs": startMs, - "trackingParams": trackingParams, + "elements": elements == null + ? null + : List.from(elements.map((x) => x.toJson())), + "startMs": startMs == null ? null : startMs, + "trackingParams": trackingParams == null ? null : trackingParams, }; } @@ -1913,12 +2201,16 @@ class Element { String toRawJson() => json.encode(toJson()); factory Element.fromJson(Map json) => Element( - endscreenElementRenderer: - EndscreenElementRenderer.fromJson(json["endscreenElementRenderer"]), + endscreenElementRenderer: json["endscreenElementRenderer"] == null + ? null + : EndscreenElementRenderer.fromJson( + json["endscreenElementRenderer"]), ); Map toJson() => { - "endscreenElementRenderer": endscreenElementRenderer.toJson(), + "endscreenElementRenderer": endscreenElementRenderer == null + ? null + : endscreenElementRenderer.toJson(), }; } @@ -1976,33 +2268,39 @@ class EndscreenElementRenderer { factory EndscreenElementRenderer.fromJson(Map json) => EndscreenElementRenderer( - style: json["style"], - image: IconClass.fromJson(json["image"]), + style: json["style"] == null ? null : json["style"], + image: json["image"] == null ? null : IconClass.fromJson(json["image"]), icon: json["icon"] == null ? null : Icon.fromJson(json["icon"]), - left: json["left"].toDouble(), - width: json["width"].toDouble(), - top: json["top"].toDouble(), - aspectRatio: json["aspectRatio"].toDouble(), - startMs: json["startMs"], - endMs: json["endMs"], - title: Title.fromJson(json["title"]), - metadata: HeaderText.fromJson(json["metadata"]), + left: json["left"] == null ? null : json["left"].toDouble(), + width: json["width"] == null ? null : json["width"].toDouble(), + top: json["top"] == null ? null : json["top"].toDouble(), + aspectRatio: + json["aspectRatio"] == null ? null : json["aspectRatio"].toDouble(), + startMs: json["startMs"] == null ? null : json["startMs"], + endMs: json["endMs"] == null ? null : json["endMs"], + title: json["title"] == null ? null : Title.fromJson(json["title"]), + metadata: json["metadata"] == null + ? null + : HeaderText.fromJson(json["metadata"]), callToAction: json["callToAction"] == null ? null : HeaderText.fromJson(json["callToAction"]), dismiss: json["dismiss"] == null ? null : HeaderText.fromJson(json["dismiss"]), - endpoint: Endpoint.fromJson(json["endpoint"]), + endpoint: json["endpoint"] == null + ? null + : Endpoint.fromJson(json["endpoint"]), hovercardButton: json["hovercardButton"] == null ? null : SubscribeButtonClass.fromJson(json["hovercardButton"]), - trackingParams: json["trackingParams"], + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], isSubscribe: json["isSubscribe"] == null ? null : json["isSubscribe"], signinEndpoint: json["signinEndpoint"] == null ? null : SigninEndpoint.fromJson(json["signinEndpoint"]), - id: json["id"], + id: json["id"] == null ? null : json["id"], playlistLength: json["playlistLength"] == null ? null : HeaderText.fromJson(json["playlistLength"]), @@ -2012,27 +2310,27 @@ class EndscreenElementRenderer { ); Map toJson() => { - "style": style, - "image": image.toJson(), + "style": style == null ? null : style, + "image": image == null ? null : image.toJson(), "icon": icon == null ? null : icon.toJson(), - "left": left, - "width": width, - "top": top, - "aspectRatio": aspectRatio, - "startMs": startMs, - "endMs": endMs, - "title": title.toJson(), - "metadata": metadata.toJson(), + "left": left == null ? null : left, + "width": width == null ? null : width, + "top": top == null ? null : top, + "aspectRatio": aspectRatio == null ? null : aspectRatio, + "startMs": startMs == null ? null : startMs, + "endMs": endMs == null ? null : endMs, + "title": title == null ? null : title.toJson(), + "metadata": metadata == null ? null : metadata.toJson(), "callToAction": callToAction == null ? null : callToAction.toJson(), "dismiss": dismiss == null ? null : dismiss.toJson(), - "endpoint": endpoint.toJson(), + "endpoint": endpoint == null ? null : endpoint.toJson(), "hovercardButton": hovercardButton == null ? null : hovercardButton.toJson(), - "trackingParams": trackingParams, + "trackingParams": trackingParams == null ? null : trackingParams, "isSubscribe": isSubscribe == null ? null : isSubscribe, "signinEndpoint": signinEndpoint == null ? null : signinEndpoint.toJson(), - "id": id, + "id": id == null ? null : id, "playlistLength": playlistLength == null ? null : playlistLength.toJson(), "videoDuration": videoDuration == null ? null : videoDuration.toJson(), @@ -2051,12 +2349,16 @@ class Icon { String toRawJson() => json.encode(toJson()); factory Icon.fromJson(Map json) => Icon( - thumbnails: List.from( - json["thumbnails"].map((x) => PurpleThumbnail.fromJson(x))), + thumbnails: json["thumbnails"] == null + ? null + : List.from( + json["thumbnails"].map((x) => PurpleThumbnail.fromJson(x))), ); Map toJson() => { - "thumbnails": List.from(thumbnails.map((x) => x.toJson())), + "thumbnails": thumbnails == null + ? null + : List.from(thumbnails.map((x) => x.toJson())), }; } @@ -2074,11 +2376,11 @@ class PurpleThumbnail { factory PurpleThumbnail.fromJson(Map json) => PurpleThumbnail( - url: json["url"], + url: json["url"] == null ? null : json["url"], ); Map toJson() => { - "url": url, + "url": url == null ? null : url, }; } @@ -2094,12 +2396,14 @@ class Message { String toRawJson() => json.encode(toJson()); factory Message.fromJson(Map json) => Message( - mealbarPromoRenderer: - MealbarPromoRenderer.fromJson(json["mealbarPromoRenderer"]), + mealbarPromoRenderer: json["mealbarPromoRenderer"] == null + ? null + : MealbarPromoRenderer.fromJson(json["mealbarPromoRenderer"]), ); Map toJson() => { - "mealbarPromoRenderer": mealbarPromoRenderer.toJson(), + "mealbarPromoRenderer": + mealbarPromoRenderer == null ? null : mealbarPromoRenderer.toJson(), }; } @@ -2135,33 +2439,47 @@ class MealbarPromoRenderer { factory MealbarPromoRenderer.fromJson(Map json) => MealbarPromoRenderer( - icon: IconClass.fromJson(json["icon"]), - messageTexts: List.from( - json["messageTexts"].map((x) => MessageTitle.fromJson(x))), - actionButton: ActionButtonClass.fromJson(json["actionButton"]), - dismissButton: ActionButtonClass.fromJson(json["dismissButton"]), - triggerCondition: json["triggerCondition"], - style: json["style"], - trackingParams: json["trackingParams"], - impressionEndpoints: List.from( - json["impressionEndpoints"] + icon: json["icon"] == null ? null : IconClass.fromJson(json["icon"]), + messageTexts: json["messageTexts"] == null + ? null + : List.from( + json["messageTexts"].map((x) => MessageTitle.fromJson(x))), + actionButton: json["actionButton"] == null + ? null + : ActionButtonClass.fromJson(json["actionButton"]), + dismissButton: json["dismissButton"] == null + ? null + : ActionButtonClass.fromJson(json["dismissButton"]), + triggerCondition: + json["triggerCondition"] == null ? null : json["triggerCondition"], + style: json["style"] == null ? null : json["style"], + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + impressionEndpoints: json["impressionEndpoints"] == null + ? null + : List.from(json["impressionEndpoints"] .map((x) => ImpressionEndpointElement.fromJson(x))), - isVisible: json["isVisible"], - messageTitle: MessageTitle.fromJson(json["messageTitle"]), + isVisible: json["isVisible"] == null ? null : json["isVisible"], + messageTitle: json["messageTitle"] == null + ? null + : MessageTitle.fromJson(json["messageTitle"]), ); Map toJson() => { - "icon": icon.toJson(), - "messageTexts": List.from(messageTexts.map((x) => x.toJson())), - "actionButton": actionButton.toJson(), - "dismissButton": dismissButton.toJson(), - "triggerCondition": triggerCondition, - "style": style, - "trackingParams": trackingParams, - "impressionEndpoints": - List.from(impressionEndpoints.map((x) => x.toJson())), - "isVisible": isVisible, - "messageTitle": messageTitle.toJson(), + "icon": icon == null ? null : icon.toJson(), + "messageTexts": messageTexts == null + ? null + : List.from(messageTexts.map((x) => x.toJson())), + "actionButton": actionButton == null ? null : actionButton.toJson(), + "dismissButton": dismissButton == null ? null : dismissButton.toJson(), + "triggerCondition": triggerCondition == null ? null : triggerCondition, + "style": style == null ? null : style, + "trackingParams": trackingParams == null ? null : trackingParams, + "impressionEndpoints": impressionEndpoints == null + ? null + : List.from(impressionEndpoints.map((x) => x.toJson())), + "isVisible": isVisible == null ? null : isVisible, + "messageTitle": messageTitle == null ? null : messageTitle.toJson(), }; } @@ -2179,12 +2497,14 @@ class ActionButtonClass { factory ActionButtonClass.fromJson(Map json) => ActionButtonClass( - buttonRenderer: - DismissButtonButtonRenderer.fromJson(json["buttonRenderer"]), + buttonRenderer: json["buttonRenderer"] == null + ? null + : DismissButtonButtonRenderer.fromJson(json["buttonRenderer"]), ); Map toJson() => { - "buttonRenderer": buttonRenderer.toJson(), + "buttonRenderer": + buttonRenderer == null ? null : buttonRenderer.toJson(), }; } @@ -2212,25 +2532,28 @@ class DismissButtonButtonRenderer { factory DismissButtonButtonRenderer.fromJson(Map json) => DismissButtonButtonRenderer( - style: json["style"], - size: json["size"], - text: MessageTitle.fromJson(json["text"]), - serviceEndpoint: - ImpressionEndpointElement.fromJson(json["serviceEndpoint"]), + style: json["style"] == null ? null : json["style"], + size: json["size"] == null ? null : json["size"], + text: json["text"] == null ? null : MessageTitle.fromJson(json["text"]), + serviceEndpoint: json["serviceEndpoint"] == null + ? null + : ImpressionEndpointElement.fromJson(json["serviceEndpoint"]), navigationEndpoint: json["navigationEndpoint"] == null ? null : NavigationEndpoint.fromJson(json["navigationEndpoint"]), - trackingParams: json["trackingParams"], + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], ); Map toJson() => { - "style": style, - "size": size, - "text": text.toJson(), - "serviceEndpoint": serviceEndpoint.toJson(), + "style": style == null ? null : style, + "size": size == null ? null : size, + "text": text == null ? null : text.toJson(), + "serviceEndpoint": + serviceEndpoint == null ? null : serviceEndpoint.toJson(), "navigationEndpoint": navigationEndpoint == null ? null : navigationEndpoint.toJson(), - "trackingParams": trackingParams, + "trackingParams": trackingParams == null ? null : trackingParams, }; } @@ -2242,7 +2565,7 @@ class ImpressionEndpointElement { }); final String clickTrackingParams; - final ServiceEndpointCommandMetadata commandMetadata; + final SubscribeCommandCommandMetadata commandMetadata; final FeedbackEndpoint feedbackEndpoint; factory ImpressionEndpointElement.fromRawJson(String str) => @@ -2252,16 +2575,24 @@ class ImpressionEndpointElement { factory ImpressionEndpointElement.fromJson(Map json) => ImpressionEndpointElement( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - ServiceEndpointCommandMetadata.fromJson(json["commandMetadata"]), - feedbackEndpoint: FeedbackEndpoint.fromJson(json["feedbackEndpoint"]), + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + commandMetadata: json["commandMetadata"] == null + ? null + : SubscribeCommandCommandMetadata.fromJson(json["commandMetadata"]), + feedbackEndpoint: json["feedbackEndpoint"] == null + ? null + : FeedbackEndpoint.fromJson(json["feedbackEndpoint"]), ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), - "feedbackEndpoint": feedbackEndpoint.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "commandMetadata": + commandMetadata == null ? null : commandMetadata.toJson(), + "feedbackEndpoint": + feedbackEndpoint == null ? null : feedbackEndpoint.toJson(), }; } @@ -2281,13 +2612,16 @@ class FeedbackEndpoint { factory FeedbackEndpoint.fromJson(Map json) => FeedbackEndpoint( - feedbackToken: json["feedbackToken"], - uiActions: UiActions.fromJson(json["uiActions"]), + feedbackToken: + json["feedbackToken"] == null ? null : json["feedbackToken"], + uiActions: json["uiActions"] == null + ? null + : UiActions.fromJson(json["uiActions"]), ); Map toJson() => { - "feedbackToken": feedbackToken, - "uiActions": uiActions.toJson(), + "feedbackToken": feedbackToken == null ? null : feedbackToken, + "uiActions": uiActions == null ? null : uiActions.toJson(), }; } @@ -2304,11 +2638,14 @@ class UiActions { String toRawJson() => json.encode(toJson()); factory UiActions.fromJson(Map json) => UiActions( - hideEnclosingContainer: json["hideEnclosingContainer"], + hideEnclosingContainer: json["hideEnclosingContainer"] == null + ? null + : json["hideEnclosingContainer"], ); Map toJson() => { - "hideEnclosingContainer": hideEnclosingContainer, + "hideEnclosingContainer": + hideEnclosingContainer == null ? null : hideEnclosingContainer, }; } @@ -2325,12 +2662,16 @@ class Microformat { String toRawJson() => json.encode(toJson()); factory Microformat.fromJson(Map json) => Microformat( - playerMicroformatRenderer: PlayerMicroformatRenderer.fromJson( - json["playerMicroformatRenderer"]), + playerMicroformatRenderer: json["playerMicroformatRenderer"] == null + ? null + : PlayerMicroformatRenderer.fromJson( + json["playerMicroformatRenderer"]), ); Map toJson() => { - "playerMicroformatRenderer": playerMicroformatRenderer.toJson(), + "playerMicroformatRenderer": playerMicroformatRenderer == null + ? null + : playerMicroformatRenderer.toJson(), }; } @@ -2378,46 +2719,68 @@ class PlayerMicroformatRenderer { factory PlayerMicroformatRenderer.fromJson(Map json) => PlayerMicroformatRenderer( - thumbnail: IconClass.fromJson(json["thumbnail"]), - embed: Embed.fromJson(json["embed"]), - title: HeaderText.fromJson(json["title"]), - description: HeaderText.fromJson(json["description"]), - lengthSeconds: json["lengthSeconds"], - ownerProfileUrl: json["ownerProfileUrl"], - externalChannelId: json["externalChannelId"], - availableCountries: - List.from(json["availableCountries"].map((x) => x)), - isUnlisted: json["isUnlisted"], - hasYpcMetadata: json["hasYpcMetadata"], - viewCount: json["viewCount"], - category: json["category"], - publishDate: DateTime.parse(json["publishDate"]), - ownerChannelName: json["ownerChannelName"], - uploadDate: DateTime.parse(json["uploadDate"]), - liveBroadcastDetails: - LiveBroadcastDetails.fromJson(json["liveBroadcastDetails"]), + thumbnail: json["thumbnail"] == null + ? null + : IconClass.fromJson(json["thumbnail"]), + embed: json["embed"] == null ? null : Embed.fromJson(json["embed"]), + title: + json["title"] == null ? null : HeaderText.fromJson(json["title"]), + description: json["description"] == null + ? null + : HeaderText.fromJson(json["description"]), + lengthSeconds: + json["lengthSeconds"] == null ? null : json["lengthSeconds"], + ownerProfileUrl: + json["ownerProfileUrl"] == null ? null : json["ownerProfileUrl"], + externalChannelId: json["externalChannelId"] == null + ? null + : json["externalChannelId"], + availableCountries: json["availableCountries"] == null + ? null + : List.from(json["availableCountries"].map((x) => x)), + isUnlisted: json["isUnlisted"] == null ? null : json["isUnlisted"], + hasYpcMetadata: + json["hasYpcMetadata"] == null ? null : json["hasYpcMetadata"], + viewCount: json["viewCount"] == null ? null : json["viewCount"], + category: json["category"] == null ? null : json["category"], + publishDate: json["publishDate"] == null + ? null + : DateTime.parse(json["publishDate"]), + ownerChannelName: + json["ownerChannelName"] == null ? null : json["ownerChannelName"], + uploadDate: json["uploadDate"] == null + ? null + : DateTime.parse(json["uploadDate"]), + liveBroadcastDetails: json["liveBroadcastDetails"] == null + ? null + : LiveBroadcastDetails.fromJson(json["liveBroadcastDetails"]), ); Map toJson() => { - "thumbnail": thumbnail.toJson(), - "embed": embed.toJson(), - "title": title.toJson(), - "description": description.toJson(), - "lengthSeconds": lengthSeconds, - "ownerProfileUrl": ownerProfileUrl, - "externalChannelId": externalChannelId, - "availableCountries": - List.from(availableCountries.map((x) => x)), - "isUnlisted": isUnlisted, - "hasYpcMetadata": hasYpcMetadata, - "viewCount": viewCount, - "category": category, - "publishDate": - "${publishDate.year.toString().padLeft(4, '0')}-${publishDate.month.toString().padLeft(2, '0')}-${publishDate.day.toString().padLeft(2, '0')}", - "ownerChannelName": ownerChannelName, - "uploadDate": - "${uploadDate.year.toString().padLeft(4, '0')}-${uploadDate.month.toString().padLeft(2, '0')}-${uploadDate.day.toString().padLeft(2, '0')}", - "liveBroadcastDetails": liveBroadcastDetails.toJson(), + "thumbnail": thumbnail == null ? null : thumbnail.toJson(), + "embed": embed == null ? null : embed.toJson(), + "title": title == null ? null : title.toJson(), + "description": description == null ? null : description.toJson(), + "lengthSeconds": lengthSeconds == null ? null : lengthSeconds, + "ownerProfileUrl": ownerProfileUrl == null ? null : ownerProfileUrl, + "externalChannelId": + externalChannelId == null ? null : externalChannelId, + "availableCountries": availableCountries == null + ? null + : List.from(availableCountries.map((x) => x)), + "isUnlisted": isUnlisted == null ? null : isUnlisted, + "hasYpcMetadata": hasYpcMetadata == null ? null : hasYpcMetadata, + "viewCount": viewCount == null ? null : viewCount, + "category": category == null ? null : category, + "publishDate": publishDate == null + ? null + : "${publishDate.year.toString().padLeft(4, '0')}-${publishDate.month.toString().padLeft(2, '0')}-${publishDate.day.toString().padLeft(2, '0')}", + "ownerChannelName": ownerChannelName == null ? null : ownerChannelName, + "uploadDate": uploadDate == null + ? null + : "${uploadDate.year.toString().padLeft(4, '0')}-${uploadDate.month.toString().padLeft(2, '0')}-${uploadDate.day.toString().padLeft(2, '0')}", + "liveBroadcastDetails": + liveBroadcastDetails == null ? null : liveBroadcastDetails.toJson(), }; } @@ -2441,19 +2804,20 @@ class Embed { String toRawJson() => json.encode(toJson()); factory Embed.fromJson(Map json) => Embed( - iframeUrl: json["iframeUrl"], - flashUrl: json["flashUrl"], - width: json["width"], - height: json["height"], - flashSecureUrl: json["flashSecureUrl"], + iframeUrl: json["iframeUrl"] == null ? null : json["iframeUrl"], + flashUrl: json["flashUrl"] == null ? null : json["flashUrl"], + width: json["width"] == null ? null : json["width"], + height: json["height"] == null ? null : json["height"], + flashSecureUrl: + json["flashSecureUrl"] == null ? null : json["flashSecureUrl"], ); Map toJson() => { - "iframeUrl": iframeUrl, - "flashUrl": flashUrl, - "width": width, - "height": height, - "flashSecureUrl": flashSecureUrl, + "iframeUrl": iframeUrl == null ? null : iframeUrl, + "flashUrl": flashUrl == null ? null : flashUrl, + "width": width == null ? null : width, + "height": height == null ? null : height, + "flashSecureUrl": flashSecureUrl == null ? null : flashSecureUrl, }; } @@ -2473,13 +2837,16 @@ class LiveBroadcastDetails { factory LiveBroadcastDetails.fromJson(Map json) => LiveBroadcastDetails( - isLiveNow: json["isLiveNow"], - startTimestamp: DateTime.parse(json["startTimestamp"]), + isLiveNow: json["isLiveNow"] == null ? null : json["isLiveNow"], + startTimestamp: json["startTimestamp"] == null + ? null + : DateTime.parse(json["startTimestamp"]), ); Map toJson() => { - "isLiveNow": isLiveNow, - "startTimestamp": startTimestamp.toIso8601String(), + "isLiveNow": isLiveNow == null ? null : isLiveNow, + "startTimestamp": + startTimestamp == null ? null : startTimestamp.toIso8601String(), }; } @@ -2490,6 +2857,7 @@ class PlayabilityStatus { this.miniplayer, this.contextParams, this.liveStreamability, + this.reason, }); final String status; @@ -2497,6 +2865,7 @@ class PlayabilityStatus { final Miniplayer miniplayer; final String contextParams; final LiveStreamability liveStreamability; + final String reason; factory PlayabilityStatus.fromRawJson(String str) => PlayabilityStatus.fromJson(json.decode(str)); @@ -2505,20 +2874,28 @@ class PlayabilityStatus { factory PlayabilityStatus.fromJson(Map json) => PlayabilityStatus( - status: json["status"], - playableInEmbed: json["playableInEmbed"], - miniplayer: Miniplayer.fromJson(json["miniplayer"]), - contextParams: json["contextParams"], - liveStreamability: - LiveStreamability.fromJson(json["liveStreamability"]), + status: json["status"] == null ? null : json["status"], + playableInEmbed: + json["playableInEmbed"] == null ? null : json["playableInEmbed"], + miniplayer: json["miniplayer"] == null + ? null + : Miniplayer.fromJson(json["miniplayer"]), + contextParams: + json["contextParams"] == null ? null : json["contextParams"], + liveStreamability: json["liveStreamability"] == null + ? null + : LiveStreamability.fromJson(json["liveStreamability"]), + reason: json["reason"] == null ? null : json["reason"], ); Map toJson() => { - "status": status, - "playableInEmbed": playableInEmbed, - "miniplayer": miniplayer.toJson(), - "contextParams": contextParams, - "liveStreamability": liveStreamability.toJson(), + "status": status == null ? null : status, + "playableInEmbed": playableInEmbed == null ? null : playableInEmbed, + "miniplayer": miniplayer == null ? null : miniplayer.toJson(), + "contextParams": contextParams == null ? null : contextParams, + "liveStreamability": + liveStreamability == null ? null : liveStreamability.toJson(), + "reason": reason == null ? null : reason, }; } @@ -2536,12 +2913,16 @@ class LiveStreamability { factory LiveStreamability.fromJson(Map json) => LiveStreamability( - liveStreamabilityRenderer: LiveStreamabilityRenderer.fromJson( - json["liveStreamabilityRenderer"]), + liveStreamabilityRenderer: json["liveStreamabilityRenderer"] == null + ? null + : LiveStreamabilityRenderer.fromJson( + json["liveStreamabilityRenderer"]), ); Map toJson() => { - "liveStreamabilityRenderer": liveStreamabilityRenderer.toJson(), + "liveStreamabilityRenderer": liveStreamabilityRenderer == null + ? null + : liveStreamabilityRenderer.toJson(), }; } @@ -2561,13 +2942,13 @@ class LiveStreamabilityRenderer { factory LiveStreamabilityRenderer.fromJson(Map json) => LiveStreamabilityRenderer( - videoId: json["videoId"], - pollDelayMs: json["pollDelayMs"], + videoId: json["videoId"] == null ? null : json["videoId"], + pollDelayMs: json["pollDelayMs"] == null ? null : json["pollDelayMs"], ); Map toJson() => { - "videoId": videoId, - "pollDelayMs": pollDelayMs, + "videoId": videoId == null ? null : videoId, + "pollDelayMs": pollDelayMs == null ? null : pollDelayMs, }; } @@ -2584,12 +2965,14 @@ class Miniplayer { String toRawJson() => json.encode(toJson()); factory Miniplayer.fromJson(Map json) => Miniplayer( - miniplayerRenderer: - MiniplayerRenderer.fromJson(json["miniplayerRenderer"]), + miniplayerRenderer: json["miniplayerRenderer"] == null + ? null + : MiniplayerRenderer.fromJson(json["miniplayerRenderer"]), ); Map toJson() => { - "miniplayerRenderer": miniplayerRenderer.toJson(), + "miniplayerRenderer": + miniplayerRenderer == null ? null : miniplayerRenderer.toJson(), }; } @@ -2609,14 +2992,17 @@ class MiniplayerRenderer { factory MiniplayerRenderer.fromJson(Map json) => MiniplayerRenderer( - playbackMode: json["playbackMode"], - minimizedEndpoint: - MinimizedEndpoint.fromJson(json["minimizedEndpoint"]), + playbackMode: + json["playbackMode"] == null ? null : json["playbackMode"], + minimizedEndpoint: json["minimizedEndpoint"] == null + ? null + : MinimizedEndpoint.fromJson(json["minimizedEndpoint"]), ); Map toJson() => { - "playbackMode": playbackMode, - "minimizedEndpoint": minimizedEndpoint.toJson(), + "playbackMode": playbackMode == null ? null : playbackMode, + "minimizedEndpoint": + minimizedEndpoint == null ? null : minimizedEndpoint.toJson(), }; } @@ -2636,14 +3022,20 @@ class MinimizedEndpoint { factory MinimizedEndpoint.fromJson(Map json) => MinimizedEndpoint( - clickTrackingParams: json["clickTrackingParams"], - openPopupAction: - MinimizedEndpointOpenPopupAction.fromJson(json["openPopupAction"]), + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + openPopupAction: json["openPopupAction"] == null + ? null + : MinimizedEndpointOpenPopupAction.fromJson( + json["openPopupAction"]), ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "openPopupAction": openPopupAction.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "openPopupAction": + openPopupAction == null ? null : openPopupAction.toJson(), }; } @@ -2664,13 +3056,14 @@ class MinimizedEndpointOpenPopupAction { factory MinimizedEndpointOpenPopupAction.fromJson( Map json) => MinimizedEndpointOpenPopupAction( - popup: FluffyPopup.fromJson(json["popup"]), - popupType: json["popupType"], + popup: + json["popup"] == null ? null : FluffyPopup.fromJson(json["popup"]), + popupType: json["popupType"] == null ? null : json["popupType"], ); Map toJson() => { - "popup": popup.toJson(), - "popupType": popupType, + "popup": popup == null ? null : popup.toJson(), + "popupType": popupType == null ? null : popupType, }; } @@ -2687,12 +3080,16 @@ class FluffyPopup { String toRawJson() => json.encode(toJson()); factory FluffyPopup.fromJson(Map json) => FluffyPopup( - notificationActionRenderer: NotificationActionRenderer.fromJson( - json["notificationActionRenderer"]), + notificationActionRenderer: json["notificationActionRenderer"] == null + ? null + : NotificationActionRenderer.fromJson( + json["notificationActionRenderer"]), ); Map toJson() => { - "notificationActionRenderer": notificationActionRenderer.toJson(), + "notificationActionRenderer": notificationActionRenderer == null + ? null + : notificationActionRenderer.toJson(), }; } @@ -2714,16 +3111,21 @@ class NotificationActionRenderer { factory NotificationActionRenderer.fromJson(Map json) => NotificationActionRenderer( - responseText: HeaderText.fromJson(json["responseText"]), - actionButton: NotificationActionRendererActionButton.fromJson( - json["actionButton"]), - trackingParams: json["trackingParams"], + responseText: json["responseText"] == null + ? null + : HeaderText.fromJson(json["responseText"]), + actionButton: json["actionButton"] == null + ? null + : NotificationActionRendererActionButton.fromJson( + json["actionButton"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], ); Map toJson() => { - "responseText": responseText.toJson(), - "actionButton": actionButton.toJson(), - "trackingParams": trackingParams, + "responseText": responseText == null ? null : responseText.toJson(), + "actionButton": actionButton == null ? null : actionButton.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, }; } @@ -2742,11 +3144,14 @@ class NotificationActionRendererActionButton { factory NotificationActionRendererActionButton.fromJson( Map json) => NotificationActionRendererActionButton( - buttonRenderer: PurpleButtonRenderer.fromJson(json["buttonRenderer"]), + buttonRenderer: json["buttonRenderer"] == null + ? null + : PurpleButtonRenderer.fromJson(json["buttonRenderer"]), ); Map toJson() => { - "buttonRenderer": buttonRenderer.toJson(), + "buttonRenderer": + buttonRenderer == null ? null : buttonRenderer.toJson(), }; } @@ -2768,15 +3173,18 @@ class PurpleButtonRenderer { factory PurpleButtonRenderer.fromJson(Map json) => PurpleButtonRenderer( - text: HeaderText.fromJson(json["text"]), - trackingParams: json["trackingParams"], - command: NavigationEndpoint.fromJson(json["command"]), + text: json["text"] == null ? null : HeaderText.fromJson(json["text"]), + trackingParams: + json["trackingParams"] == null ? null : json["trackingParams"], + command: json["command"] == null + ? null + : NavigationEndpoint.fromJson(json["command"]), ); Map toJson() => { - "text": text.toJson(), - "trackingParams": trackingParams, - "command": command.toJson(), + "text": text == null ? null : text.toJson(), + "trackingParams": trackingParams == null ? null : trackingParams, + "command": command == null ? null : command.toJson(), }; } @@ -2808,29 +3216,49 @@ class PlaybackTracking { factory PlaybackTracking.fromJson(Map json) => PlaybackTracking( - videostatsPlaybackUrl: - PtrackingUrlClass.fromJson(json["videostatsPlaybackUrl"]), - videostatsDelayplayUrl: - AtrUrlClass.fromJson(json["videostatsDelayplayUrl"]), - videostatsWatchtimeUrl: - PtrackingUrlClass.fromJson(json["videostatsWatchtimeUrl"]), - ptrackingUrl: PtrackingUrlClass.fromJson(json["ptrackingUrl"]), - qoeUrl: PtrackingUrlClass.fromJson(json["qoeUrl"]), - setAwesomeUrl: AtrUrlClass.fromJson(json["setAwesomeUrl"]), - atrUrl: AtrUrlClass.fromJson(json["atrUrl"]), - youtubeRemarketingUrl: - AtrUrlClass.fromJson(json["youtubeRemarketingUrl"]), + videostatsPlaybackUrl: json["videostatsPlaybackUrl"] == null + ? null + : PtrackingUrlClass.fromJson(json["videostatsPlaybackUrl"]), + videostatsDelayplayUrl: json["videostatsDelayplayUrl"] == null + ? null + : AtrUrlClass.fromJson(json["videostatsDelayplayUrl"]), + videostatsWatchtimeUrl: json["videostatsWatchtimeUrl"] == null + ? null + : PtrackingUrlClass.fromJson(json["videostatsWatchtimeUrl"]), + ptrackingUrl: json["ptrackingUrl"] == null + ? null + : PtrackingUrlClass.fromJson(json["ptrackingUrl"]), + qoeUrl: json["qoeUrl"] == null + ? null + : PtrackingUrlClass.fromJson(json["qoeUrl"]), + setAwesomeUrl: json["setAwesomeUrl"] == null + ? null + : AtrUrlClass.fromJson(json["setAwesomeUrl"]), + atrUrl: json["atrUrl"] == null + ? null + : AtrUrlClass.fromJson(json["atrUrl"]), + youtubeRemarketingUrl: json["youtubeRemarketingUrl"] == null + ? null + : AtrUrlClass.fromJson(json["youtubeRemarketingUrl"]), ); Map toJson() => { - "videostatsPlaybackUrl": videostatsPlaybackUrl.toJson(), - "videostatsDelayplayUrl": videostatsDelayplayUrl.toJson(), - "videostatsWatchtimeUrl": videostatsWatchtimeUrl.toJson(), - "ptrackingUrl": ptrackingUrl.toJson(), - "qoeUrl": qoeUrl.toJson(), - "setAwesomeUrl": setAwesomeUrl.toJson(), - "atrUrl": atrUrl.toJson(), - "youtubeRemarketingUrl": youtubeRemarketingUrl.toJson(), + "videostatsPlaybackUrl": videostatsPlaybackUrl == null + ? null + : videostatsPlaybackUrl.toJson(), + "videostatsDelayplayUrl": videostatsDelayplayUrl == null + ? null + : videostatsDelayplayUrl.toJson(), + "videostatsWatchtimeUrl": videostatsWatchtimeUrl == null + ? null + : videostatsWatchtimeUrl.toJson(), + "ptrackingUrl": ptrackingUrl == null ? null : ptrackingUrl.toJson(), + "qoeUrl": qoeUrl == null ? null : qoeUrl.toJson(), + "setAwesomeUrl": setAwesomeUrl == null ? null : setAwesomeUrl.toJson(), + "atrUrl": atrUrl == null ? null : atrUrl.toJson(), + "youtubeRemarketingUrl": youtubeRemarketingUrl == null + ? null + : youtubeRemarketingUrl.toJson(), }; } @@ -2849,13 +3277,16 @@ class AtrUrlClass { String toRawJson() => json.encode(toJson()); factory AtrUrlClass.fromJson(Map json) => AtrUrlClass( - baseUrl: json["baseUrl"], - elapsedMediaTimeSeconds: json["elapsedMediaTimeSeconds"], + baseUrl: json["baseUrl"] == null ? null : json["baseUrl"], + elapsedMediaTimeSeconds: json["elapsedMediaTimeSeconds"] == null + ? null + : json["elapsedMediaTimeSeconds"], ); Map toJson() => { - "baseUrl": baseUrl, - "elapsedMediaTimeSeconds": elapsedMediaTimeSeconds, + "baseUrl": baseUrl == null ? null : baseUrl, + "elapsedMediaTimeSeconds": + elapsedMediaTimeSeconds == null ? null : elapsedMediaTimeSeconds, }; } @@ -2873,11 +3304,11 @@ class PtrackingUrlClass { factory PtrackingUrlClass.fromJson(Map json) => PtrackingUrlClass( - baseUrl: json["baseUrl"], + baseUrl: json["baseUrl"] == null ? null : json["baseUrl"], ); Map toJson() => { - "baseUrl": baseUrl, + "baseUrl": baseUrl == null ? null : baseUrl, }; } @@ -2904,23 +3335,38 @@ class PlayerConfig { String toRawJson() => json.encode(toJson()); factory PlayerConfig.fromJson(Map json) => PlayerConfig( - audioConfig: AudioConfig.fromJson(json["audioConfig"]), - streamSelectionConfig: - StreamSelectionConfig.fromJson(json["streamSelectionConfig"]), - daiConfig: DaiConfig.fromJson(json["daiConfig"]), - mediaCommonConfig: - MediaCommonConfig.fromJson(json["mediaCommonConfig"]), - webPlayerConfig: WebPlayerConfig.fromJson(json["webPlayerConfig"]), - livePlayerConfig: LivePlayerConfig.fromJson(json["livePlayerConfig"]), + audioConfig: json["audioConfig"] == null + ? null + : AudioConfig.fromJson(json["audioConfig"]), + streamSelectionConfig: json["streamSelectionConfig"] == null + ? null + : StreamSelectionConfig.fromJson(json["streamSelectionConfig"]), + daiConfig: json["daiConfig"] == null + ? null + : DaiConfig.fromJson(json["daiConfig"]), + mediaCommonConfig: json["mediaCommonConfig"] == null + ? null + : MediaCommonConfig.fromJson(json["mediaCommonConfig"]), + webPlayerConfig: json["webPlayerConfig"] == null + ? null + : WebPlayerConfig.fromJson(json["webPlayerConfig"]), + livePlayerConfig: json["livePlayerConfig"] == null + ? null + : LivePlayerConfig.fromJson(json["livePlayerConfig"]), ); Map toJson() => { - "audioConfig": audioConfig.toJson(), - "streamSelectionConfig": streamSelectionConfig.toJson(), - "daiConfig": daiConfig.toJson(), - "mediaCommonConfig": mediaCommonConfig.toJson(), - "webPlayerConfig": webPlayerConfig.toJson(), - "livePlayerConfig": livePlayerConfig.toJson(), + "audioConfig": audioConfig == null ? null : audioConfig.toJson(), + "streamSelectionConfig": streamSelectionConfig == null + ? null + : streamSelectionConfig.toJson(), + "daiConfig": daiConfig == null ? null : daiConfig.toJson(), + "mediaCommonConfig": + mediaCommonConfig == null ? null : mediaCommonConfig.toJson(), + "webPlayerConfig": + webPlayerConfig == null ? null : webPlayerConfig.toJson(), + "livePlayerConfig": + livePlayerConfig == null ? null : livePlayerConfig.toJson(), }; } @@ -2941,15 +3387,22 @@ class AudioConfig { String toRawJson() => json.encode(toJson()); factory AudioConfig.fromJson(Map json) => AudioConfig( - loudnessDb: json["loudnessDb"].toDouble(), - perceptualLoudnessDb: json["perceptualLoudnessDb"].toDouble(), - enablePerFormatLoudness: json["enablePerFormatLoudness"], + loudnessDb: + json["loudnessDb"] == null ? null : json["loudnessDb"].toDouble(), + perceptualLoudnessDb: json["perceptualLoudnessDb"] == null + ? null + : json["perceptualLoudnessDb"].toDouble(), + enablePerFormatLoudness: json["enablePerFormatLoudness"] == null + ? null + : json["enablePerFormatLoudness"], ); Map toJson() => { - "loudnessDb": loudnessDb, - "perceptualLoudnessDb": perceptualLoudnessDb, - "enablePerFormatLoudness": enablePerFormatLoudness, + "loudnessDb": loudnessDb == null ? null : loudnessDb, + "perceptualLoudnessDb": + perceptualLoudnessDb == null ? null : perceptualLoudnessDb, + "enablePerFormatLoudness": + enablePerFormatLoudness == null ? null : enablePerFormatLoudness, }; } @@ -2968,13 +3421,16 @@ class DaiConfig { String toRawJson() => json.encode(toJson()); factory DaiConfig.fromJson(Map json) => DaiConfig( - enableServerStitchedDai: json["enableServerStitchedDai"], - enableDai: json["enableDai"], + enableServerStitchedDai: json["enableServerStitchedDai"] == null + ? null + : json["enableServerStitchedDai"], + enableDai: json["enableDai"] == null ? null : json["enableDai"], ); Map toJson() => { - "enableServerStitchedDai": enableServerStitchedDai, - "enableDai": enableDai, + "enableServerStitchedDai": + enableServerStitchedDai == null ? null : enableServerStitchedDai, + "enableDai": enableDai == null ? null : enableDai, }; } @@ -2994,13 +3450,19 @@ class LivePlayerConfig { factory LivePlayerConfig.fromJson(Map json) => LivePlayerConfig( - liveReadaheadSeconds: json["liveReadaheadSeconds"].toDouble(), - hasSubfragmentedFmp4: json["hasSubfragmentedFmp4"], + liveReadaheadSeconds: json["liveReadaheadSeconds"] == null + ? null + : json["liveReadaheadSeconds"].toDouble(), + hasSubfragmentedFmp4: json["hasSubfragmentedFmp4"] == null + ? null + : json["hasSubfragmentedFmp4"], ); Map toJson() => { - "liveReadaheadSeconds": liveReadaheadSeconds, - "hasSubfragmentedFmp4": hasSubfragmentedFmp4, + "liveReadaheadSeconds": + liveReadaheadSeconds == null ? null : liveReadaheadSeconds, + "hasSubfragmentedFmp4": + hasSubfragmentedFmp4 == null ? null : hasSubfragmentedFmp4, }; } @@ -3018,12 +3480,15 @@ class MediaCommonConfig { factory MediaCommonConfig.fromJson(Map json) => MediaCommonConfig( - dynamicReadaheadConfig: - DynamicReadaheadConfig.fromJson(json["dynamicReadaheadConfig"]), + dynamicReadaheadConfig: json["dynamicReadaheadConfig"] == null + ? null + : DynamicReadaheadConfig.fromJson(json["dynamicReadaheadConfig"]), ); Map toJson() => { - "dynamicReadaheadConfig": dynamicReadaheadConfig.toJson(), + "dynamicReadaheadConfig": dynamicReadaheadConfig == null + ? null + : dynamicReadaheadConfig.toJson(), }; } @@ -3045,15 +3510,24 @@ class DynamicReadaheadConfig { factory DynamicReadaheadConfig.fromJson(Map json) => DynamicReadaheadConfig( - maxReadAheadMediaTimeMs: json["maxReadAheadMediaTimeMs"], - minReadAheadMediaTimeMs: json["minReadAheadMediaTimeMs"], - readAheadGrowthRateMs: json["readAheadGrowthRateMs"], + maxReadAheadMediaTimeMs: json["maxReadAheadMediaTimeMs"] == null + ? null + : json["maxReadAheadMediaTimeMs"], + minReadAheadMediaTimeMs: json["minReadAheadMediaTimeMs"] == null + ? null + : json["minReadAheadMediaTimeMs"], + readAheadGrowthRateMs: json["readAheadGrowthRateMs"] == null + ? null + : json["readAheadGrowthRateMs"], ); Map toJson() => { - "maxReadAheadMediaTimeMs": maxReadAheadMediaTimeMs, - "minReadAheadMediaTimeMs": minReadAheadMediaTimeMs, - "readAheadGrowthRateMs": readAheadGrowthRateMs, + "maxReadAheadMediaTimeMs": + maxReadAheadMediaTimeMs == null ? null : maxReadAheadMediaTimeMs, + "minReadAheadMediaTimeMs": + minReadAheadMediaTimeMs == null ? null : minReadAheadMediaTimeMs, + "readAheadGrowthRateMs": + readAheadGrowthRateMs == null ? null : readAheadGrowthRateMs, }; } @@ -3071,11 +3545,11 @@ class StreamSelectionConfig { factory StreamSelectionConfig.fromJson(Map json) => StreamSelectionConfig( - maxBitrate: json["maxBitrate"], + maxBitrate: json["maxBitrate"] == null ? null : json["maxBitrate"], ); Map toJson() => { - "maxBitrate": maxBitrate, + "maxBitrate": maxBitrate == null ? null : maxBitrate, }; } @@ -3093,12 +3567,15 @@ class WebPlayerConfig { factory WebPlayerConfig.fromJson(Map json) => WebPlayerConfig( - webPlayerActionsPorting: - WebPlayerActionsPorting.fromJson(json["webPlayerActionsPorting"]), + webPlayerActionsPorting: json["webPlayerActionsPorting"] == null + ? null + : WebPlayerActionsPorting.fromJson(json["webPlayerActionsPorting"]), ); Map toJson() => { - "webPlayerActionsPorting": webPlayerActionsPorting.toJson(), + "webPlayerActionsPorting": webPlayerActionsPorting == null + ? null + : webPlayerActionsPorting.toJson(), }; } @@ -3124,23 +3601,37 @@ class WebPlayerActionsPorting { factory WebPlayerActionsPorting.fromJson(Map json) => WebPlayerActionsPorting( - getSharePanelCommand: - GetSharePanelCommand.fromJson(json["getSharePanelCommand"]), - subscribeCommand: SubscribeCommand.fromJson(json["subscribeCommand"]), - unsubscribeCommand: - UnsubscribeCommand.fromJson(json["unsubscribeCommand"]), - addToWatchLaterCommand: - AddToWatchLaterCommand.fromJson(json["addToWatchLaterCommand"]), - removeFromWatchLaterCommand: RemoveFromWatchLaterCommand.fromJson( - json["removeFromWatchLaterCommand"]), + getSharePanelCommand: json["getSharePanelCommand"] == null + ? null + : GetSharePanelCommand.fromJson(json["getSharePanelCommand"]), + subscribeCommand: json["subscribeCommand"] == null + ? null + : SubscribeCommand.fromJson(json["subscribeCommand"]), + unsubscribeCommand: json["unsubscribeCommand"] == null + ? null + : UnsubscribeCommand.fromJson(json["unsubscribeCommand"]), + addToWatchLaterCommand: json["addToWatchLaterCommand"] == null + ? null + : AddToWatchLaterCommand.fromJson(json["addToWatchLaterCommand"]), + removeFromWatchLaterCommand: json["removeFromWatchLaterCommand"] == null + ? null + : RemoveFromWatchLaterCommand.fromJson( + json["removeFromWatchLaterCommand"]), ); Map toJson() => { - "getSharePanelCommand": getSharePanelCommand.toJson(), - "subscribeCommand": subscribeCommand.toJson(), - "unsubscribeCommand": unsubscribeCommand.toJson(), - "addToWatchLaterCommand": addToWatchLaterCommand.toJson(), - "removeFromWatchLaterCommand": removeFromWatchLaterCommand.toJson(), + "getSharePanelCommand": + getSharePanelCommand == null ? null : getSharePanelCommand.toJson(), + "subscribeCommand": + subscribeCommand == null ? null : subscribeCommand.toJson(), + "unsubscribeCommand": + unsubscribeCommand == null ? null : unsubscribeCommand.toJson(), + "addToWatchLaterCommand": addToWatchLaterCommand == null + ? null + : addToWatchLaterCommand.toJson(), + "removeFromWatchLaterCommand": removeFromWatchLaterCommand == null + ? null + : removeFromWatchLaterCommand.toJson(), }; } @@ -3152,7 +3643,7 @@ class AddToWatchLaterCommand { }); final String clickTrackingParams; - final ServiceEndpointCommandMetadata commandMetadata; + final SubscribeCommandCommandMetadata commandMetadata; final AddToWatchLaterCommandPlaylistEditEndpoint playlistEditEndpoint; factory AddToWatchLaterCommand.fromRawJson(String str) => @@ -3162,18 +3653,25 @@ class AddToWatchLaterCommand { factory AddToWatchLaterCommand.fromJson(Map json) => AddToWatchLaterCommand( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - ServiceEndpointCommandMetadata.fromJson(json["commandMetadata"]), - playlistEditEndpoint: - AddToWatchLaterCommandPlaylistEditEndpoint.fromJson( + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + commandMetadata: json["commandMetadata"] == null + ? null + : SubscribeCommandCommandMetadata.fromJson(json["commandMetadata"]), + playlistEditEndpoint: json["playlistEditEndpoint"] == null + ? null + : AddToWatchLaterCommandPlaylistEditEndpoint.fromJson( json["playlistEditEndpoint"]), ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), - "playlistEditEndpoint": playlistEditEndpoint.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "commandMetadata": + commandMetadata == null ? null : commandMetadata.toJson(), + "playlistEditEndpoint": + playlistEditEndpoint == null ? null : playlistEditEndpoint.toJson(), }; } @@ -3194,14 +3692,18 @@ class AddToWatchLaterCommandPlaylistEditEndpoint { factory AddToWatchLaterCommandPlaylistEditEndpoint.fromJson( Map json) => AddToWatchLaterCommandPlaylistEditEndpoint( - playlistId: json["playlistId"], - actions: List.from( - json["actions"].map((x) => PurpleAction.fromJson(x))), + playlistId: json["playlistId"] == null ? null : json["playlistId"], + actions: json["actions"] == null + ? null + : List.from( + json["actions"].map((x) => PurpleAction.fromJson(x))), ); Map toJson() => { - "playlistId": playlistId, - "actions": List.from(actions.map((x) => x.toJson())), + "playlistId": playlistId == null ? null : playlistId, + "actions": actions == null + ? null + : List.from(actions.map((x) => x.toJson())), }; } @@ -3220,13 +3722,14 @@ class PurpleAction { String toRawJson() => json.encode(toJson()); factory PurpleAction.fromJson(Map json) => PurpleAction( - addedVideoId: json["addedVideoId"], - action: json["action"], + addedVideoId: + json["addedVideoId"] == null ? null : json["addedVideoId"], + action: json["action"] == null ? null : json["action"], ); Map toJson() => { - "addedVideoId": addedVideoId, - "action": action, + "addedVideoId": addedVideoId == null ? null : addedVideoId, + "action": action == null ? null : action, }; } @@ -3238,7 +3741,7 @@ class GetSharePanelCommand { }); final String clickTrackingParams; - final ServiceEndpointCommandMetadata commandMetadata; + final SubscribeCommandCommandMetadata commandMetadata; final WebPlayerShareEntityServiceEndpoint webPlayerShareEntityServiceEndpoint; factory GetSharePanelCommand.fromRawJson(String str) => @@ -3248,19 +3751,28 @@ class GetSharePanelCommand { factory GetSharePanelCommand.fromJson(Map json) => GetSharePanelCommand( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - ServiceEndpointCommandMetadata.fromJson(json["commandMetadata"]), + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + commandMetadata: json["commandMetadata"] == null + ? null + : SubscribeCommandCommandMetadata.fromJson(json["commandMetadata"]), webPlayerShareEntityServiceEndpoint: - WebPlayerShareEntityServiceEndpoint.fromJson( - json["webPlayerShareEntityServiceEndpoint"]), + json["webPlayerShareEntityServiceEndpoint"] == null + ? null + : WebPlayerShareEntityServiceEndpoint.fromJson( + json["webPlayerShareEntityServiceEndpoint"]), ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "commandMetadata": + commandMetadata == null ? null : commandMetadata.toJson(), "webPlayerShareEntityServiceEndpoint": - webPlayerShareEntityServiceEndpoint.toJson(), + webPlayerShareEntityServiceEndpoint == null + ? null + : webPlayerShareEntityServiceEndpoint.toJson(), }; } @@ -3279,11 +3791,14 @@ class WebPlayerShareEntityServiceEndpoint { factory WebPlayerShareEntityServiceEndpoint.fromJson( Map json) => WebPlayerShareEntityServiceEndpoint( - serializedShareEntity: json["serializedShareEntity"], + serializedShareEntity: json["serializedShareEntity"] == null + ? null + : json["serializedShareEntity"], ); Map toJson() => { - "serializedShareEntity": serializedShareEntity, + "serializedShareEntity": + serializedShareEntity == null ? null : serializedShareEntity, }; } @@ -3295,7 +3810,7 @@ class RemoveFromWatchLaterCommand { }); final String clickTrackingParams; - final ServiceEndpointCommandMetadata commandMetadata; + final SubscribeCommandCommandMetadata commandMetadata; final RemoveFromWatchLaterCommandPlaylistEditEndpoint playlistEditEndpoint; factory RemoveFromWatchLaterCommand.fromRawJson(String str) => @@ -3305,18 +3820,25 @@ class RemoveFromWatchLaterCommand { factory RemoveFromWatchLaterCommand.fromJson(Map json) => RemoveFromWatchLaterCommand( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - ServiceEndpointCommandMetadata.fromJson(json["commandMetadata"]), - playlistEditEndpoint: - RemoveFromWatchLaterCommandPlaylistEditEndpoint.fromJson( + clickTrackingParams: json["clickTrackingParams"] == null + ? null + : json["clickTrackingParams"], + commandMetadata: json["commandMetadata"] == null + ? null + : SubscribeCommandCommandMetadata.fromJson(json["commandMetadata"]), + playlistEditEndpoint: json["playlistEditEndpoint"] == null + ? null + : RemoveFromWatchLaterCommandPlaylistEditEndpoint.fromJson( json["playlistEditEndpoint"]), ); Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), - "playlistEditEndpoint": playlistEditEndpoint.toJson(), + "clickTrackingParams": + clickTrackingParams == null ? null : clickTrackingParams, + "commandMetadata": + commandMetadata == null ? null : commandMetadata.toJson(), + "playlistEditEndpoint": + playlistEditEndpoint == null ? null : playlistEditEndpoint.toJson(), }; } @@ -3339,14 +3861,18 @@ class RemoveFromWatchLaterCommandPlaylistEditEndpoint { factory RemoveFromWatchLaterCommandPlaylistEditEndpoint.fromJson( Map json) => RemoveFromWatchLaterCommandPlaylistEditEndpoint( - playlistId: json["playlistId"], - actions: List.from( - json["actions"].map((x) => FluffyAction.fromJson(x))), + playlistId: json["playlistId"] == null ? null : json["playlistId"], + actions: json["actions"] == null + ? null + : List.from( + json["actions"].map((x) => FluffyAction.fromJson(x))), ); Map toJson() => { - "playlistId": playlistId, - "actions": List.from(actions.map((x) => x.toJson())), + "playlistId": playlistId == null ? null : playlistId, + "actions": actions == null + ? null + : List.from(actions.map((x) => x.toJson())), }; } @@ -3365,45 +3891,14 @@ class FluffyAction { String toRawJson() => json.encode(toJson()); factory FluffyAction.fromJson(Map json) => FluffyAction( - action: json["action"], - removedVideoId: json["removedVideoId"], + action: json["action"] == null ? null : json["action"], + removedVideoId: + json["removedVideoId"] == null ? null : json["removedVideoId"], ); Map toJson() => { - "action": action, - "removedVideoId": removedVideoId, - }; -} - -class SubscribeCommand { - SubscribeCommand({ - this.clickTrackingParams, - this.commandMetadata, - this.subscribeEndpoint, - }); - - final String clickTrackingParams; - final ServiceEndpointCommandMetadata commandMetadata; - final SubscribeEndpoint subscribeEndpoint; - - factory SubscribeCommand.fromRawJson(String str) => - SubscribeCommand.fromJson(json.decode(str)); - - String toRawJson() => json.encode(toJson()); - - factory SubscribeCommand.fromJson(Map json) => - SubscribeCommand( - clickTrackingParams: json["clickTrackingParams"], - commandMetadata: - ServiceEndpointCommandMetadata.fromJson(json["commandMetadata"]), - subscribeEndpoint: - SubscribeEndpoint.fromJson(json["subscribeEndpoint"]), - ); - - Map toJson() => { - "clickTrackingParams": clickTrackingParams, - "commandMetadata": commandMetadata.toJson(), - "subscribeEndpoint": subscribeEndpoint.toJson(), + "action": action == null ? null : action, + "removedVideoId": removedVideoId == null ? null : removedVideoId, }; } @@ -3423,19 +3918,25 @@ class ResponseContext { factory ResponseContext.fromJson(Map json) => ResponseContext( - serviceTrackingParams: List.from( - json["serviceTrackingParams"] + serviceTrackingParams: json["serviceTrackingParams"] == null + ? null + : List.from(json["serviceTrackingParams"] .map((x) => ServiceTrackingParam.fromJson(x))), webResponseContextExtensionData: - WebResponseContextExtensionData.fromJson( - json["webResponseContextExtensionData"]), + json["webResponseContextExtensionData"] == null + ? null + : WebResponseContextExtensionData.fromJson( + json["webResponseContextExtensionData"]), ); Map toJson() => { - "serviceTrackingParams": - List.from(serviceTrackingParams.map((x) => x.toJson())), + "serviceTrackingParams": serviceTrackingParams == null + ? null + : List.from(serviceTrackingParams.map((x) => x.toJson())), "webResponseContextExtensionData": - webResponseContextExtensionData.toJson(), + webResponseContextExtensionData == null + ? null + : webResponseContextExtensionData.toJson(), }; } @@ -3455,13 +3956,17 @@ class ServiceTrackingParam { factory ServiceTrackingParam.fromJson(Map json) => ServiceTrackingParam( - service: json["service"], - params: List.from(json["params"].map((x) => Param.fromJson(x))), + service: json["service"] == null ? null : json["service"], + params: json["params"] == null + ? null + : List.from(json["params"].map((x) => Param.fromJson(x))), ); Map toJson() => { - "service": service, - "params": List.from(params.map((x) => x.toJson())), + "service": service == null ? null : service, + "params": params == null + ? null + : List.from(params.map((x) => x.toJson())), }; } @@ -3479,13 +3984,13 @@ class Param { String toRawJson() => json.encode(toJson()); factory Param.fromJson(Map json) => Param( - key: json["key"], - value: json["value"], + key: json["key"] == null ? null : json["key"], + value: json["value"] == null ? null : json["value"], ); Map toJson() => { - "key": key, - "value": value, + "key": key == null ? null : key, + "value": value == null ? null : value, }; } @@ -3503,11 +4008,12 @@ class WebResponseContextExtensionData { factory WebResponseContextExtensionData.fromJson(Map json) => WebResponseContextExtensionData( - hasDecorated: json["hasDecorated"], + hasDecorated: + json["hasDecorated"] == null ? null : json["hasDecorated"], ); Map toJson() => { - "hasDecorated": hasDecorated, + "hasDecorated": hasDecorated == null ? null : hasDecorated, }; } @@ -3526,16 +4032,26 @@ class Storyboards { String toRawJson() => json.encode(toJson()); factory Storyboards.fromJson(Map json) => Storyboards( - playerStoryboardSpecRenderer: PlayerStoryboardSpecRenderer.fromJson( - json["playerStoryboardSpecRenderer"]), - playerLiveStoryboardSpecRenderer: PlayerStoryboardSpecRenderer.fromJson( - json["playerLiveStoryboardSpecRenderer"]), + playerStoryboardSpecRenderer: + json["playerStoryboardSpecRenderer"] == null + ? null + : PlayerStoryboardSpecRenderer.fromJson( + json["playerStoryboardSpecRenderer"]), + playerLiveStoryboardSpecRenderer: + json["playerLiveStoryboardSpecRenderer"] == null + ? null + : PlayerStoryboardSpecRenderer.fromJson( + json["playerLiveStoryboardSpecRenderer"]), ); Map toJson() => { - "playerStoryboardSpecRenderer": playerStoryboardSpecRenderer.toJson(), + "playerStoryboardSpecRenderer": playerStoryboardSpecRenderer == null + ? null + : playerStoryboardSpecRenderer.toJson(), "playerLiveStoryboardSpecRenderer": - playerLiveStoryboardSpecRenderer.toJson(), + playerLiveStoryboardSpecRenderer == null + ? null + : playerLiveStoryboardSpecRenderer.toJson(), }; } @@ -3553,11 +4069,11 @@ class PlayerStoryboardSpecRenderer { factory PlayerStoryboardSpecRenderer.fromJson(Map json) => PlayerStoryboardSpecRenderer( - spec: json["spec"], + spec: json["spec"] == null ? null : json["spec"], ); Map toJson() => { - "spec": spec, + "spec": spec == null ? null : spec, }; } @@ -3582,22 +4098,31 @@ class StreamingData { String toRawJson() => json.encode(toJson()); factory StreamingData.fromJson(Map json) => StreamingData( - expiresInSeconds: json["expiresInSeconds"], - formats: - List.from(json["formats"].map((x) => Format.fromJson(x))), - adaptiveFormats: List.from( - json["adaptiveFormats"].map((x) => Format.fromJson(x))), - dashManifestUrl: json["dashManifestUrl"], - hlsManifestUrl: json["hlsManifestUrl"], + expiresInSeconds: + json["expiresInSeconds"] == null ? null : json["expiresInSeconds"], + formats: json["formats"] == null + ? null + : List.from(json["formats"].map((x) => Format.fromJson(x))), + adaptiveFormats: json["adaptiveFormats"] == null + ? null + : List.from( + json["adaptiveFormats"].map((x) => Format.fromJson(x))), + dashManifestUrl: + json["dashManifestUrl"] == null ? null : json["dashManifestUrl"], + hlsManifestUrl: + json["hlsManifestUrl"] == null ? null : json["hlsManifestUrl"], ); Map toJson() => { - "expiresInSeconds": expiresInSeconds, - "formats": List.from(formats.map((x) => x.toJson())), - "adaptiveFormats": - List.from(adaptiveFormats.map((x) => x.toJson())), - "dashManifestUrl": dashManifestUrl, - "hlsManifestUrl": hlsManifestUrl, + "expiresInSeconds": expiresInSeconds == null ? null : expiresInSeconds, + "formats": formats == null + ? null + : List.from(formats.map((x) => x.toJson())), + "adaptiveFormats": adaptiveFormats == null + ? null + : List.from(adaptiveFormats.map((x) => x.toJson())), + "dashManifestUrl": dashManifestUrl == null ? null : dashManifestUrl, + "hlsManifestUrl": hlsManifestUrl == null ? null : hlsManifestUrl, }; } @@ -3619,6 +4144,8 @@ class Format { this.averageBitrate, this.approxDurationMs, this.signatureCipher, + this.url, + this.cipher, this.colorInfo, this.highReplication, this.audioQuality, @@ -3642,6 +4169,8 @@ class Format { final int averageBitrate; final String approxDurationMs; final String signatureCipher; + final String cipher; + final String url; final ColorInfo colorInfo; final bool highReplication; final String audioQuality; @@ -3653,9 +4182,9 @@ class Format { String toRawJson() => json.encode(toJson()); factory Format.fromJson(Map json) => Format( - itag: json["itag"], - mimeType: json["mimeType"], - bitrate: json["bitrate"], + itag: json["itag"] == null ? null : json["itag"], + mimeType: json["mimeType"] == null ? null : json["mimeType"], + bitrate: json["bitrate"] == null ? null : json["bitrate"], width: json["width"] == null ? null : json["width"], height: json["height"] == null ? null : json["height"], initRange: json["initRange"] == null @@ -3664,16 +4193,25 @@ class Format { indexRange: json["indexRange"] == null ? null : Range.fromJson(json["indexRange"]), - lastModified: json["lastModified"], - contentLength: json["contentLength"], - quality: json["quality"], + lastModified: + json["lastModified"] == null ? null : json["lastModified"], + contentLength: + json["contentLength"] == null ? null : json["contentLength"], + quality: json["quality"] == null ? null : json["quality"], fps: json["fps"] == null ? null : json["fps"], qualityLabel: json["qualityLabel"] == null ? null : json["qualityLabel"], - projectionType: projectionTypeValues.map[json["projectionType"]], - averageBitrate: json["averageBitrate"], - approxDurationMs: json["approxDurationMs"], - signatureCipher: json["signatureCipher"], + projectionType: json["projectionType"] == null + ? null + : projectionTypeValues.map[json["projectionType"]], + averageBitrate: + json["averageBitrate"] == null ? null : json["averageBitrate"], + approxDurationMs: + json["approxDurationMs"] == null ? null : json["approxDurationMs"], + signatureCipher: + json["signatureCipher"] == null ? null : json["signatureCipher"], + cipher: json["cipher"] == null ? null : json["cipher"], + url: json["url"] == null ? null : json["url"], colorInfo: json["colorInfo"] == null ? null : ColorInfo.fromJson(json["colorInfo"]), @@ -3688,22 +4226,26 @@ class Format { ); Map toJson() => { - "itag": itag, - "mimeType": mimeType, - "bitrate": bitrate, + "itag": itag == null ? null : itag, + "mimeType": mimeType == null ? null : mimeType, + "bitrate": bitrate == null ? null : bitrate, "width": width == null ? null : width, "height": height == null ? null : height, "initRange": initRange == null ? null : initRange.toJson(), "indexRange": indexRange == null ? null : indexRange.toJson(), - "lastModified": lastModified, - "contentLength": contentLength, - "quality": quality, + "lastModified": lastModified == null ? null : lastModified, + "contentLength": contentLength == null ? null : contentLength, + "quality": quality == null ? null : quality, "fps": fps == null ? null : fps, "qualityLabel": qualityLabel == null ? null : qualityLabel, - "projectionType": projectionTypeValues.reverse[projectionType], - "averageBitrate": averageBitrate, - "approxDurationMs": approxDurationMs, - "signatureCipher": signatureCipher, + "projectionType": projectionType == null + ? null + : projectionTypeValues.reverse[projectionType], + "averageBitrate": averageBitrate == null ? null : averageBitrate, + "approxDurationMs": approxDurationMs == null ? null : approxDurationMs, + "signatureCipher": signatureCipher == null ? null : signatureCipher, + "url": url == null ? null : url, + "cipher": cipher == null ? null : cipher, "colorInfo": colorInfo == null ? null : colorInfo.toJson(), "highReplication": highReplication == null ? null : highReplication, "audioQuality": audioQuality == null ? null : audioQuality, @@ -3729,19 +4271,27 @@ class ColorInfo { String toRawJson() => json.encode(toJson()); factory ColorInfo.fromJson(Map json) => ColorInfo( - primaries: primariesValues.map[json["primaries"]], - transferCharacteristics: - transferCharacteristicsValues.map[json["transferCharacteristics"]], - matrixCoefficients: - matrixCoefficientsValues.map[json["matrixCoefficients"]], + primaries: json["primaries"] == null + ? null + : primariesValues.map[json["primaries"]], + transferCharacteristics: json["transferCharacteristics"] == null + ? null + : transferCharacteristicsValues + .map[json["transferCharacteristics"]], + matrixCoefficients: json["matrixCoefficients"] == null + ? null + : matrixCoefficientsValues.map[json["matrixCoefficients"]], ); Map toJson() => { - "primaries": primariesValues.reverse[primaries], - "transferCharacteristics": - transferCharacteristicsValues.reverse[transferCharacteristics], - "matrixCoefficients": - matrixCoefficientsValues.reverse[matrixCoefficients], + "primaries": + primaries == null ? null : primariesValues.reverse[primaries], + "transferCharacteristics": transferCharacteristics == null + ? null + : transferCharacteristicsValues.reverse[transferCharacteristics], + "matrixCoefficients": matrixCoefficients == null + ? null + : matrixCoefficientsValues.reverse[matrixCoefficients], }; } @@ -3778,13 +4328,13 @@ class Range { String toRawJson() => json.encode(toJson()); factory Range.fromJson(Map json) => Range( - start: json["start"], - end: json["end"], + start: json["start"] == null ? null : json["start"], + end: json["end"] == null ? null : json["end"], ); Map toJson() => { - "start": start, - "end": end, + "start": start == null ? null : start, + "end": end == null ? null : end, }; } @@ -3848,53 +4398,80 @@ class VideoDetails { String toRawJson() => json.encode(toJson()); factory VideoDetails.fromJson(Map json) => VideoDetails( - videoId: json["videoId"], - title: json["title"], - lengthSeconds: json["lengthSeconds"], - keywords: List.from(json["keywords"].map((x) => x)), - channelId: json["channelId"], - isOwnerViewing: json["isOwnerViewing"], - shortDescription: json["shortDescription"], - isCrawlable: json["isCrawlable"], - thumbnail: IconClass.fromJson(json["thumbnail"]), - averageRating: json["averageRating"].toDouble(), - allowRatings: json["allowRatings"], - viewCount: json["viewCount"], - author: json["author"], - isPrivate: json["isPrivate"], - isUnpluggedCorpus: json["isUnpluggedCorpus"], - isLiveContent: json["isLiveContent"], - isLive: json["isLive"], - isLiveDvrEnabled: json["isLiveDvrEnabled"], - liveChunkReadahead: json["liveChunkReadahead"], - isLiveDefaultBroadcast: json["isLiveDefaultBroadcast"], - isLowLatencyLiveStream: json["isLowLatencyLiveStream"], - latencyClass: json["latencyClass"], + videoId: json["videoId"] == null ? null : json["videoId"], + title: json["title"] == null ? null : json["title"], + lengthSeconds: + json["lengthSeconds"] == null ? null : json["lengthSeconds"], + keywords: json["keywords"] == null + ? null + : List.from(json["keywords"].map((x) => x)), + channelId: json["channelId"] == null ? null : json["channelId"], + isOwnerViewing: + json["isOwnerViewing"] == null ? null : json["isOwnerViewing"], + shortDescription: + json["shortDescription"] == null ? null : json["shortDescription"], + isCrawlable: json["isCrawlable"] == null ? null : json["isCrawlable"], + thumbnail: json["thumbnail"] == null + ? null + : IconClass.fromJson(json["thumbnail"]), + averageRating: json["averageRating"] == null + ? null + : json["averageRating"].toDouble(), + allowRatings: + json["allowRatings"] == null ? null : json["allowRatings"], + viewCount: json["viewCount"] == null ? null : json["viewCount"], + author: json["author"] == null ? null : json["author"], + isPrivate: json["isPrivate"] == null ? null : json["isPrivate"], + isUnpluggedCorpus: json["isUnpluggedCorpus"] == null + ? null + : json["isUnpluggedCorpus"], + isLiveContent: + json["isLiveContent"] == null ? null : json["isLiveContent"], + isLive: json["isLive"] == null ? null : json["isLive"], + isLiveDvrEnabled: + json["isLiveDvrEnabled"] == null ? null : json["isLiveDvrEnabled"], + liveChunkReadahead: json["liveChunkReadahead"] == null + ? null + : json["liveChunkReadahead"], + isLiveDefaultBroadcast: json["isLiveDefaultBroadcast"] == null + ? null + : json["isLiveDefaultBroadcast"], + isLowLatencyLiveStream: json["isLowLatencyLiveStream"] == null + ? null + : json["isLowLatencyLiveStream"], + latencyClass: + json["latencyClass"] == null ? null : json["latencyClass"], ); Map toJson() => { - "videoId": videoId, - "title": title, - "lengthSeconds": lengthSeconds, - "keywords": List.from(keywords.map((x) => x)), - "channelId": channelId, - "isOwnerViewing": isOwnerViewing, - "shortDescription": shortDescription, - "isCrawlable": isCrawlable, - "thumbnail": thumbnail.toJson(), - "averageRating": averageRating, - "allowRatings": allowRatings, - "viewCount": viewCount, - "author": author, - "isPrivate": isPrivate, - "isUnpluggedCorpus": isUnpluggedCorpus, - "isLiveContent": isLiveContent, - "isLive": isLive, - "isLiveDvrEnabled": isLiveDvrEnabled, - "liveChunkReadahead": liveChunkReadahead, - "isLiveDefaultBroadcast": isLiveDefaultBroadcast, - "isLowLatencyLiveStream": isLowLatencyLiveStream, - "latencyClass": latencyClass, + "videoId": videoId == null ? null : videoId, + "title": title == null ? null : title, + "lengthSeconds": lengthSeconds == null ? null : lengthSeconds, + "keywords": keywords == null + ? null + : List.from(keywords.map((x) => x)), + "channelId": channelId == null ? null : channelId, + "isOwnerViewing": isOwnerViewing == null ? null : isOwnerViewing, + "shortDescription": shortDescription == null ? null : shortDescription, + "isCrawlable": isCrawlable == null ? null : isCrawlable, + "thumbnail": thumbnail == null ? null : thumbnail.toJson(), + "averageRating": averageRating == null ? null : averageRating, + "allowRatings": allowRatings == null ? null : allowRatings, + "viewCount": viewCount == null ? null : viewCount, + "author": author == null ? null : author, + "isPrivate": isPrivate == null ? null : isPrivate, + "isUnpluggedCorpus": + isUnpluggedCorpus == null ? null : isUnpluggedCorpus, + "isLiveContent": isLiveContent == null ? null : isLiveContent, + "isLive": isLive == null ? null : isLive, + "isLiveDvrEnabled": isLiveDvrEnabled == null ? null : isLiveDvrEnabled, + "liveChunkReadahead": + liveChunkReadahead == null ? null : liveChunkReadahead, + "isLiveDefaultBroadcast": + isLiveDefaultBroadcast == null ? null : isLiveDefaultBroadcast, + "isLowLatencyLiveStream": + isLowLatencyLiveStream == null ? null : isLowLatencyLiveStream, + "latencyClass": latencyClass == null ? null : latencyClass, }; } diff --git a/lib/src/reverse_engineering/responses/player_response.dart b/lib/src/reverse_engineering/responses/player_response.dart index 29015c3..f410760 100644 --- a/lib/src/reverse_engineering/responses/player_response.dart +++ b/lib/src/reverse_engineering/responses/player_response.dart @@ -1,14 +1,18 @@ import 'dart:convert'; import 'package:http_parser/http_parser.dart'; +import 'package:youtube_explode_dart/src/reverse_engineering/responses/generated/player_response.g.dart'; import '../../extensions/helpers_extension.dart'; import 'stream_info_provider.dart'; /// class PlayerResponse { - // Json parsed map - final Map _root; + // Json parsed class + PlayerResponseJson _root; + + /// Json parsed map + final Map _rawJson; Iterable _muxedStreams; Iterable _adaptiveStreams; @@ -17,7 +21,7 @@ class PlayerResponse { String _videoPlayabilityError; /// - String get playabilityStatus => _root['playabilityStatus']['status']; + String get playabilityStatus => _root.playabilityStatus.status; /// bool get isVideoAvailable => playabilityStatus.toLowerCase() != 'error'; @@ -26,41 +30,41 @@ class PlayerResponse { bool get isVideoPlayable => playabilityStatus.toLowerCase() == 'ok'; /// - String get videoTitle => _root['videoDetails']['title']; + String get videoTitle => _root.videoDetails.title; /// - String get videoAuthor => _root['videoDetails']['author']; + String get videoAuthor => _root.videoDetails.author; /// - DateTime get videoUploadDate => DateTime.parse( - _root['microformat']['playerMicroformatRenderer']['uploadDate']); + DateTime get videoUploadDate => + _root.microformat.playerMicroformatRenderer.uploadDate; /// - String get videoChannelId => _root['videoDetails']['channelId']; + String get videoChannelId => _root.videoDetails.channelId; /// Duration get videoDuration => - Duration(seconds: int.parse(_root['videoDetails']['lengthSeconds'])); + Duration(seconds: int.parse(_root.videoDetails.lengthSeconds)); /// - Iterable get videoKeywords => - _root['videoDetails']['keywords']?.cast() ?? const []; + List get videoKeywords => _root.videoDetails.keywords ?? const []; /// - String get videoDescription => _root['videoDetails']['shortDescription']; + String get videoDescription => _root.videoDetails.shortDescription; /// - int get videoViewCount => int.parse(_root['videoDetails']['viewCount']); + int get videoViewCount => int.parse(_root.videoDetails.viewCount); + //TODO: Get these types /// // Can be null String get previewVideoId => - _root + _rawJson .get('playabilityStatus') ?.get('errorScreen') ?.get('playerLegacyDesktopYpcTrailerRenderer') ?.getValue('trailerVideoId') ?? - Uri.splitQueryString(_root + Uri.splitQueryString(_rawJson .get('playabilityStatus') ?.get('errorScreen') ?.get('') @@ -69,75 +73,70 @@ class PlayerResponse { '')['video_id']; /// - bool get isLive => _root.get('videoDetails')?.getValue('isLive') ?? false; + bool get isLive => _root.videoDetails.isLive ?? false; /// // Can be null - String get hlsManifestUrl => - _root.get('streamingData')?.getValue('hlsManifestUrl'); + String get hlsManifestUrl => _root.streamingData?.hlsManifestUrl; /// // Can be null - String get dashManifestUrl => - _root.get('streamingData')?.getValue('dashManifestUrl'); + String get dashManifestUrl => _root.streamingData?.dashManifestUrl; /// - Iterable get muxedStreams => _muxedStreams ??= _root - ?.get('streamingData') - ?.getValue('formats') - ?.map((e) => _StreamInfo(e)) - ?.cast() ?? - const []; + List get muxedStreams => + _muxedStreams ??= _root.streamingData?.formats + ?.map((e) => _StreamInfo(e)) + ?.cast() + ?.toList() ?? + const []; /// - Iterable get adaptiveStreams => _adaptiveStreams ??= _root - ?.get('streamingData') - ?.getValue('adaptiveFormats') - ?.map((e) => _StreamInfo(e)) - ?.cast() ?? - const []; + List get adaptiveStreams => + _adaptiveStreams ??= _root.streamingData?.adaptiveFormats + ?.map((e) => _StreamInfo(e)) + ?.cast() + ?.toList() ?? + const []; /// List get streams => _streams ??= [...muxedStreams, ...adaptiveStreams]; /// - Iterable get closedCaptionTrack => - _closedCaptionTrack ??= _root - .get('captions') - ?.get('playerCaptionsTracklistRenderer') - ?.getValue('captionTracks') + List get closedCaptionTrack => _closedCaptionTrack ??= + _root.captions?.playerCaptionsTracklistRenderer?.captionTracks ?.map((e) => ClosedCaptionTrack(e)) - ?.cast() ?? + ?.cast() + ?.toList() ?? const []; - /// - PlayerResponse(this._root); + /// Can be null + String getVideoPlayabilityError() => + _videoPlayabilityError ??= _root.playabilityStatus.reason; /// - String getVideoPlayabilityError() => _videoPlayabilityError ??= - _root.get('playabilityStatus')?.getValue('reason'); - - /// - PlayerResponse.parse(String raw) : _root = json.decode(raw); + PlayerResponse.parse(String raw) : _rawJson = json.decode(raw) { + _root = PlayerResponseJson.fromJson(_rawJson); + } } /// class ClosedCaptionTrack { - // Json parsed map - final Map _root; + // Json parsed class + final CaptionTrack _root; /// - String get url => _root['baseUrl']; + String get url => _root.baseUrl; /// - String get languageCode => _root['languageCode']; + String get languageCode => _root.languageCode; /// - String get languageName => _root['name']['simpleText']; + String get languageName => _root.name.simpleText; /// - bool get autoGenerated => _root['vssId'].toLowerCase().startsWith('a.'); + bool get autoGenerated => _root.vssId.toLowerCase().startsWith('a.'); /// ClosedCaptionTrack(this._root); @@ -146,8 +145,8 @@ class ClosedCaptionTrack { class _StreamInfo extends StreamInfoProvider { static final _contentLenExp = RegExp(r'[\?&]clen=(\d+)'); - // Json parsed map - final Map _root; + // Json parsed class + final Format _root; int _bitrate; String _container; @@ -159,38 +158,38 @@ class _StreamInfo extends StreamInfoProvider { String _url; @override - int get bitrate => _bitrate ??= _root['bitrate']; + int get bitrate => _bitrate ??= _root.bitrate; @override String get container => _container ??= mimeType.subtype; @override int get contentLength => - _contentLength ??= int.tryParse(_root['contentLength'] ?? '') ?? + _contentLength ??= int.tryParse(_root.contentLength ?? '') ?? _contentLenExp.firstMatch(url)?.group(1); @override - int get framerate => _framerate ??= _root['fps']; + int get framerate => _framerate ??= _root.fps; @override String get signature => - _signature ??= Uri.splitQueryString(_root['signatureCipher'] ?? '')['s']; + _signature ??= Uri.splitQueryString(_root.signatureCipher ?? '')['s']; @override - String get signatureParameter => _signatureParameter ??= - Uri.splitQueryString(_root['cipher'] ?? '')['sp'] ?? - Uri.splitQueryString(_root['signatureCipher'] ?? '')['sp']; + String get signatureParameter => + _signatureParameter ??= Uri.splitQueryString(_root.cipher ?? '')['sp'] ?? + Uri.splitQueryString(_root.signatureCipher ?? '')['sp']; @override - int get tag => _tag ??= _root['itag']; + int get tag => _tag ??= _root.itag; @override String get url => _url ??= _getUrl(); String _getUrl() { - var url = _root['url']; - url ??= Uri.splitQueryString(_root['cipher'] ?? '')['url']; - url ??= Uri.splitQueryString(_root['signatureCipher'] ?? '')['url']; + var url = _root.url; + url ??= Uri.splitQueryString(_root.cipher ?? '')['url']; + url ??= Uri.splitQueryString(_root.signatureCipher ?? '')['url']; return url; } @@ -203,17 +202,17 @@ class _StreamInfo extends StreamInfoProvider { isAudioOnly ? null : codecs.split(',').first.trim().nullIfWhitespace; @override - int get videoHeight => _root['height']; + int get videoHeight => _root.height; @override - String get videoQualityLabel => _root['qualityLabel']; + String get videoQualityLabel => _root.qualityLabel; @override - int get videoWidth => _root['width']; + int get videoWidth => _root.width; bool get isAudioOnly => _isAudioOnly ??= mimeType.type == 'audio'; - MediaType get mimeType => _mimeType ??= MediaType.parse(_root['mimeType']); + MediaType get mimeType => _mimeType ??= MediaType.parse(_root.mimeType); String get codecs => _codecs ??= mimeType?.parameters['codecs']?.toLowerCase();