Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/io/sockudo/rest/Sockudo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.StringEntity;
Expand Down Expand Up @@ -168,6 +169,11 @@ protected Result doGet(final URI uri) {
return httpCall(new HttpGet(uri));
}

@Override
protected Result doDelete(final URI uri) {
return httpCall(new HttpDelete(uri));
}

@Override
protected Result doPost(final URI uri, final String body) {
final StringEntity bodyEntity = new StringEntity(body, "UTF-8");
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/io/sockudo/rest/SockudoAbstract.java
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,45 @@ public T appendMessage(final String channelName, final String messageSerial, fin
return post("/channels/" + channelName + "/messages/" + messageSerial + "/append", body);
}

/**
* Publish an annotation for a versioned message.
*/
public T publishAnnotation(final String channelName, final String messageSerial, final String body) {
Prerequisites.nonEmpty("channelName", channelName);
Prerequisites.isValidChannel(channelName);
Prerequisites.nonEmpty("messageSerial", messageSerial);
return post("/channels/" + channelName + "/messages/" + messageSerial + "/annotations", body);
}

/**
* Delete an annotation from a versioned message.
*/
public T deleteAnnotation(final String channelName, final String messageSerial, final String annotationSerial, final Map<String, String> parameters) {
Prerequisites.nonEmpty("channelName", channelName);
Prerequisites.isValidChannel(channelName);
Prerequisites.nonEmpty("messageSerial", messageSerial);
Prerequisites.nonEmpty("annotationSerial", annotationSerial);
return delete("/channels/" + channelName + "/messages/" + messageSerial + "/annotations/" + annotationSerial, parameters);
}

public T deleteAnnotation(final String channelName, final String messageSerial, final String annotationSerial) {
return deleteAnnotation(channelName, messageSerial, annotationSerial, Collections.<String, String>emptyMap());
}

/**
* List raw annotation events for a versioned message.
*/
public T listAnnotations(final String channelName, final String messageSerial, final Map<String, String> parameters) {
Prerequisites.nonEmpty("channelName", channelName);
Prerequisites.isValidChannel(channelName);
Prerequisites.nonEmpty("messageSerial", messageSerial);
return get("/channels/" + channelName + "/messages/" + messageSerial + "/annotations", parameters);
}

public T listAnnotations(final String channelName, final String messageSerial) {
return listAnnotations(channelName, messageSerial, Collections.<String, String>emptyMap());
}

/**
* Fetch presence history for a specific presence channel.
*
Expand Down Expand Up @@ -666,6 +705,15 @@ public T getChannelPresenceSnapshot(final String channelName) {

protected abstract T doGet(final URI uri);

public T delete(final String path, final Map<String, String> parameters) {
final String fullPath = "/apps/" + appId + path;
final URI uri = SignatureUtil.uri("DELETE", scheme, host, fullPath, null, key, secret, parameters);

return doDelete(uri);
}

protected abstract T doDelete(final URI uri);

/**
* Make a generic HTTP call to the Sockudo API.
* <p>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/io/sockudo/rest/SockudoAsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ protected CompletableFuture<Result> doGet(final URI uri) {
return httpCall(request);
}

@Override
protected CompletableFuture<Result> doDelete(final URI uri) {
final Request request = new RequestBuilder(HttpConstants.Methods.DELETE)
.setUrl(uri.toString())
.build();

return httpCall(request);
}

@Override
protected CompletableFuture<Result> doPost(final URI uri, final String body) {
final Request request = new RequestBuilder(HttpConstants.Methods.POST)
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/io/sockudo/rest/util/SockudoNoHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ protected Object doGet(final URI uri) {
throw new IllegalStateException("Shouldn't have been called, HTTP level not implemented");
}

@Override
protected Object doDelete(final URI uri) {
throw new IllegalStateException("Shouldn't have been called, HTTP level not implemented");
}

@Override
protected Object doPost(final URI uri, final String body) {
throw new IllegalStateException("Shouldn't have been called, HTTP level not implemented");
Expand Down
Loading