Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
io.getstream.client.PersonalizationClient Maven / Gradle / Ivy
Go to download
Stream Feeds Java Client for backend and android integrations
package io.getstream.client;
import static io.getstream.core.utils.Auth.buildPersonalizationToken;
import com.google.common.collect.ImmutableMap;
import io.getstream.core.StreamPersonalization;
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.http.Token;
import io.getstream.core.utils.Auth.TokenAction;
import java.util.Map;
import java8.util.concurrent.CompletableFuture;
public final class PersonalizationClient {
private final String secret;
private final StreamPersonalization personalization;
PersonalizationClient(String secret, StreamPersonalization personalization) {
this.secret = secret;
this.personalization = personalization;
}
public CompletableFuture> get(String resource) throws StreamException {
return get(null, resource);
}
public CompletableFuture> get(String resource, Map params)
throws StreamException {
return get(null, resource, params);
}
public CompletableFuture> get(String userID, String resource)
throws StreamException {
return get(userID, resource, ImmutableMap.of());
}
public CompletableFuture> get(
String userID, String resource, Map params) throws StreamException {
final Token token = buildPersonalizationToken(secret, userID, TokenAction.READ);
return personalization.get(token, userID, resource, params);
}
public CompletableFuture post(String resource, Map payload)
throws StreamException {
return post(null, resource, payload);
}
public CompletableFuture post(
String resource, Map params, Map payload)
throws StreamException {
return post(null, resource, params, payload);
}
public CompletableFuture post(String userID, String resource, Map payload)
throws StreamException {
return post(userID, resource, ImmutableMap.of(), payload);
}
public CompletableFuture post(
String userID, String resource, Map params, Map payload)
throws StreamException {
final Token token = buildPersonalizationToken(secret, userID, TokenAction.WRITE);
return personalization.post(token, userID, resource, params, payload);
}
public CompletableFuture delete(String resource) throws StreamException {
return delete(null, resource);
}
public CompletableFuture delete(String resource, Map params)
throws StreamException {
return delete(null, resource, params);
}
public CompletableFuture delete(String userID, String resource) throws StreamException {
return delete(userID, resource, ImmutableMap.of());
}
public CompletableFuture delete(String userID, String resource, Map params)
throws StreamException {
final Token token = buildPersonalizationToken(secret, userID, TokenAction.DELETE);
return personalization.delete(token, userID, resource, params);
}
}