Skip to content

Commit

Permalink
Merge pull request #434 from vimeo/add-video-status-endpoint
Browse files Browse the repository at this point in the history
Add the video status endpoint
  • Loading branch information
anthonycr authored Jun 23, 2020
2 parents d8611a7 + d3f77da commit 10624c5
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 2 deletions.
43 changes: 43 additions & 0 deletions models/src/main/java/com/vimeo/networking2/VideoStatus.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.vimeo.networking2

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.vimeo.networking2.enums.VideoStateType
import com.vimeo.networking2.enums.asEnum
import java.io.Serializable

/**
* The current status of the video transcoding process.
*/
@JsonClass(generateAdapter = true)
data class VideoStatus(
/**
* The current state of the transcoding process.
*/
@Json(name = "state")
val state: String? = null,

/**
* The percentage of the transcoding process that is complete.
*/
@Json(name = "progress")
val progress: Int? = null,

/**
* The remaining time in seconds before transcoding is complete.
*/
@Json(name = "time_left")
val timeLeft: Long? = null
) : Serializable {

companion object {
private const val serialVersionUID = -72138L
}
}

/**
* @see VideoStatus.state
* @see VideoStateType
*/
val VideoStatus.videoStateType: VideoStateType
get() = state.asEnum(VideoStateType.UNKNOWN)
39 changes: 39 additions & 0 deletions models/src/main/java/com/vimeo/networking2/enums/VideoStateType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.vimeo.networking2.enums

/**
* Video transcoding states.
*/
enum class VideoStateType(override val value: String?): StringValue {

ACTIVE("active"),

BLOCKED("blocked"),

EXCEEDS_QUOTA("exceeds_quota"),

EXCEEDS_TOTAL_CAP("exceeds_total_cap"),

FAILED("failed"),

FINISHING("finishing"),

INTERNAL_ERROR("internal_error"),

INVALID_FILE("invalid_file"),

PENDING("pending"),

READY("ready"),

RETRIEVED("retrieved"),

STANDBY("standby"),

STARTING("starting"),

UPLOAD_COMPLETE("upload_complete"),

UPLOAD_INCOMPLETE("upload_incomplete"),

UNKNOWN("unknown")
}
3 changes: 2 additions & 1 deletion models/src/test/java/com/vimeo/networking2/ModelsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class ModelsTest {
VimeoAccount::class,
WatchedInteraction::class,
WatchLaterInteraction::class,
Website::class
Website::class,
VideoStatus::class
)

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class EnumsTest {
VideoQualityType::class.java,
VideoSourceType::class.java,
VideoStatusType::class.java,
ViewPrivacyType::class.java
ViewPrivacyType::class.java,
VideoStateType::class.java
)

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import com.vimeo.networking2.UserList;
import com.vimeo.networking2.Video;
import com.vimeo.networking2.VideoList;
import com.vimeo.networking2.VideoStatus;
import com.vimeo.networking2.VimeoAccount;
import com.vimeo.networking2.params.BatchPublishToSocialMedia;
import com.vimeo.networking2.PublishJob;
Expand Down Expand Up @@ -465,6 +466,12 @@ Call<AlbumList> getAlbumList(@Header("Authorization") String authHeader,

@GET("products")
Call<ProductList> getProducts(@Header("Authorization") String authHeader);

@GET
Call<VideoStatus> getVideoStatus(@Header("Authorization") String authHeader,
@Url String uri,
@QueryMap Map<String, String> options,
@Header("Cache-Control") String cacheHeaderValue);
// </editor-fold>

@PUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import com.vimeo.networking2.UserList;
import com.vimeo.networking2.Video;
import com.vimeo.networking2.VideoList;
import com.vimeo.networking2.VideoStatus;

import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -552,6 +553,26 @@ public Call<Product> call(@NotNull String authHeader,
}
};

/**
* Used in association with
* {@link VimeoClient#getContent(String, CacheControl, Caller, String, Map, String, VimeoCallback)} or
* {@link VimeoClient#getContentSync(String, CacheControl, String, Map, String, Caller)}
* to get a {@link VideoStatus} response from an API endpoint.
*/
public static final Caller<VideoStatus> VIDEO_STATUS =
new Caller<VideoStatus>() {

@NotNull
@Override
public Call<VideoStatus> call(@NotNull String authHeader,
@NotNull String uri,
@NotNull Map<String, String> queryMap,
@NotNull String cacheHeader,
@NotNull VimeoService vimeoService) {
return vimeoService.getVideoStatus(authHeader, uri, queryMap, cacheHeader);
}
};

private GetRequestCaller() {}

}

0 comments on commit 10624c5

Please sign in to comment.