Skip to content

Commit f3ec86a

Browse files
authored
Merge pull request #483 from vimeo/subfolders
Support for subfolders
2 parents 129809b + 898c331 commit f3ec86a

File tree

12 files changed

+158
-92
lines changed

12 files changed

+158
-92
lines changed

models/detekt_baseline.xml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,6 @@
153153
<ID>UndocumentedPublicProperty:FeedItem.kt$FeedItem$/** * Video associated with ths feed item. */ @Json(name = "clip") val video: Video? = null</ID>
154154
<ID>UndocumentedPublicProperty:FeedItemConnections.kt$FeedItemConnections$/** * A list of resource URIs related to the activity. */ @Json(name = "related") val related: BasicConnection? = null</ID>
155155
<ID>UndocumentedPublicProperty:FileTransferPage.kt$FileTransferPage$/** * The link to the file transfer page. */ @Internal @Json(name = "link") val link: String? = null</ID>
156-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The Slack integration channel for the folder. */ @Json(name = "slack_integration_channel") val slackIntegrationChannel: String? = null</ID>
157-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The Slack webhook ID for the folder. */ @Json(name = "slack_incoming_webhooks_id") val slackIncomingWebhooksId: String? = null</ID>
158-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The [FolderPrivacy] that defines the public visibility of the folder. */ @Json(name = "privacy") val privacy: FolderPrivacy? = null</ID>
159-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The folder's canonical relative URI. */ @Json(name = "uri") val uri: String? = null</ID>
160-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The folder's metadata. */ @Json(name = "metadata") val metadata: Metadata&lt;FolderConnections, BasicInteraction&gt;? = null</ID>
161-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The folder's owner. */ @Json(name = "user") val user: User? = null</ID>
162-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The language preference for Slack notifications about the folder. * @see slackLanguagePreferenceType */ @Json(name = "slack_language_preference") val slackLanguagePreference: String? = null</ID>
163-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The link to the folder on Vimeo. */ @Json(name = "link") val link: String? = null</ID>
164-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The name of the folder. */ @Json(name = "name") val name: String? = null</ID>
165-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The resource key string of the folder. */ @Json(name = "resource_key") val resourceKey: String? = null</ID>
166-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The time in ISO 8601 format when a user last performed an action on the folder. */ @Json(name = "last_user_action_event_date") val lastUserActionEventDate: Date? = null</ID>
167-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The time in ISO 8601 format when the folder was created. */ @Json(name = "created_time") val createdDate: Date? = null</ID>
168-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * The time in ISO 8601 format when the folder was last modified. */ @Json(name = "modified_time") val lastModifiedDate: Date? = null</ID>
169-
<ID>UndocumentedPublicProperty:Folder.kt$Folder$/** * User preferences for Slack notifications about the folder. * @see slackUserPreferenceType */ @Json(name = "slack_user_preferences") val slackUserPreference: String? = null</ID>
170-
<ID>UndocumentedPublicProperty:FolderConnections.kt$FolderConnections$/** * A basic connection object indicating how to return all the project items in the folder. */ @Json(name = "items") val items: BasicConnection? = null</ID>
171-
<ID>UndocumentedPublicProperty:FolderConnections.kt$FolderConnections$/** * A basic connection object indicating how to return all the sub-folders in the folder. */ @Json(name = "folders") val folders: BasicConnection? = null</ID>
172-
<ID>UndocumentedPublicProperty:FolderConnections.kt$FolderConnections$/** * A basic connection object indicating how to return all the videos in the folder. */ @Json(name = "videos") val videos: BasicConnection? = null</ID>
173-
<ID>UndocumentedPublicProperty:FolderConnections.kt$FolderConnections$/** * Information about the authenticated user's team. */ @Json(name = "team_members") val teamMembers: BasicConnection? = null</ID>
174156
<ID>UndocumentedPublicProperty:FolderPrivacy.kt$FolderPrivacy$/** * Who can view the folder. * @see FolderPrivacy.viewPrivacyType */ @Json(name = "view") val viewPrivacy: String? = null</ID>
175157
<ID>UndocumentedPublicProperty:Followable.kt$Followable$val metadata: Metadata&lt;*, out FollowableInteractions&gt;?</ID>
176158
<ID>UndocumentedPublicProperty:Gcs.kt$Gcs$/** * Expected ending byte range for the current upload_link. */ @Internal @Json(name = "end_byte") val endByte: Long? = null</ID>
@@ -494,19 +476,6 @@
494476
<ID>UndocumentedPublicProperty:TeamBranding.kt$TeamBranding$/** * The hexadecimal color code for the accent color of the team. */ @Json(name = "accent_color") val acccentColor: String? = null</ID>
495477
<ID>UndocumentedPublicProperty:TeamBranding.kt$TeamBranding$/** * The name of the team. */ @Json(name = "team_name") val name: String? = null</ID>
496478
<ID>UndocumentedPublicProperty:TeamBranding.kt$TeamBranding$/** * The team's URI. */ @Json(name = "uri") val uri: String? = null</ID>
497-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * A localized string for display purposes that names the user's role on the team. * @see role */ @Json(name = "role") val localizedRole: String? = null</ID>
498-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The URI to independently request this team membership information. */ @Json(name = "uri") val uri: String? = null</ID>
499-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The URL for the invited user to join the team. * The value of this field is null if the invited user has already joined. * (e.g. https://vimeo.com/user/seat?code=e7c71ae7f4dc5d71a3bceb4d1d9e) */ @Json(name = "invite_url") val inviteUrl: String? = null</ID>
500-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The resource key that identifies team membership. */ @Json(name = "resource_key") val resourceKey: String? = null</ID>
501-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The status of the user's team membership. * @see TeamMembership.teamInviteStatusType */ @Json(name = "status") val teamInviteStatus: String? = null</ID>
502-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The team member's email. */ @Json(name = "email") val email: String? = null</ID>
503-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The team member. The value of this field is null if the user hasn't joined the team yet. */ @Json(name = "user") val user: User? = null</ID>
504-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The team membership metadata. */ @Json(name = "metadata") val metadata: Metadata&lt;TeamMembershipConnections, BasicInteraction&gt;? = null</ID>
505-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The time in ISO 8601 format at which the invite was accepted. */ @Json(name = "joined_time") val joinedTime: Date? = null</ID>
506-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The time in ISO 8601 format at which the invite was sent. */ @Json(name = "created_time") val createdTime: Date? = null</ID>
507-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The time in ISO 8601 format at which the team membership was last modified. */ @Json(name = "modified_time") val modifiedTime: Date? = null</ID>
508-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * The user's role on the team. * @see TeamMembership.roleType */ @Json(name = "permission_level") val role: String? = null</ID>
509-
<ID>UndocumentedPublicProperty:TeamMembership.kt$TeamMembership$/** * Whether the team member has folder access. */ @Json(name = "has_folder_access") val hasFolderAccess: Boolean? = null</ID>
510479
<ID>UndocumentedPublicProperty:TeamMembershipConnections.kt$TeamMembershipConnections$/** * A connection object indicating how to get the owner of this user. */ @Json(name = "owner") val owner: TeamOwnerConnection? = null</ID>
511480
<ID>UndocumentedPublicProperty:TeamOwnerConnection.kt$TeamOwnerConnection$/** * The team owner's display name. */ @Json(name = "display_name") val displayName: String? = null</ID>
512481
<ID>UndocumentedPublicProperty:TeamOwnerConnection.kt$TeamOwnerConnection$/** * The total number of owners on this connection. */ @Json(name = "total") val total: Int? = null</ID>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.vimeo.networking2
2+
3+
import com.squareup.moshi.Json
4+
import com.squareup.moshi.JsonClass
5+
import com.vimeo.networking2.common.Interaction
6+
7+
/**
8+
* The interaction for adding a subfolder to a parent folder.
9+
*
10+
* @param canAddSubfolders Whether the folder can contain a subfolder.
11+
* @param contentType The content type.
12+
* @param subfolderDepthLimitReached Whether the user has reached the maximum subfolder depth.
13+
*/
14+
@JsonClass(generateAdapter = true)
15+
data class AddSubfolderInteraction(
16+
17+
@Json(name = "can_add_subfolders")
18+
val canAddSubfolders: Boolean? = null,
19+
20+
@Json(name = "content_type")
21+
val contentType: String? = null,
22+
23+
@Json(name = "subfolder_depth_limit_reached")
24+
val subfolderDepthLimitReached: Boolean? = null,
25+
26+
@Json(name = "options")
27+
override val options: List<String>? = null,
28+
29+
@Json(name = "uri")
30+
override val uri: String? = null
31+
) : Interaction
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.vimeo.networking2
2+
3+
import com.squareup.moshi.Json
4+
import com.squareup.moshi.JsonClass
5+
import com.vimeo.networking2.common.Connection
6+
7+
/**
8+
* The default implementation of a connection that does not add any other properties.
9+
*/
10+
@JsonClass(generateAdapter = true)
11+
data class DefaultConnection(
12+
13+
@Json(name = "options")
14+
override val options: List<String>? = null,
15+
16+
@Json(name = "uri")
17+
override val uri: String? = null
18+
) : Connection

models/src/main/java/com/vimeo/networking2/Folder.kt

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,93 +13,65 @@ import java.util.Date
1313
/**
1414
* A folder that acts as a container for a list of [Videos][Video] that can be fetched via
1515
* a uri defined in [Metadata.connections].
16+
*
17+
* @param createdDate The time in ISO 8601 format when the folder was created.
18+
* @param lastUserActionEventDate The time in ISO 8601 format when a user last performed an action on the folder.
19+
* @param link The link to the folder on Vimeo.
20+
* @param metadata The folder's metadata.
21+
* @param lastModifiedDate The time in ISO 8601 format when the folder was last modified.
22+
* @param name The name of the folder.
23+
* @param privacy The [FolderPrivacy] that defines the public visibility of the folder.
24+
* @param resourceKey The resource key string of the folder.
25+
* @param slackIncomingWebhooksId The Slack webhook ID for the folder.
26+
* @param slackIntegrationChannel The Slack integration channel for the folder.
27+
* @param slackLanguagePreference The language preference for Slack notifications about the folder. See
28+
* [slackLanguagePreferenceType].
29+
* @param slackUserPreference User preferences for Slack notifications about the folder. See [slackUserPreferenceType].
30+
* @param uri The folder's canonical relative URI.
31+
* @param user The folder's owner.
1632
*/
1733
@JsonClass(generateAdapter = true)
1834
data class Folder(
1935

20-
/**
21-
* The time in ISO 8601 format when the folder was created.
22-
*/
2336
@Json(name = "created_time")
2437
val createdDate: Date? = null,
2538

26-
/**
27-
* The time in ISO 8601 format when a user last performed an action on the folder.
28-
*/
2939
@Json(name = "last_user_action_event_date")
3040
val lastUserActionEventDate: Date? = null,
3141

32-
/**
33-
* The link to the folder on Vimeo.
34-
*/
3542
@Json(name = "link")
3643
val link: String? = null,
3744

38-
/**
39-
* The folder's metadata.
40-
*/
4145
@Json(name = "metadata")
42-
val metadata: Metadata<FolderConnections, BasicInteraction>? = null,
46+
val metadata: Metadata<FolderConnections, FolderInteractions>? = null,
4347

44-
/**
45-
* The time in ISO 8601 format when the folder was last modified.
46-
*/
4748
@Json(name = "modified_time")
4849
val lastModifiedDate: Date? = null,
4950

50-
/**
51-
* The name of the folder.
52-
*/
5351
@Json(name = "name")
5452
val name: String? = null,
5553

56-
/**
57-
* The [FolderPrivacy] that defines the public visibility of the folder.
58-
*/
5954
@Json(name = "privacy")
6055
val privacy: FolderPrivacy? = null,
6156

62-
/**
63-
* The resource key string of the folder.
64-
*/
6557
@Json(name = "resource_key")
6658
val resourceKey: String? = null,
6759

68-
/**
69-
* The Slack webhook ID for the folder.
70-
*/
7160
@Json(name = "slack_incoming_webhooks_id")
7261
val slackIncomingWebhooksId: String? = null,
7362

74-
/**
75-
* The Slack integration channel for the folder.
76-
*/
7763
@Json(name = "slack_integration_channel")
7864
val slackIntegrationChannel: String? = null,
7965

80-
/**
81-
* The language preference for Slack notifications about the folder.
82-
* @see slackLanguagePreferenceType
83-
*/
8466
@Json(name = "slack_language_preference")
8567
val slackLanguagePreference: String? = null,
8668

87-
/**
88-
* User preferences for Slack notifications about the folder.
89-
* @see slackUserPreferenceType
90-
*/
9169
@Json(name = "slack_user_preferences")
9270
val slackUserPreference: String? = null,
9371

94-
/**
95-
* The folder's canonical relative URI.
96-
*/
9772
@Json(name = "uri")
9873
val uri: String? = null,
9974

100-
/**
101-
* The folder's owner.
102-
*/
10375
@Json(name = "user")
10476
val user: User? = null
10577
) : Entity {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.vimeo.networking2
2+
3+
import com.squareup.moshi.Json
4+
import com.squareup.moshi.JsonClass
5+
6+
/**
7+
* The connection to a parent folder in the ancestor hierarchy of a folder.
8+
*
9+
* @param uri The URI of the parent folder.
10+
* @param name The name of the parent folder.
11+
*/
12+
@JsonClass(generateAdapter = true)
13+
data class FolderAncestorConnection(
14+
15+
@Json(name = "uri")
16+
val uri: String? = null,
17+
18+
@Json(name = "name")
19+
val name: String? = null
20+
)

models/src/main/java/com/vimeo/networking2/FolderConnections.kt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,33 @@ import com.squareup.moshi.JsonClass
77

88
/**
99
* All of the connections for a folder.
10+
*
11+
* @param ancestorPath An ordered list of connections to the parent folders of a folder. The zeroth index in the list
12+
* will be the immediate parent of the folder.
13+
* @param folders A basic connection object indicating how to return all the sub-folders in the folder.
14+
* @param items A basic connection object indicating how to return all the project items in the folder.
15+
* @param teamMembers Information about the authenticated user's team.
16+
* @param parentFolder Information about the folder's parent folder if there is one.
17+
* @param videos A basic connection object indicating how to return all the videos in the folder.
1018
*/
1119
@JsonClass(generateAdapter = true)
1220
data class FolderConnections(
1321

14-
/**
15-
* A basic connection object indicating how to return all the sub-folders in the folder.
16-
*/
22+
@Json(name = "ancestor_path")
23+
val ancestorPath: List<FolderAncestorConnection>? = null,
24+
1725
@Json(name = "folders")
1826
val folders: BasicConnection? = null,
1927

20-
/**
21-
* A basic connection object indicating how to return all the project items in the folder.
22-
*/
2328
@Json(name = "items")
2429
val items: BasicConnection? = null,
2530

26-
/**
27-
* Information about the authenticated user's team.
28-
*/
2931
@Json(name = "team_members")
3032
val teamMembers: BasicConnection? = null,
3133

32-
/**
33-
* A basic connection object indicating how to return all the videos in the folder.
34-
*/
34+
@Json(name = "parent_folder")
35+
val parentFolder: DefaultConnection? = null,
36+
3537
@Json(name = "videos")
3638
val videos: BasicConnection? = null
3739
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.vimeo.networking2
2+
3+
import com.squareup.moshi.Json
4+
import com.squareup.moshi.JsonClass
5+
6+
/**
7+
* The interactions for a folder.
8+
*
9+
* @param addSubfolder The interaction used to add a subfolder as well as determine capability for adding subfolders.
10+
*/
11+
@JsonClass(generateAdapter = true)
12+
data class FolderInteractions(
13+
14+
@Json(name = "add_subfolder")
15+
val addSubfolder: AddSubfolderInteraction? = null
16+
)

models/src/test/java/com/vimeo/networking2/ModelsTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import kotlin.reflect.full.primaryConstructor
77
class ModelsTest {
88

99
private val models = listOf(
10+
AddSubfolderInteraction::class,
1011
Album::class,
1112
AlbumConnections::class,
1213
AlbumEmbed::class,
@@ -39,6 +40,7 @@ class ModelsTest {
3940
BasicConnection::class,
4041
Credit::class,
4142
DashVideoFile::class,
43+
DefaultConnection::class,
4244
Document::class,
4345
Drm::class,
4446
Email::class,
@@ -51,6 +53,8 @@ class ModelsTest {
5153
FeedItemConnections::class,
5254
FeedList::class,
5355
Folder::class,
56+
FolderAncestorConnection::class,
57+
FolderInteractions::class,
5458
FolderList::class,
5559
FolderConnections::class,
5660
FolderPrivacy::class,

request/src/main/java/com/vimeo/networking2/VimeoApiClient.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ interface VimeoApiClient {
424424
* Create a folder that will be used to organize videos.
425425
*
426426
* @param uri The URI of the user's folders connection.
427+
* @param parentFolderId The ID of the folder in which this folder should be created, null if it should be created
428+
* at the root.
427429
* @param name The name of the folder.
428430
* @param privacy The privacy of the folder.
429431
* @param slackWebhookId The ID of the Slack webhook for notifications.
@@ -435,6 +437,7 @@ interface VimeoApiClient {
435437
*/
436438
fun createFolder(
437439
uri: String,
440+
parentFolderId: String?,
438441
name: String,
439442
privacy: FolderViewPrivacyType,
440443
slackWebhookId: String?,
@@ -447,6 +450,7 @@ interface VimeoApiClient {
447450
* Create a folder that will be used to organize videos.
448451
*
449452
* @param user The user whose folders connection will be used for the request.
453+
* @param parentFolder The folder in which this folder should be created, null if it should be created at the root.
450454
* @param name The name of the folder.
451455
* @param privacy The privacy of the folder.
452456
* @param slackWebhookId The ID of the Slack webhook for notifications.
@@ -458,6 +462,7 @@ interface VimeoApiClient {
458462
*/
459463
fun createFolder(
460464
user: User,
465+
parentFolder: Folder?,
461466
name: String,
462467
privacy: FolderViewPrivacyType,
463468
slackWebhookId: String?,
@@ -470,12 +475,15 @@ interface VimeoApiClient {
470475
* Delete a folder.
471476
*
472477
* @param folder The folder being deleted.
478+
* @param shouldDeleteClips True if the videos in the folder should also be deleted, false if they should not and
479+
* instead should be moved to the root folder.
473480
* @param callback The callback which will be notified of the request completion.
474481
*
475482
* @return A [VimeoRequest] object to cancel API requests.
476483
*/
477484
fun deleteFolder(
478485
folder: Folder,
486+
shouldDeleteClips: Boolean,
479487
callback: VimeoCallback<Unit>
480488
): VimeoRequest
481489

0 commit comments

Comments
 (0)