|
12 | 12 | import com.google.common.collect.ImmutableMap; |
13 | 13 | import io.getstream.core.exceptions.StreamException; |
14 | 14 | import io.getstream.core.http.HTTPClient; |
| 15 | +import io.getstream.core.http.Request; |
15 | 16 | import io.getstream.core.http.Token; |
16 | 17 | import io.getstream.core.models.FeedID; |
17 | 18 | import io.getstream.core.models.Paginated; |
@@ -283,14 +284,40 @@ public CompletableFuture<Void> update(Token token, Reaction reaction, FeedID... |
283 | 284 | } |
284 | 285 | } |
285 | 286 |
|
286 | | - public CompletableFuture<Void> delete(Token token, String id) throws StreamException { |
| 287 | + public CompletableFuture<Void> delete(Token token, String id, Boolean soft) throws StreamException { |
287 | 288 | checkNotNull(id, "Reaction id can't be null"); |
288 | 289 | checkArgument(!id.isEmpty(), "Reaction id can't be empty"); |
289 | 290 |
|
290 | 291 | try { |
291 | 292 | final URL url = buildReactionsURL(baseURL, id + '/'); |
| 293 | + |
| 294 | + final Request deleteRequest = soft ? buildDelete(url, key, token, new CustomQueryParameter("soft", "true")) |
| 295 | + : buildDelete(url, key, token); |
| 296 | + |
| 297 | + return httpClient |
| 298 | + .execute(deleteRequest) |
| 299 | + .thenApply( |
| 300 | + response -> { |
| 301 | + try { |
| 302 | + return deserializeError(response); |
| 303 | + } catch (StreamException | IOException e) { |
| 304 | + throw new CompletionException(e); |
| 305 | + } |
| 306 | + }); |
| 307 | + } catch (MalformedURLException | URISyntaxException e) { |
| 308 | + throw new StreamException(e); |
| 309 | + } |
| 310 | + } |
| 311 | + |
| 312 | + public CompletableFuture<Void> restore(Token token, String id) throws StreamException { |
| 313 | + checkNotNull(id, "Reaction id can't be null"); |
| 314 | + checkArgument(!id.isEmpty(), "Reaction id can't be empty"); |
| 315 | + |
| 316 | + try { |
| 317 | + final URL url = buildReactionsURL(baseURL, id + "/restore/"); |
| 318 | + byte[] payload = new byte[0]; |
292 | 319 | return httpClient |
293 | | - .execute(buildDelete(url, key, token)) |
| 320 | + .execute(buildPut(url, key, token, payload)) |
294 | 321 | .thenApply( |
295 | 322 | response -> { |
296 | 323 | try { |
|
0 commit comments