Skip to content

Commit

Permalink
Add method to reorder user's lists
Browse files Browse the repository at this point in the history
  • Loading branch information
danielerl committed Sep 6, 2023
1 parent 3b55ff7 commit 28d6fe6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/com/uwetrottmann/trakt5/services/Users.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ Call<Void> deleteList(
@Path("id") String id
);

/**
* <b>OAuth Required</b>
*
* <p> Reorder all custom lists by sending the updated rank of list ids.
*/
@POST("users/{username}/lists/reorder")
Call<ListReorderResponse> reorderLists(
@Path("username") UserSlug userSlug,
@Body ListItemRank rank
);

/**
* <b>OAuth Optional</b>
*
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/com/uwetrottmann/trakt5/services/UsersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ public void test_reorderListItems() throws IOException {
assertThat(response.updated).isEqualTo(entries.size());
}

@Test
public void test_reorderLists() throws IOException {
List<TraktList> lists = executeCall(getTrakt().users().lists(UserSlug.ME));

// reverse order
List<Long> newRank = new ArrayList<>();
for (int i = lists.size() - 1; i >= 0; i--) {
newRank.add(lists.get(i).ids.trakt.longValue());
}

ListReorderResponse response = executeCall(getTrakt().users().reorderLists(
UserSlug.ME,
ListItemRank.from(newRank)
));
assertThat(response.updated).isEqualTo(lists.size());
}

@Test
public void test_unfollowAndFollow() throws InterruptedException, IOException {
// unfollow first
Expand Down

0 comments on commit 28d6fe6

Please sign in to comment.