This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
forked from mastodon/mastodon-android
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
176 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
mastodon/src/main/java/org/joinmastodon/android/api/ResultlessMastodonAPIRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 14 additions & 12 deletions
26
mastodon/src/main/java/org/joinmastodon/android/api/requests/lists/AddAccountsToList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
package org.joinmastodon.android.api.requests.lists; | ||
|
||
import org.joinmastodon.android.api.MastodonAPIRequest; | ||
import java.util.List; | ||
import org.joinmastodon.android.api.ResultlessMastodonAPIRequest; | ||
|
||
public class AddAccountsToList extends MastodonAPIRequest<Object> { | ||
public AddAccountsToList(String listId, List<String> accountIds){ | ||
super(HttpMethod.POST, "/lists/"+listId+"/accounts", Object.class); | ||
Request req = new Request(); | ||
req.accountIds = accountIds; | ||
setRequestBody(req); | ||
} | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Collection; | ||
|
||
public static class Request{ | ||
public List<String> accountIds; | ||
} | ||
import okhttp3.FormBody; | ||
|
||
public class AddAccountsToList extends ResultlessMastodonAPIRequest{ | ||
public AddAccountsToList(String listID, Collection<String> accountIDs){ | ||
super(HttpMethod.POST, "/lists/"+listID+"/accounts"); | ||
FormBody.Builder builder=new FormBody.Builder(StandardCharsets.UTF_8); | ||
for(String id:accountIDs){ | ||
builder.add("account_ids[]", id); | ||
} | ||
setRequestBody(builder.build()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
mastodon/src/main/java/org/joinmastodon/android/api/requests/lists/DeleteList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package org.joinmastodon.android.api.requests.lists; | ||
|
||
import org.joinmastodon.android.api.MastodonAPIRequest; | ||
import org.joinmastodon.android.api.ResultlessMastodonAPIRequest; | ||
|
||
public class DeleteList extends MastodonAPIRequest<Object> { | ||
public DeleteList(String id) { | ||
super(HttpMethod.DELETE, "/lists/" + id, Object.class); | ||
public class DeleteList extends ResultlessMastodonAPIRequest{ | ||
public DeleteList(String id){ | ||
super(HttpMethod.DELETE, "/lists/"+id); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
mastodon/src/main/java/org/joinmastodon/android/api/requests/lists/GetListAccounts.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.joinmastodon.android.api.requests.lists; | ||
|
||
import android.text.TextUtils; | ||
|
||
import com.google.gson.reflect.TypeToken; | ||
|
||
import org.joinmastodon.android.api.requests.HeaderPaginationRequest; | ||
import org.joinmastodon.android.model.Account; | ||
|
||
public class GetListAccounts extends HeaderPaginationRequest<Account>{ | ||
public GetListAccounts(String listID, String maxID, int limit){ | ||
super(HttpMethod.GET, "/lists/"+listID+"/accounts", new TypeToken<>(){}); | ||
if(!TextUtils.isEmpty(maxID)) | ||
addQueryParameter("max_id", maxID); | ||
addQueryParameter("limit", String.valueOf(limit)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 14 additions & 12 deletions
26
...don/src/main/java/org/joinmastodon/android/api/requests/lists/RemoveAccountsFromList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
package org.joinmastodon.android.api.requests.lists; | ||
|
||
import org.joinmastodon.android.api.MastodonAPIRequest; | ||
import java.util.List; | ||
import org.joinmastodon.android.api.ResultlessMastodonAPIRequest; | ||
|
||
public class RemoveAccountsFromList extends MastodonAPIRequest<Object> { | ||
public RemoveAccountsFromList(String listId, List<String> accountIds){ | ||
super(HttpMethod.DELETE, "/lists/"+listId+"/accounts", Object.class); | ||
Request req = new Request(); | ||
req.accountIds = accountIds; | ||
setRequestBody(req); | ||
} | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Collection; | ||
|
||
public static class Request{ | ||
public List<String> accountIds; | ||
} | ||
import okhttp3.FormBody; | ||
|
||
public class RemoveAccountsFromList extends ResultlessMastodonAPIRequest{ | ||
public RemoveAccountsFromList(String listID, Collection<String> accountIDs){ | ||
super(HttpMethod.DELETE, "/lists/"+listID+"/accounts"); | ||
FormBody.Builder builder=new FormBody.Builder(StandardCharsets.UTF_8); | ||
for(String id:accountIDs){ | ||
builder.add("account_ids[]", id); | ||
} | ||
setRequestBody(builder.build()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters