mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-11 17:20:39 +01:00
Merge pull request #72 from ultrasonic/add-delete-bookmark
Add delete bookmark
This commit is contained in:
commit
c5bf541c45
@ -0,0 +1,33 @@
|
|||||||
|
package org.moire.ultrasonic.api.subsonic
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration test for [SubsonicAPIDefinition.deleteBookmark] call.
|
||||||
|
*/
|
||||||
|
class SubsonicApiDeleteBookmarkTest : SubsonicAPIClientTest() {
|
||||||
|
@Test
|
||||||
|
fun `Should handle error response`() {
|
||||||
|
checkErrorCallParsed(mockWebServerRule) {
|
||||||
|
client.api.deleteBookmark(1).execute()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should handle ok response`() {
|
||||||
|
mockWebServerRule.enqueueResponse("ping_ok.json")
|
||||||
|
|
||||||
|
val response = client.api.deleteBookmark(1).execute()
|
||||||
|
|
||||||
|
assertResponseSuccessful(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should pass id in request params`() {
|
||||||
|
val id = 233
|
||||||
|
|
||||||
|
mockWebServerRule.assertRequestParam(expectedParam = "id=$id") {
|
||||||
|
client.api.deleteBookmark(id).execute()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -230,4 +230,7 @@ interface SubsonicAPIDefinition {
|
|||||||
@Query("id") id: Int,
|
@Query("id") id: Int,
|
||||||
@Query("position") position: Long,
|
@Query("position") position: Long,
|
||||||
@Query("comment") comment: String? = null): Call<SubsonicResponse>
|
@Query("comment") comment: String? = null): Call<SubsonicResponse>
|
||||||
|
|
||||||
|
@GET("deleteBookmark.view")
|
||||||
|
fun deleteBookmark(@Query("id") id: Int): Call<SubsonicResponse>
|
||||||
}
|
}
|
||||||
|
@ -1299,31 +1299,20 @@ public class RESTMusicService implements MusicService
|
|||||||
checkResponseSuccessful(response);
|
checkResponseSuccessful(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteBookmark(String id, Context context, ProgressListener progressListener) throws Exception
|
public void deleteBookmark(String id,
|
||||||
{
|
Context context,
|
||||||
checkServerVersion(context, "1.9", "Bookmarks not supported.");
|
ProgressListener progressListener) throws Exception {
|
||||||
|
if (id == null) {
|
||||||
|
throw new IllegalArgumentException("Id is null");
|
||||||
|
}
|
||||||
|
Integer itemId = Integer.parseInt(id);
|
||||||
|
|
||||||
HttpParams params = new BasicHttpParams();
|
updateProgressListener(progressListener, R.string.parser_reading);
|
||||||
HttpConnectionParams.setSoTimeout(params, SOCKET_READ_TIMEOUT_GET_RANDOM_SONGS);
|
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
|
||||||
|
.deleteBookmark(itemId).execute();
|
||||||
List<String> parameterNames = new ArrayList<String>();
|
checkResponseSuccessful(response);
|
||||||
List<Object> parameterValues = new ArrayList<Object>();
|
}
|
||||||
|
|
||||||
parameterNames.add("id");
|
|
||||||
parameterValues.add(id);
|
|
||||||
|
|
||||||
Reader reader = getReader(context, progressListener, "deleteBookmark", params, parameterNames, parameterValues);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new ErrorParser(context).parse(reader);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Util.close(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception
|
public MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception
|
||||||
|
Loading…
x
Reference in New Issue
Block a user