Notifications

This commit is contained in:
Grishka
2022-03-05 12:59:27 +03:00
parent b437f6f3a3
commit 37bef85f6a
18 changed files with 738 additions and 119 deletions

View File

@@ -5,12 +5,13 @@ import com.google.gson.reflect.TypeToken;
import org.joinmastodon.android.api.MastodonAPIRequest;
import org.joinmastodon.android.model.Relationship;
import java.util.Collection;
import java.util.List;
import androidx.annotation.NonNull;
public class GetAccountRelationships extends MastodonAPIRequest<List<Relationship>>{
public GetAccountRelationships(@NonNull List<String> ids){
public GetAccountRelationships(@NonNull Collection<String> ids){
super(HttpMethod.GET, "/accounts/relationships", new TypeToken<>(){});
for(String id:ids)
addQueryParameter("id[]", id);

View File

@@ -1,18 +1,27 @@
package org.joinmastodon.android.api.requests.notifications;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import org.joinmastodon.android.api.MastodonAPIRequest;
import org.joinmastodon.android.model.Notification;
import java.util.EnumSet;
import java.util.List;
public class GetNotifications extends MastodonAPIRequest<List<Notification>>{
public GetNotifications(String maxID, int limit){
public GetNotifications(String maxID, int limit, EnumSet<Notification.Type> excludeTypes){
super(HttpMethod.GET, "/notifications", new TypeToken<>(){});
if(maxID!=null)
addQueryParameter("max_id", maxID);
if(limit>0)
addQueryParameter("limit", ""+limit);
if(excludeTypes!=null){
for(Notification.Type nt:excludeTypes){
try{
addQueryParameter("exclude_types[]", nt.getDeclaringClass().getField(nt.name()).getAnnotation(SerializedName.class).value());
}catch(NoSuchFieldException ignore){}
}
}
}
}