Skip to content

Commit c5a5ed1

Browse files
github-actions[bot]github-actions
andauthored
Support new Membership API and Webhook (#1548)
line/line-openapi#86 # Support new Membership API and Webhook We have implemented and supported new API and Webhook about Membership. ## API to get a list of users who joined the membership You can obtain a list of user IDs for users who have joined the membership of your LINE Official Account by calling `client.getJoinedMembershipUsers(...)`. Documents: https://developers.line.biz/en/reference/messaging-api/#get-membership-user-ids ## Membership Webhook We have introduced new Webhook events `MembershipEvent` that indicates that a user has joined, left or renewed a membership of your LINE Official Account. Documents: https://developers.line.biz/en/reference/messaging-api/#membership-event ## For more details For more details, check out the announcement: https://developers.line.biz/en/news/2025/02/13/membership-api/ Co-authored-by: github-actions <[email protected]>
1 parent 41868b6 commit c5a5ed1

File tree

12 files changed

+435
-1
lines changed

12 files changed

+435
-1
lines changed

clients/line-bot-messaging-api-client/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ src/main/java/com/linecorp/bot/messaging/model/GenderDemographicFilter.java
6363
src/main/java/com/linecorp/bot/messaging/model/GetAggregationUnitNameListResponse.java
6464
src/main/java/com/linecorp/bot/messaging/model/GetAggregationUnitUsageResponse.java
6565
src/main/java/com/linecorp/bot/messaging/model/GetFollowersResponse.java
66+
src/main/java/com/linecorp/bot/messaging/model/GetJoinedMembershipUsersResponse.java
6667
src/main/java/com/linecorp/bot/messaging/model/GetMembershipSubscriptionResponse.java
6768
src/main/java/com/linecorp/bot/messaging/model/GetMessageContentTranscodingResponse.java
6869
src/main/java/com/linecorp/bot/messaging/model/GetWebhookEndpointResponse.java

clients/line-bot-messaging-api-client/src/main/java/com/linecorp/bot/messaging/client/MessagingApiClient.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.linecorp.bot.messaging.model.GetAggregationUnitNameListResponse;
3030
import com.linecorp.bot.messaging.model.GetAggregationUnitUsageResponse;
3131
import com.linecorp.bot.messaging.model.GetFollowersResponse;
32+
import com.linecorp.bot.messaging.model.GetJoinedMembershipUsersResponse;
3233
import com.linecorp.bot.messaging.model.GetMembershipSubscriptionResponse;
3334
import com.linecorp.bot.messaging.model.GetWebhookEndpointResponse;
3435
import com.linecorp.bot.messaging.model.GroupMemberCountResponse;
@@ -251,6 +252,24 @@ CompletableFuture<Result<MembersIdsResponse>> getGroupMembersIds(
251252
@GET("/v2/bot/group/{groupId}/summary")
252253
CompletableFuture<Result<GroupSummaryResponse>> getGroupSummary(@Path("groupId") String groupId);
253254

255+
/**
256+
* Get a list of user IDs who joined the membership.
257+
*
258+
* @param membershipId Membership plan ID. (required)
259+
* @param start A continuation token to get next remaining membership user IDs. Returned only when
260+
* there are remaining user IDs that weren&#39;t returned in the userIds property in the
261+
* previous request. The continuation token expires in 24 hours (86,400 seconds). (optional)
262+
* @param limit The max number of items to return for this API call. The value is set to 300 by
263+
* default, but the max acceptable value is 1000. (optional, default to 300)
264+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-membership-user-ids">
265+
* Documentation</a>
266+
*/
267+
@GET("/v2/bot/membership/{membershipId}/users/ids")
268+
CompletableFuture<Result<GetJoinedMembershipUsersResponse>> getJoinedMembershipUsers(
269+
@Path("membershipId") Integer membershipId,
270+
@Query("start") String start,
271+
@Query("limit") Integer limit);
272+
254273
/**
255274
* Get a list of memberships.
256275
*
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright 2023 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
/**
18+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
19+
* https://openapi-generator.tech Do not edit the class manually.
20+
*/
21+
package com.linecorp.bot.messaging.model;
22+
23+
24+
25+
import com.fasterxml.jackson.annotation.JsonInclude;
26+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
27+
import com.fasterxml.jackson.annotation.JsonProperty;
28+
import java.util.List;
29+
30+
/**
31+
* List of users who have joined the membership
32+
*
33+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-membership-user-ids">
34+
* Documentation</a>
35+
*/
36+
@JsonInclude(Include.NON_NULL)
37+
@javax.annotation.Generated(value = "com.linecorp.bot.codegen.LineJavaCodegenGenerator")
38+
public record GetJoinedMembershipUsersResponse(
39+
/**
40+
* A list of user IDs who joined the membership. Users who have not agreed to the bot user
41+
* agreement, are not following the bot, or are not active will be excluded. If there are no
42+
* users in the membership, an empty list will be returned.
43+
*/
44+
@JsonProperty("userIds") List<String> userIds,
45+
/**
46+
* A continuation token to get next remaining membership user IDs. Returned only when there are
47+
* remaining user IDs that weren&#39;t returned in the userIds property in the previous request.
48+
* The continuation token expires in 24 hours (86,400 seconds).
49+
*/
50+
@JsonProperty("next") String next) {
51+
52+
public static class Builder {
53+
private List<String> userIds;
54+
private String next;
55+
56+
public Builder(List<String> userIds) {
57+
58+
this.userIds = userIds;
59+
}
60+
61+
public Builder next(String next) {
62+
this.next = next;
63+
return this;
64+
}
65+
66+
public GetJoinedMembershipUsersResponse build() {
67+
return new GetJoinedMembershipUsersResponse(userIds, next);
68+
}
69+
}
70+
}

clients/line-bot-messaging-api-client/src/test/java/com/linecorp/bot/messaging/client/MessagingApiClientTest.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.linecorp.bot.messaging.model.GetAggregationUnitNameListResponse;
3939
import com.linecorp.bot.messaging.model.GetAggregationUnitUsageResponse;
4040
import com.linecorp.bot.messaging.model.GetFollowersResponse;
41+
import com.linecorp.bot.messaging.model.GetJoinedMembershipUsersResponse;
4142
import com.linecorp.bot.messaging.model.GetMembershipSubscriptionResponse;
4243
import com.linecorp.bot.messaging.model.GetWebhookEndpointResponse;
4344
import com.linecorp.bot.messaging.model.GroupMemberCountResponse;
@@ -540,6 +541,57 @@ public void getGroupSummaryTest() {
540541
// TODO: test validations
541542
}
542543

544+
@Test
545+
public void getJoinedMembershipUsersTest() {
546+
stubFor(
547+
get(urlPathTemplate("/v2/bot/membership/{membershipId}/users/ids"))
548+
.willReturn(
549+
aResponse()
550+
.withStatus(200)
551+
.withHeader("content-type", "application/json")
552+
.withBody("{}")));
553+
554+
Integer membershipId =
555+
Arranger.some(
556+
Integer.class,
557+
Map.of(
558+
"message",
559+
() -> new TextMessage("hello"),
560+
"recipient",
561+
() -> null,
562+
"filter",
563+
() -> null));
564+
565+
String start =
566+
Arranger.some(
567+
String.class,
568+
Map.of(
569+
"message",
570+
() -> new TextMessage("hello"),
571+
"recipient",
572+
() -> null,
573+
"filter",
574+
() -> null));
575+
576+
Integer limit =
577+
Arranger.some(
578+
Integer.class,
579+
Map.of(
580+
"message",
581+
() -> new TextMessage("hello"),
582+
"recipient",
583+
() -> null,
584+
"filter",
585+
() -> null));
586+
587+
GetJoinedMembershipUsersResponse response =
588+
api.getJoinedMembershipUsers(membershipId, start, limit).join().body();
589+
590+
assertThat(response).isNotNull();
591+
592+
// TODO: test validations
593+
}
594+
543595
@Test
544596
public void getMembershipListTest() {
545597
stubFor(

line-bot-webhook/.openapi-generator/FILES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ src/main/java/com/linecorp/bot/webhook/model/ImageMessageContent.java
2525
src/main/java/com/linecorp/bot/webhook/model/ImageSet.java
2626
src/main/java/com/linecorp/bot/webhook/model/JoinEvent.java
2727
src/main/java/com/linecorp/bot/webhook/model/JoinedMembers.java
28+
src/main/java/com/linecorp/bot/webhook/model/JoinedMembershipContent.java
2829
src/main/java/com/linecorp/bot/webhook/model/LeaveEvent.java
2930
src/main/java/com/linecorp/bot/webhook/model/LeftMembers.java
31+
src/main/java/com/linecorp/bot/webhook/model/LeftMembershipContent.java
3032
src/main/java/com/linecorp/bot/webhook/model/LinkContent.java
3133
src/main/java/com/linecorp/bot/webhook/model/LinkThingsContent.java
3234
src/main/java/com/linecorp/bot/webhook/model/LocationMessageContent.java
3335
src/main/java/com/linecorp/bot/webhook/model/MemberJoinedEvent.java
3436
src/main/java/com/linecorp/bot/webhook/model/MemberLeftEvent.java
37+
src/main/java/com/linecorp/bot/webhook/model/MembershipContent.java
38+
src/main/java/com/linecorp/bot/webhook/model/MembershipEvent.java
3539
src/main/java/com/linecorp/bot/webhook/model/Mention.java
3640
src/main/java/com/linecorp/bot/webhook/model/Mentionee.java
3741
src/main/java/com/linecorp/bot/webhook/model/MessageContent.java
@@ -42,6 +46,7 @@ src/main/java/com/linecorp/bot/webhook/model/PnpDelivery.java
4246
src/main/java/com/linecorp/bot/webhook/model/PnpDeliveryCompletionEvent.java
4347
src/main/java/com/linecorp/bot/webhook/model/PostbackContent.java
4448
src/main/java/com/linecorp/bot/webhook/model/PostbackEvent.java
49+
src/main/java/com/linecorp/bot/webhook/model/RenewedMembershipContent.java
4550
src/main/java/com/linecorp/bot/webhook/model/RoomSource.java
4651
src/main/java/com/linecorp/bot/webhook/model/ScenarioResult.java
4752
src/main/java/com/linecorp/bot/webhook/model/ScenarioResultThingsContent.java

line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/Event.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
@JsonSubTypes.Type(value = LeaveEvent.class, name = "leave"),
4040
@JsonSubTypes.Type(value = MemberJoinedEvent.class, name = "memberJoined"),
4141
@JsonSubTypes.Type(value = MemberLeftEvent.class, name = "memberLeft"),
42+
@JsonSubTypes.Type(value = MembershipEvent.class, name = "membership"),
4243
@JsonSubTypes.Type(value = MessageEvent.class, name = "message"),
4344
@JsonSubTypes.Type(value = ModuleEvent.class, name = "module"),
4445
@JsonSubTypes.Type(value = PostbackEvent.class, name = "postback"),
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2023 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
/**
18+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
19+
* https://openapi-generator.tech Do not edit the class manually.
20+
*/
21+
package com.linecorp.bot.webhook.model;
22+
23+
24+
25+
import com.fasterxml.jackson.annotation.JsonInclude;
26+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
27+
import com.fasterxml.jackson.annotation.JsonProperty;
28+
import com.fasterxml.jackson.annotation.JsonTypeName;
29+
30+
/** JoinedMembershipContent */
31+
@JsonTypeName("joined")
32+
@JsonInclude(Include.NON_NULL)
33+
@javax.annotation.Generated(value = "com.linecorp.bot.codegen.LineJavaCodegenGenerator")
34+
public record JoinedMembershipContent(
35+
/** The ID of the membership that the user joined. This is defined for each membership. */
36+
@JsonProperty("membershipId") Integer membershipId) implements MembershipContent {
37+
38+
public static class Builder {
39+
private Integer membershipId;
40+
41+
public Builder(Integer membershipId) {
42+
43+
this.membershipId = membershipId;
44+
}
45+
46+
public JoinedMembershipContent build() {
47+
return new JoinedMembershipContent(membershipId);
48+
}
49+
}
50+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2023 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
/**
18+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
19+
* https://openapi-generator.tech Do not edit the class manually.
20+
*/
21+
package com.linecorp.bot.webhook.model;
22+
23+
24+
25+
import com.fasterxml.jackson.annotation.JsonInclude;
26+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
27+
import com.fasterxml.jackson.annotation.JsonProperty;
28+
import com.fasterxml.jackson.annotation.JsonTypeName;
29+
30+
/** LeftMembershipContent */
31+
@JsonTypeName("left")
32+
@JsonInclude(Include.NON_NULL)
33+
@javax.annotation.Generated(value = "com.linecorp.bot.codegen.LineJavaCodegenGenerator")
34+
public record LeftMembershipContent(
35+
/** The ID of the membership that the user left. This is defined for each membership. */
36+
@JsonProperty("membershipId") Integer membershipId) implements MembershipContent {
37+
38+
public static class Builder {
39+
private Integer membershipId;
40+
41+
public Builder(Integer membershipId) {
42+
43+
this.membershipId = membershipId;
44+
}
45+
46+
public LeftMembershipContent build() {
47+
return new LeftMembershipContent(membershipId);
48+
}
49+
}
50+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2023 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
/**
18+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
19+
* https://openapi-generator.tech Do not edit the class manually.
20+
*/
21+
package com.linecorp.bot.webhook.model;
22+
23+
24+
25+
import com.fasterxml.jackson.annotation.JsonSubTypes;
26+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
27+
28+
/** Content of the membership event. */
29+
@JsonSubTypes({
30+
@JsonSubTypes.Type(value = JoinedMembershipContent.class, name = "joined"),
31+
@JsonSubTypes.Type(value = LeftMembershipContent.class, name = "left"),
32+
@JsonSubTypes.Type(value = RenewedMembershipContent.class, name = "renewed"),
33+
})
34+
@JsonTypeInfo(
35+
use = JsonTypeInfo.Id.NAME,
36+
include = JsonTypeInfo.As.PROPERTY,
37+
property = "type",
38+
visible = true)
39+
public interface MembershipContent {}

0 commit comments

Comments
 (0)