From 8a82e808342caa05d7d40ef9302869dfe0471238 Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Fri, 13 Nov 2020 14:39:22 +0900 Subject: [PATCH 1/5] Get & test webhook URL #582 --- .../bot/client/LineMessagingClient.java | 17 ++++ .../bot/client/LineMessagingClientImpl.java | 14 +++ .../bot/client/LineMessagingService.java | 9 ++ .../client/LineMessagingClientImplTest.java | 37 ++++++++ .../request/TestWebhookEndpointRequest.java | 41 +++++++++ .../response/GetWebhookEndpointResponse.java | 46 ++++++++++ .../response/TestWebhookEndpointResponse.java | 61 +++++++++++++ .../controller/BotController.java | 81 +++++++++++++++++ .../main/resources/templates/__wrapper.ftlh | 87 +++++++++++-------- .../resources/templates/bot/get_webhook.ftlh | 35 ++++++++ .../main/resources/templates/bot/info.ftlh | 38 ++++++++ .../resources/templates/bot/test_webhook.ftlh | 29 +++++++ 12 files changed, 457 insertions(+), 38 deletions(-) create mode 100644 line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java create mode 100644 line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java create mode 100644 line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java create mode 100644 sample-manage-audience/src/main/java/com/linecorp/bot/messagingapidemoapp/controller/BotController.java create mode 100644 sample-manage-audience/src/main/resources/templates/bot/get_webhook.ftlh create mode 100644 sample-manage-audience/src/main/resources/templates/bot/info.ftlh create mode 100644 sample-manage-audience/src/main/resources/templates/bot/test_webhook.ftlh diff --git a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java index 3f2a7ce69..df5af2f33 100644 --- a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java +++ b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java @@ -30,16 +30,19 @@ import com.linecorp.bot.model.group.GroupSummaryResponse; import com.linecorp.bot.model.profile.MembersIdsResponse; import com.linecorp.bot.model.profile.UserProfileResponse; +import com.linecorp.bot.model.request.TestWebhookEndpointRequest; import com.linecorp.bot.model.response.BotApiResponse; import com.linecorp.bot.model.response.BotInfoResponse; import com.linecorp.bot.model.response.GetMessageEventResponse; import com.linecorp.bot.model.response.GetNumberOfFollowersResponse; import com.linecorp.bot.model.response.GetNumberOfMessageDeliveriesResponse; +import com.linecorp.bot.model.response.GetWebhookEndpointResponse; import com.linecorp.bot.model.response.IssueLinkTokenResponse; import com.linecorp.bot.model.response.MessageQuotaResponse; import com.linecorp.bot.model.response.NarrowcastProgressResponse; import com.linecorp.bot.model.response.NumberOfMessagesResponse; import com.linecorp.bot.model.response.QuotaConsumptionResponse; +import com.linecorp.bot.model.response.TestWebhookEndpointResponse; import com.linecorp.bot.model.response.demographics.GetFriendsDemographicsResponse; import com.linecorp.bot.model.richmenu.RichMenu; import com.linecorp.bot.model.richmenu.RichMenuIdResponse; @@ -378,6 +381,20 @@ public interface LineMessagingClient { */ CompletableFuture getBotInfo(); + /** + * Get webhook endpoint information. + * + * @see Get webhook endpoint information + */ + CompletableFuture getWebhookEndpoint(); + + /** + * Test webhook endpoint. + * + * @see Test webhook endpoint + */ + CompletableFuture testWebhookEndpoint(TestWebhookEndpointRequest request); + static LineMessagingClientBuilder builder(String channelToken) { return builder(FixedChannelTokenSupplier.of(channelToken)); } diff --git a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClientImpl.java b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClientImpl.java index e57858d4f..9822c8fb4 100644 --- a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClientImpl.java +++ b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClientImpl.java @@ -31,16 +31,19 @@ import com.linecorp.bot.model.group.GroupSummaryResponse; import com.linecorp.bot.model.profile.MembersIdsResponse; import com.linecorp.bot.model.profile.UserProfileResponse; +import com.linecorp.bot.model.request.TestWebhookEndpointRequest; import com.linecorp.bot.model.response.BotApiResponse; import com.linecorp.bot.model.response.BotInfoResponse; import com.linecorp.bot.model.response.GetMessageEventResponse; import com.linecorp.bot.model.response.GetNumberOfFollowersResponse; import com.linecorp.bot.model.response.GetNumberOfMessageDeliveriesResponse; +import com.linecorp.bot.model.response.GetWebhookEndpointResponse; import com.linecorp.bot.model.response.IssueLinkTokenResponse; import com.linecorp.bot.model.response.MessageQuotaResponse; import com.linecorp.bot.model.response.NarrowcastProgressResponse; import com.linecorp.bot.model.response.NumberOfMessagesResponse; import com.linecorp.bot.model.response.QuotaConsumptionResponse; +import com.linecorp.bot.model.response.TestWebhookEndpointResponse; import com.linecorp.bot.model.response.demographics.GetFriendsDemographicsResponse; import com.linecorp.bot.model.richmenu.RichMenu; import com.linecorp.bot.model.richmenu.RichMenuBulkLinkRequest; @@ -285,6 +288,17 @@ public CompletableFuture getBotInfo() { return toFuture(retrofitImpl.getBotInfo()); } + @Override + public CompletableFuture getWebhookEndpoint() { + return toFuture(retrofitImpl.getWebhookEndpoint()); + } + + @Override + public CompletableFuture testWebhookEndpoint( + TestWebhookEndpointRequest request) { + return toFuture(retrofitImpl.testWebhookEndpoint(request)); + } + // TODO: Extract this method. static CompletableFuture toFuture(Call callToWrap) { final CallbackAdaptor completableFuture = new CallbackAdaptor<>(); diff --git a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingService.java b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingService.java index aaa0c80ac..b8a16759f 100644 --- a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingService.java +++ b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingService.java @@ -27,15 +27,18 @@ import com.linecorp.bot.model.group.GroupSummaryResponse; import com.linecorp.bot.model.profile.MembersIdsResponse; import com.linecorp.bot.model.profile.UserProfileResponse; +import com.linecorp.bot.model.request.TestWebhookEndpointRequest; import com.linecorp.bot.model.response.BotInfoResponse; import com.linecorp.bot.model.response.GetMessageEventResponse; import com.linecorp.bot.model.response.GetNumberOfFollowersResponse; import com.linecorp.bot.model.response.GetNumberOfMessageDeliveriesResponse; +import com.linecorp.bot.model.response.GetWebhookEndpointResponse; import com.linecorp.bot.model.response.IssueLinkTokenResponse; import com.linecorp.bot.model.response.MessageQuotaResponse; import com.linecorp.bot.model.response.NarrowcastProgressResponse; import com.linecorp.bot.model.response.NumberOfMessagesResponse; import com.linecorp.bot.model.response.QuotaConsumptionResponse; +import com.linecorp.bot.model.response.TestWebhookEndpointResponse; import com.linecorp.bot.model.response.demographics.GetFriendsDemographicsResponse; import com.linecorp.bot.model.richmenu.RichMenu; import com.linecorp.bot.model.richmenu.RichMenuBulkLinkRequest; @@ -382,4 +385,10 @@ Call linkRichMenuToUser( */ @GET("v2/bot/info") Call getBotInfo(); + + @GET("v2/bot/channel/webhook/endpoint") + Call getWebhookEndpoint(); + + @POST("v2/bot/channel/webhook/test") + Call testWebhookEndpoint(@Body TestWebhookEndpointRequest request); } diff --git a/line-bot-api-client/src/test/java/com/linecorp/bot/client/LineMessagingClientImplTest.java b/line-bot-api-client/src/test/java/com/linecorp/bot/client/LineMessagingClientImplTest.java index d97d8fac0..b5764c252 100644 --- a/line-bot-api-client/src/test/java/com/linecorp/bot/client/LineMessagingClientImplTest.java +++ b/line-bot-api-client/src/test/java/com/linecorp/bot/client/LineMessagingClientImplTest.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.net.URI; +import java.time.Instant; import org.junit.Rule; import org.junit.Test; @@ -52,10 +53,12 @@ import com.linecorp.bot.model.narrowcast.filter.GenderDemographicFilter.Gender; import com.linecorp.bot.model.profile.MembersIdsResponse; import com.linecorp.bot.model.profile.UserProfileResponse; +import com.linecorp.bot.model.request.TestWebhookEndpointRequest; import com.linecorp.bot.model.response.BotApiResponse; import com.linecorp.bot.model.response.BotInfoResponse; import com.linecorp.bot.model.response.GetNumberOfFollowersResponse; import com.linecorp.bot.model.response.GetNumberOfMessageDeliveriesResponse; +import com.linecorp.bot.model.response.GetWebhookEndpointResponse; import com.linecorp.bot.model.response.IssueLinkTokenResponse; import com.linecorp.bot.model.response.MessageQuotaResponse; import com.linecorp.bot.model.response.MessageQuotaResponse.QuotaType; @@ -63,6 +66,7 @@ import com.linecorp.bot.model.response.NarrowcastProgressResponse.Phase; import com.linecorp.bot.model.response.NumberOfMessagesResponse; import com.linecorp.bot.model.response.QuotaConsumptionResponse; +import com.linecorp.bot.model.response.TestWebhookEndpointResponse; import com.linecorp.bot.model.richmenu.RichMenu; import com.linecorp.bot.model.richmenu.RichMenuBulkLinkRequest; import com.linecorp.bot.model.richmenu.RichMenuBulkUnlinkRequest; @@ -637,6 +641,39 @@ public void getBotInfo() throws Exception { assertThat(actual).isEqualTo(response); } + @Test + public void getWebhookEndpoint() throws Exception { + final GetWebhookEndpointResponse response = GetWebhookEndpointResponse + .builder() + .endpoint(URI.create("https://line.me/webhook")) + .active(true) + .build(); + whenCall(retrofitMock.getWebhookEndpoint(), response); + final GetWebhookEndpointResponse actual = target.getWebhookEndpoint().get(); + verify(retrofitMock, only()).getWebhookEndpoint(); + assertThat(actual).isEqualTo(response); + } + + @Test + public void testWebhookEndpoint() throws Exception { + final TestWebhookEndpointResponse response = TestWebhookEndpointResponse + .builder() + .success(true) + .timestamp(Instant.now()) + .detail("abc") + .reason("def") + .statusCode(200) + .build(); + final TestWebhookEndpointRequest request = TestWebhookEndpointRequest + .builder() + .endpoint(URI.create("http://example.com/my/great/endpoint")) + .build(); + whenCall(retrofitMock.testWebhookEndpoint(request), response); + final TestWebhookEndpointResponse actual = target.testWebhookEndpoint(request).get(); + verify(retrofitMock, only()).testWebhookEndpoint(request); + assertThat(actual).isEqualTo(response); + } + // Utility methods private static void whenCall(Call call, T value) { diff --git a/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java b/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java new file mode 100644 index 000000000..07492bf1f --- /dev/null +++ b/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2020 LINE Corporation + * + * LINE Corporation licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package com.linecorp.bot.model.request; + +import java.net.URI; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; + +import com.linecorp.bot.model.request.TestWebhookEndpointRequest.TestWebhookEndpointRequestBuilder; + +import lombok.Builder; +import lombok.Value; + +@Value +@Builder +@JsonDeserialize(builder = TestWebhookEndpointRequestBuilder.class) +public class TestWebhookEndpointRequest { + /** + * A valid webhook URL(Optional). + */ + URI endpoint; + + @JsonPOJOBuilder(withPrefix = "") + public static class TestWebhookEndpointRequestBuilder { + } +} diff --git a/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java b/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java new file mode 100644 index 000000000..54dd010e5 --- /dev/null +++ b/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright 2020 LINE Corporation + * + * LINE Corporation licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package com.linecorp.bot.model.response; + +import java.net.URI; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; + +import com.linecorp.bot.model.response.GetWebhookEndpointResponse.GetWebhookEndpointResponseBuilder; + +import lombok.Builder; +import lombok.Value; + +@Value +@Builder +@JsonDeserialize(builder = GetWebhookEndpointResponseBuilder.class) +public class GetWebhookEndpointResponse { + /** + * Webhook URL + */ + URI endpoint; + + /* + * Webhook usage status. Send a webhook event from the LINE platform to the webhook URL only if enabled. + */ + boolean active; + + @JsonPOJOBuilder(withPrefix = "") + public static class GetWebhookEndpointResponseBuilder { + } +} diff --git a/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java b/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java new file mode 100644 index 000000000..008c5c044 --- /dev/null +++ b/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java @@ -0,0 +1,61 @@ +/* + * Copyright 2020 LINE Corporation + * + * LINE Corporation licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package com.linecorp.bot.model.response; + +import java.time.Instant; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; + +import com.linecorp.bot.model.response.TestWebhookEndpointResponse.TestWebhookEndpointResponseBuilder; + +import lombok.Builder; +import lombok.Value; + +@Value +@Builder +@JsonDeserialize(builder = TestWebhookEndpointResponseBuilder.class) +public class TestWebhookEndpointResponse { + /** + * Result of the communication from the LINE platform to the webhook URL. + */ + boolean success; + + /** + * Please refer to Common Properties. + */ + Instant timestamp; + + /** + * The HTTP status code. If the webhook response isn't received, the status code is set to zero or a negative number. + */ + int statusCode; + + /** + * Reason for the response. + */ + String reason; + + /** + * Details of the response. + */ + String detail; + + @JsonPOJOBuilder(withPrefix = "") + public static class TestWebhookEndpointResponseBuilder { + } +} diff --git a/sample-manage-audience/src/main/java/com/linecorp/bot/messagingapidemoapp/controller/BotController.java b/sample-manage-audience/src/main/java/com/linecorp/bot/messagingapidemoapp/controller/BotController.java new file mode 100644 index 000000000..d2204e4ad --- /dev/null +++ b/sample-manage-audience/src/main/java/com/linecorp/bot/messagingapidemoapp/controller/BotController.java @@ -0,0 +1,81 @@ +/* + * Copyright 2020 LINE Corporation + * + * LINE Corporation licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + */ + +package com.linecorp.bot.messagingapidemoapp.controller; + +import java.net.URI; +import java.util.concurrent.ExecutionException; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import com.linecorp.bot.client.LineMessagingClient; +import com.linecorp.bot.client.exception.NotFoundException; +import com.linecorp.bot.model.request.TestWebhookEndpointRequest; +import com.linecorp.bot.model.request.TestWebhookEndpointRequest.TestWebhookEndpointRequestBuilder; +import com.linecorp.bot.model.response.BotInfoResponse; +import com.linecorp.bot.model.response.GetWebhookEndpointResponse; +import com.linecorp.bot.model.response.TestWebhookEndpointResponse; + +import lombok.AllArgsConstructor; + +@Controller +@AllArgsConstructor +public class BotController { + LineMessagingClient client; + + @GetMapping("/bot/info") + public String info(Model model) throws ExecutionException, InterruptedException { + BotInfoResponse botInfo = client.getBotInfo().get(); + model.addAttribute("botInfo", botInfo); + return "bot/info"; + } + + @GetMapping("/bot/webhook") + public String webhook(Model model) throws InterruptedException, ExecutionException { + try { + GetWebhookEndpointResponse webhook = client.getWebhookEndpoint().get(); + model.addAttribute("webhook", webhook); + } catch (ExecutionException e) { + if (e.getCause() instanceof NotFoundException) { + model.addAttribute("notFoundException", e.getCause()); + } else { + throw e; + } + } + return "bot/get_webhook"; + } + + @PostMapping("/bot/test_webhook") + public String testWebhook(Model model, + @RequestParam("url") URI uri) throws InterruptedException, ExecutionException { + TestWebhookEndpointRequestBuilder builder = TestWebhookEndpointRequest.builder(); + if (uri != null) { + builder.endpoint(uri); + } + TestWebhookEndpointRequest testWebhookEndpointRequest = builder.build(); + TestWebhookEndpointResponse response = client.testWebhookEndpoint( + testWebhookEndpointRequest + ).get(); + model.addAttribute("response", response); + return "bot/test_webhook"; + } + +} diff --git a/sample-manage-audience/src/main/resources/templates/__wrapper.ftlh b/sample-manage-audience/src/main/resources/templates/__wrapper.ftlh index 55c9daf12..8d1ed3e23 100644 --- a/sample-manage-audience/src/main/resources/templates/__wrapper.ftlh +++ b/sample-manage-audience/src/main/resources/templates/__wrapper.ftlh @@ -14,52 +14,63 @@ - - + +
- <#nested/> + <#nested/>
diff --git a/sample-manage-audience/src/main/resources/templates/bot/get_webhook.ftlh b/sample-manage-audience/src/main/resources/templates/bot/get_webhook.ftlh new file mode 100644 index 000000000..aaab5c4bb --- /dev/null +++ b/sample-manage-audience/src/main/resources/templates/bot/get_webhook.ftlh @@ -0,0 +1,35 @@ +<#import "../__wrapper.ftlh" as wrapper> +<@wrapper.main> + +

Webhook

+ +

Webhook information

+ + <#if notFoundException??> +

This bot doesn't have an webhook endpoint: ${notFoundException.message}

+ <#else> + + + + + + + + + +
endpoint${webhook.endpoint}
active${webhook.active?c}
+ + +

Test webhook

+
+ + + + + +
(Optional) + +
+
+ + diff --git a/sample-manage-audience/src/main/resources/templates/bot/info.ftlh b/sample-manage-audience/src/main/resources/templates/bot/info.ftlh new file mode 100644 index 000000000..57637c389 --- /dev/null +++ b/sample-manage-audience/src/main/resources/templates/bot/info.ftlh @@ -0,0 +1,38 @@ +<#import "../__wrapper.ftlh" as wrapper> +<@wrapper.main> + +

Bot information

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
userId${botInfo.userId}
basicId${botInfo.basicId}
premiumId${botInfo.premiumId!"-"}
displayName${botInfo.displayName}
pictureUrl${botInfo.pictureUrl}
+ pictureUrl
chatMode${botInfo.chatMode}
markAsReadMode${botInfo.markAsReadMode}
+ + diff --git a/sample-manage-audience/src/main/resources/templates/bot/test_webhook.ftlh b/sample-manage-audience/src/main/resources/templates/bot/test_webhook.ftlh new file mode 100644 index 000000000..5faa4e066 --- /dev/null +++ b/sample-manage-audience/src/main/resources/templates/bot/test_webhook.ftlh @@ -0,0 +1,29 @@ +<#import "../__wrapper.ftlh" as wrapper> +<@wrapper.main> + +

Webhook testing result

+ + + + + + + + + + + + + + + + + + + + + + +
Success${response.success!?c}
timestamp${response.timestamp.epochSecond!}
statusCode${response.statusCode}
Reason${response.reason!"-"}
Detail${response.detail!"-"}
+ + From d02d65845447829273caeca905823be5dc337c64 Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Sat, 14 Nov 2020 10:00:10 +0900 Subject: [PATCH 2/5] Update line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java Co-authored-by: Masahiro Ide --- .../main/java/com/linecorp/bot/client/LineMessagingClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java index df5af2f33..6b56a3787 100644 --- a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java +++ b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java @@ -382,7 +382,7 @@ public interface LineMessagingClient { CompletableFuture getBotInfo(); /** - * Get webhook endpoint information. + * Gets webhook endpoint information. * * @see Get webhook endpoint information */ From 746ef1e505980e03f8dceef44d16e10874d5c097 Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Sat, 14 Nov 2020 10:00:52 +0900 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Masahiro Ide --- .../java/com/linecorp/bot/client/LineMessagingClient.java | 2 +- .../bot/model/request/TestWebhookEndpointRequest.java | 4 ++-- .../bot/model/response/GetWebhookEndpointResponse.java | 2 +- .../bot/messagingapidemoapp/controller/BotController.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java index 6b56a3787..15cbc1803 100644 --- a/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java +++ b/line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java @@ -389,7 +389,7 @@ public interface LineMessagingClient { CompletableFuture getWebhookEndpoint(); /** - * Test webhook endpoint. + * Tests webhook endpoint. * * @see Test webhook endpoint */ diff --git a/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java b/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java index 07492bf1f..0ffee3365 100644 --- a/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java +++ b/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java @@ -31,9 +31,9 @@ @JsonDeserialize(builder = TestWebhookEndpointRequestBuilder.class) public class TestWebhookEndpointRequest { /** - * A valid webhook URL(Optional). + * A valid webhook URL. If {@literal null{, sends a test webhook event to a webhook endpoint that is already set to the channel. */ - URI endpoint; + @Nullable URI endpoint; @JsonPOJOBuilder(withPrefix = "") public static class TestWebhookEndpointRequestBuilder { diff --git a/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java b/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java index 54dd010e5..7b67171c9 100644 --- a/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java +++ b/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java @@ -36,7 +36,7 @@ public class GetWebhookEndpointResponse { URI endpoint; /* - * Webhook usage status. Send a webhook event from the LINE platform to the webhook URL only if enabled. + * Webhook usage status. The LINE platform sends a webhook event to {@link #endpoint} only if {@literal true}. */ boolean active; diff --git a/sample-manage-audience/src/main/java/com/linecorp/bot/messagingapidemoapp/controller/BotController.java b/sample-manage-audience/src/main/java/com/linecorp/bot/messagingapidemoapp/controller/BotController.java index d2204e4ad..75c1a35b5 100644 --- a/sample-manage-audience/src/main/java/com/linecorp/bot/messagingapidemoapp/controller/BotController.java +++ b/sample-manage-audience/src/main/java/com/linecorp/bot/messagingapidemoapp/controller/BotController.java @@ -73,7 +73,7 @@ public String testWebhook(Model model, TestWebhookEndpointRequest testWebhookEndpointRequest = builder.build(); TestWebhookEndpointResponse response = client.testWebhookEndpoint( testWebhookEndpointRequest - ).get(); + ).join(); model.addAttribute("response", response); return "bot/test_webhook"; } From f9084c91114e85e6c44ca55ee741a9549086defc Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Sat, 14 Nov 2020 10:13:35 +0900 Subject: [PATCH 4/5] Add link to common properties page in a javadoc. --- .../bot/model/response/TestWebhookEndpointResponse.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java b/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java index 008c5c044..d9c6bdf88 100644 --- a/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java +++ b/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java @@ -36,7 +36,8 @@ public class TestWebhookEndpointResponse { boolean success; /** - * Please refer to Common Properties. + * Please refer to + * Common Properties. */ Instant timestamp; From 984fe6f83f71817fa3ad457c28f4bdb7fa3945a5 Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Mon, 16 Nov 2020 22:47:29 +0900 Subject: [PATCH 5/5] fix javadoc issues --- .../bot/model/request/TestWebhookEndpointRequest.java | 5 +++-- .../bot/model/response/GetWebhookEndpointResponse.java | 5 +++-- .../bot/model/response/TestWebhookEndpointResponse.java | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java b/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java index 0ffee3365..80cc7d116 100644 --- a/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java +++ b/line-bot-model/src/main/java/com/linecorp/bot/model/request/TestWebhookEndpointRequest.java @@ -31,9 +31,10 @@ @JsonDeserialize(builder = TestWebhookEndpointRequestBuilder.class) public class TestWebhookEndpointRequest { /** - * A valid webhook URL. If {@literal null{, sends a test webhook event to a webhook endpoint that is already set to the channel. + * A valid webhook URL. If {@literal null}, sends a test webhook event to a webhook endpoint that is already + * set to the channel. */ - @Nullable URI endpoint; + URI endpoint; @JsonPOJOBuilder(withPrefix = "") public static class TestWebhookEndpointRequestBuilder { diff --git a/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java b/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java index 7b67171c9..b8987bdb7 100644 --- a/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java +++ b/line-bot-model/src/main/java/com/linecorp/bot/model/response/GetWebhookEndpointResponse.java @@ -31,12 +31,13 @@ @JsonDeserialize(builder = GetWebhookEndpointResponseBuilder.class) public class GetWebhookEndpointResponse { /** - * Webhook URL + * Webhook URL. */ URI endpoint; /* - * Webhook usage status. The LINE platform sends a webhook event to {@link #endpoint} only if {@literal true}. + * Webhook usage status. The LINE platform sends a webhook event to {@link #endpoint} only if + * {@literal true}. */ boolean active; diff --git a/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java b/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java index d9c6bdf88..a953a46f0 100644 --- a/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java +++ b/line-bot-model/src/main/java/com/linecorp/bot/model/response/TestWebhookEndpointResponse.java @@ -42,7 +42,8 @@ public class TestWebhookEndpointResponse { Instant timestamp; /** - * The HTTP status code. If the webhook response isn't received, the status code is set to zero or a negative number. + * The HTTP status code. If the webhook response isn't received, the status code is set to zero or a + * negative number. */ int statusCode;