Skip to content

Commit

Permalink
Document webhook setters (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
swfree committed Apr 30, 2021
1 parent 7d55c66 commit 63c9f8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions doc/webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ A webhook can be updated by calling the [`update(BoxWebHook.Info fieldsToUpdate)
<!-- sample put_webhooks_id -->
```java
BoxWebHook webhook = new BoxWebHook(api, id);
BoxWebHook.Info info = webhook.getInfo();
info.addPendingChange("address", url);
BoxWebHook.Info info = webhook.new Info();
info.setAddress(url);
webhook.update(info);
```

Expand Down
12 changes: 8 additions & 4 deletions src/test/java/com/box/sdk/BoxWebHookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,12 @@ public void testUpdateWebhookInfoSucceeds() throws IOException {
final String webhookID = "12345";
final String createdByLogin = "test@user.com";
final String webhookURL = "/webhooks/" + webhookID;

JsonArray triggers = new JsonArray()
.add("FILE.UPLOADED");

JsonObject updateObject = new JsonObject()
.add("triggers", "FILE.UPLOADED")
.add("triggers", triggers)
.add("address", newAddress);

getResult = TestConfig.getFixture("BoxWebhook/GetWebhook200");
Expand All @@ -270,9 +274,9 @@ public void testUpdateWebhookInfoSucceeds() throws IOException {
.withBody(result)));

BoxWebHook webhook = new BoxWebHook(this.api, webhookID);
BoxWebHook.Info info = webhook.getInfo();
info.addPendingChange("address", newAddress);
info.addPendingChange("triggers", "FILE.UPLOADED");
BoxWebHook.Info info = webhook.new Info();
info.setAddress(new URL(newAddress));
info.setTriggers(BoxWebHook.Trigger.FILE_UPLOADED);
webhook.updateInfo(info);

Assert.assertEquals(new URL(newAddress), info.getAddress());
Expand Down

0 comments on commit 63c9f8c

Please sign in to comment.