Skip to content

Commit

Permalink
feat(lib): update video class member nullability
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Oct 28, 2024
1 parent 596c3bc commit 8cecf09
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 60 deletions.
53 changes: 26 additions & 27 deletions lib/src/types/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ class Video {
final String videoId;

/// When a video was created, presented in ISO-8601 format.
final DateTime? createdAt;
final DateTime createdAt;

/// The title of the video content.
final String? title;
final String title;

/// The description for the video content.
final String? description;
final String description;

/// The date and time the API created the video. Date and time are provided using ISO-8601 UTC format.
final String? publishedAt;
final String publishedAt;

/// The date and time the video was updated. Date and time are provided using ISO-8601 UTC format.
final DateTime? updatedAt;
final DateTime updatedAt;

/// The date and time the video was discarded.
final DateTime? discardedAt;
Expand All @@ -62,7 +62,7 @@ class Video {
final DateTime? deletesAt;

/// Returns `true` for videos you discarded.
final bool? discarded;
final bool discarded;

/// Returns the language of a video in [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format.
@_JsonLocaleConverter()
Expand All @@ -72,50 +72,49 @@ class Video {
final LanguageOrigin? languageOrigin;

/// One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces.
final List<String>? tags;
final List<String> tags;

/// Metadata you can use to categorise and filter videos. Metadata is a list of dictionaries, where each dictionary represents a key value pair for categorising a video. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair.
final List<Metadata>? metadata;
final List<Metadata> metadata;

/// The source information about the video.
final VideoSource? source;
final VideoSource source;

/// The details about the video object that you can use to work with the video object.
final VideoAssets? assets;
final VideoAssets assets;

/// The id of the player that will be applied on the video.
final String? playerId;

/// Defines if the content is publicly reachable or if a unique token is needed for each play session. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos).
@JsonKey(name: '_public')
final bool? public;
final bool public;

/// Defines if video is panoramic.
final bool? panoramic;
final bool panoramic;

/// This lets you know whether mp4 is supported. If enabled, an mp4 URL will be provided in the response for the video.
final bool? mp4Support;
final bool mp4Support;

/// Creates a [Video].
const Video(this.videoId,
{this.createdAt,
this.title,
this.description,
this.publishedAt,
this.updatedAt,
{required this.createdAt,
required this.title,
required this.description,
required this.publishedAt,
required this.updatedAt,
this.discardedAt,
this.deletesAt,
this.discarded,
required this.discarded,
this.language,
this.languageOrigin,
this.tags,
this.metadata,
this.source,
this.assets,
required this.tags,
required this.metadata,
required this.source,
required this.assets,
this.playerId,
this.public,
this.panoramic,
this.mp4Support});
required this.public,
required this.panoramic,
required this.mp4Support});

/// Creates a [Video] from a [json] map.
factory Video.fromJson(Map<String, dynamic> json) => _$VideoFromJson(json);
Expand Down
43 changes: 17 additions & 26 deletions lib/src/types/video.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 26 additions & 7 deletions test/video_uploader_mobile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ void main() {
const MethodChannel channel = const MethodChannel('video.api.uploader');
ApiVideoUploaderPlatform.instance = ApiVideoMobileUploaderPlugin();

Video _createDummyVideo(String videoId) {
return Video(videoId,
createdAt: DateTime.now(),
title: "Title",
description: "Description",
publishedAt: DateTime.now(),
updatedAt: DateTime.now(),
discarded: false,
tags: [],
metadata: [],
source: VideoSource(),
assets: VideoAssets(),
public: false,
panoramic: false,
mp4Support: false,
);
}

test('setEnvironment', () async {
final environment = Environment.sandbox;
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
Expand Down Expand Up @@ -57,7 +75,7 @@ void main() {
expect(null, isNot(methodCall.arguments["uploadId"]));
expect(methodCall.arguments["videoId"], videoId);
expect(methodCall.arguments["filePath"], filePath);
return jsonEncode(Video(videoId).toJson());
return jsonEncode(_createDummyVideo(videoId).toJson());
} else {
fail("Method not expected: ${methodCall.method}");
}
Expand All @@ -78,7 +96,7 @@ void main() {
expect(null, isNot(methodCall.arguments["uploadId"]));
expect(methodCall.arguments["token"], token);
expect(methodCall.arguments["filePath"], filePath);
return jsonEncode(Video(videoId).toJson());
return jsonEncode(_createDummyVideo(videoId).toJson());
} else {
fail("Method not expected: ${methodCall.method}");
}
Expand All @@ -96,7 +114,7 @@ void main() {
return null;
} else if (methodCall.method == "uploadWithUploadToken") {
expect(null, isNot(methodCall.arguments["uploadId"]));
return jsonEncode(Video(videoId).toJson());
return jsonEncode(_createDummyVideo(videoId).toJson());
} else {
fail("Method not expected: ${methodCall.method}");
}
Expand Down Expand Up @@ -131,7 +149,7 @@ void main() {
expect(null, isNot(methodCall.arguments["uploadId"]));
expect(methodCall.arguments["sessionId"], sessionId);
expect(methodCall.arguments["filePath"], filePath);
return jsonEncode(Video(videoId).toJson());
return jsonEncode(_createDummyVideo(videoId).toJson());
} else {
fail("Method not expected: ${methodCall.method}");
}
Expand All @@ -148,7 +166,7 @@ void main() {
expect(null, isNot(methodCall.arguments["uploadId"]));
expect(methodCall.arguments["sessionId"], sessionId);
expect(methodCall.arguments["filePath"], filePath);
return jsonEncode(Video(videoId).toJson());
return jsonEncode(_createDummyVideo(videoId).toJson());
} else {
fail("Method not expected: ${methodCall.method}");
}
Expand Down Expand Up @@ -184,7 +202,7 @@ void main() {
expect(null, isNot(methodCall.arguments["uploadId"]));
expect(methodCall.arguments["sessionId"], sessionId);
expect(methodCall.arguments["filePath"], filePath);
return jsonEncode(Video(videoId).toJson());
return jsonEncode(_createDummyVideo(videoId).toJson());
} else {
fail("Method not expected: ${methodCall.method}");
}
Expand All @@ -201,11 +219,12 @@ void main() {
expect(null, isNot(methodCall.arguments["uploadId"]));
expect(methodCall.arguments["sessionId"], sessionId);
expect(methodCall.arguments["filePath"], filePath);
return jsonEncode(Video(videoId).toJson());
return jsonEncode(_createDummyVideo(videoId).toJson());
} else {
fail("Method not expected: ${methodCall.method}");
}
});
expect((await session.uploadLastPart(filePath)).videoId, videoId);
});

}

0 comments on commit 8cecf09

Please sign in to comment.