Skip to content

Commit

Permalink
CXAN-462 Add editComment API (#624)
Browse files Browse the repository at this point in the history
* CXAN-462 Add editComment API
  • Loading branch information
EStepiuk committed Jul 20, 2023
1 parent 4671ef6 commit 2edfee2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
17 changes: 17 additions & 0 deletions request/src/main/java/com/vimeo/networking2/VimeoApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,23 @@ interface VimeoApiClient {
timeCode: Double? = null,
): VimeoRequest

/**
* Edit a [Comment].
*
* @param uri The URI of the [Comment] to edit.
* @param text The optional new text for the comment.
* @param timeCode The optional time code of the video this comment relates to.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun editComment(
uri: String,
text: String? = null,
timeCode: Double? = null,
callback: VimeoCallback<Comment>
): VimeoRequest

/**
* Create a note on a [Video].
*
Expand Down
9 changes: 9 additions & 0 deletions request/src/main/java/com/vimeo/networking2/VimeoService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ internal interface VimeoService {
@Field(PARAMETER_TIME_CODE) timeCode: Double?,
): VimeoCall<Comment>

@FormUrlEncoded
@PATCH
fun editComment(
@Header(AUTHORIZATION) authorization: String,
@Url uri: String,
@Field(PARAMETER_COMMENT_TEXT_BODY) commentBody: String?,
@Field(PARAMETER_TIME_CODE) timeCode: Double?,
): VimeoCall<Comment>

@POST
fun createNote(
@Header(AUTHORIZATION) authorization: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ internal class MutableVimeoApiClientDelegate(var actual: VimeoApiClient? = null)
password: String?,
callback: VimeoCallback<Comment>,
timeCode: Double?
): VimeoRequest = client.createComment(uri, comment, password, callback, timeCode,)
): VimeoRequest = client.createComment(uri, comment, password, callback, timeCode)

override fun createComment(
video: Video,
Expand All @@ -681,6 +681,13 @@ internal class MutableVimeoApiClientDelegate(var actual: VimeoApiClient? = null)
timeCode: Double?
): VimeoRequest = client.createComment(video, comment, password, callback, timeCode)

override fun editComment(
uri: String,
text: String?,
timeCode: Double?,
callback: VimeoCallback<Comment>
): VimeoRequest = client.editComment(uri, text, timeCode, callback)

override fun createNote(
uri: String,
text: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,16 @@ internal class VimeoApiClientImpl(
return createComment(uri, comment, password, callback, timeCode)
}

override fun editComment(
uri: String,
text: String?,
timeCode: Double?,
callback: VimeoCallback<Comment>,
): VimeoRequest {
val safeUri = uri.validate() ?: return localVimeoCallAdapter.enqueueInvalidUri(callback)
return vimeoService.editComment(authHeader, safeUri, text, timeCode).enqueue(callback)
}

override fun createNote(
uri: String,
text: String,
Expand Down

0 comments on commit 2edfee2

Please sign in to comment.