Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document setters for updating webhooks #888

Merged
merged 1 commit into from Apr 30, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/webhooks.md
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
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