Skip to content

Commit d8b6b27

Browse files
authored
Merge pull request #487 from kazuki-ma/ManageAudienceClient
NON-ISSUE Split ManageAudienceClient from LineMessagingClient.
2 parents f17b037 + ff7192c commit d8b6b27

File tree

14 files changed

+978
-432
lines changed

14 files changed

+978
-432
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2020 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+
package com.linecorp.bot.client;
18+
19+
import java.net.URI;
20+
21+
import com.fasterxml.jackson.databind.DeserializationFeature;
22+
import com.fasterxml.jackson.databind.ObjectMapper;
23+
24+
import com.linecorp.bot.model.objectmapper.ModelObjectMapper;
25+
26+
import retrofit2.Retrofit;
27+
import retrofit2.converter.jackson.JacksonConverterFactory;
28+
29+
public class ManageAudienceClientFactory {
30+
public static ManageAudienceClient create(IntegrationTestSettings settings) {
31+
ObjectMapper objectMapper = ModelObjectMapper
32+
.createNewObjectMapper()
33+
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
34+
settings.isFailOnUnknownProperties());
35+
36+
Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
37+
.addConverterFactory(JacksonConverterFactory.create(objectMapper));
38+
39+
return ManageAudienceClient
40+
.builder()
41+
.channelToken(settings.getToken())
42+
.apiEndPoint(URI.create(settings.getEndpoint()))
43+
.retrofitBuilder(retrofitBuilder)
44+
.build();
45+
}
46+
}

line-bot-api-client/src/integrationTest/java/com/linecorp/bot/client/ManageAudienceIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848

4949
@Slf4j
5050
public class ManageAudienceIntegrationTest {
51-
private LineMessagingClient target;
51+
private ManageAudienceClient target;
5252
private IntegrationTestSettings settings;
5353

5454
@Before
5555
public void setUp() throws IOException {
5656
settings = IntegrationTestSettingsLoader.load();
57-
target = LineMessagingClientFactory.create(settings);
57+
target = ManageAudienceClientFactory.create(settings);
5858
}
5959

6060
@Test

line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClient.java

Lines changed: 7 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@
2626
import com.linecorp.bot.model.ReplyMessage;
2727
import com.linecorp.bot.model.event.source.GroupSource;
2828
import com.linecorp.bot.model.event.source.RoomSource;
29-
import com.linecorp.bot.model.manageaudience.AudienceGroupCreateRoute;
30-
import com.linecorp.bot.model.manageaudience.AudienceGroupStatus;
31-
import com.linecorp.bot.model.manageaudience.request.AddAudienceToAudienceGroupRequest;
32-
import com.linecorp.bot.model.manageaudience.request.CreateAudienceGroupRequest;
33-
import com.linecorp.bot.model.manageaudience.request.CreateClickBasedAudienceGroupRequest;
34-
import com.linecorp.bot.model.manageaudience.request.CreateImpBasedAudienceGroupRequest;
35-
import com.linecorp.bot.model.manageaudience.request.UpdateAudienceGroupAuthorityLevelRequest;
36-
import com.linecorp.bot.model.manageaudience.request.UpdateAudienceGroupDescriptionRequest;
37-
import com.linecorp.bot.model.manageaudience.response.CreateAudienceGroupResponse;
38-
import com.linecorp.bot.model.manageaudience.response.CreateClickBasedAudienceGroupResponse;
39-
import com.linecorp.bot.model.manageaudience.response.CreateImpBasedAudienceGroupResponse;
40-
import com.linecorp.bot.model.manageaudience.response.GetAudienceDataResponse;
41-
import com.linecorp.bot.model.manageaudience.response.GetAudienceGroupAuthorityLevelResponse;
42-
import com.linecorp.bot.model.manageaudience.response.GetAudienceGroupsResponse;
4329
import com.linecorp.bot.model.profile.MembersIdsResponse;
4430
import com.linecorp.bot.model.profile.UserProfileResponse;
4531
import com.linecorp.bot.model.response.BotApiResponse;
@@ -56,8 +42,6 @@
5642
import com.linecorp.bot.model.richmenu.RichMenuListResponse;
5743
import com.linecorp.bot.model.richmenu.RichMenuResponse;
5844

59-
import retrofit2.http.Body;
60-
6145
public interface LineMessagingClient {
6246
/**
6347
* Reply to messages from users.
@@ -152,7 +136,7 @@ public interface LineMessagingClient {
152136
* retrieved by this operation does not include the number of messages sent from LINE@ Manager.
153137
*
154138
* @param date Date the messages were sent. The format should be {@code yyyyMMdd} (for Example:
155-
* {@literal "20191231"}) and the timezone should be UTC+9.
139+
* {@literal "20191231"}) and the timezone should be UTC+9.
156140
*/
157141
CompletableFuture<NumberOfMessagesResponse> getNumberOfSentReplyMessages(String date);
158142

@@ -161,7 +145,7 @@ public interface LineMessagingClient {
161145
* retrieved by this operation does not include the number of messages sent from LINE@ Manager.
162146
*
163147
* @param date Date the messages were sent. The format should be {@code yyyyMMdd} (for Example:
164-
* {@literal "20191231"}) and the timezone should be UTC+9.
148+
* {@literal "20191231"}) and the timezone should be UTC+9.
165149
*/
166150
CompletableFuture<NumberOfMessagesResponse> getNumberOfSentPushMessages(String date);
167151

@@ -170,7 +154,7 @@ public interface LineMessagingClient {
170154
* retrieved by this operation does not include the number of messages sent from LINE@ Manager.
171155
*
172156
* @param date Date the messages were sent. The format should be {@code yyyyMMdd} (for Example:
173-
* {@literal "20191231"}) and the timezone should be UTC+9.
157+
* {@literal "20191231"}) and the timezone should be UTC+9.
174158
*/
175159
CompletableFuture<NumberOfMessagesResponse> getNumberOfSentMulticastMessages(String date);
176160

@@ -183,7 +167,7 @@ public interface LineMessagingClient {
183167
* Migration of LINE@ accounts</a>.
184168
*
185169
* @param date Date the messages were sent. The format should be {@code yyyyMMdd} (for Example:
186-
* {@literal "20191231"}) and the timezone should be UTC+9.
170+
* {@literal "20191231"}) and the timezone should be UTC+9.
187171
*/
188172
CompletableFuture<NumberOfMessagesResponse> getNumberOfSentBroadcastMessages(String date);
189173

@@ -199,7 +183,6 @@ public interface LineMessagingClient {
199183
*
200184
* @param groupId Identifier of the group. Can be get by {@link GroupSource#getGroupId()}.
201185
* @param userId Identifier of the user.
202-
*
203186
* @see <a href="https://developers.line.me/en/reference/messaging-api/#get-group-member-profile">//developers.line.me/en/reference/messaging-api/#get-group-member-profile</a>
204187
*/
205188
CompletableFuture<UserProfileResponse> getGroupMemberProfile(String groupId, String userId);
@@ -209,7 +192,6 @@ public interface LineMessagingClient {
209192
*
210193
* @param roomId Identifier of the group. Can be get by {@link RoomSource#getRoomId()}.
211194
* @param userId Identifier of the user.
212-
*
213195
* @see <a href="https://developers.line.me/en/reference/messaging-api/#get-room-member-profile">//developers.line.me/en/reference/messaging-api/#get-room-member-profile</a>
214196
*/
215197
CompletableFuture<UserProfileResponse> getRoomMemberProfile(String roomId, String userId);
@@ -218,7 +200,6 @@ public interface LineMessagingClient {
218200
* Get (a part of) group member list.
219201
*
220202
* @param start nullable continuationToken which can be get {@link MembersIdsResponse#getNext()}
221-
*
222203
* @see <a href="https://developers.line.me/en/reference/messaging-api/#get-group-member-user-ids">//developers.line.me/en/reference/messaging-api/#get-group-member-user-ids</a>
223204
* @see MembersIdsResponse#getNext()
224205
*/
@@ -228,7 +209,6 @@ public interface LineMessagingClient {
228209
* Get (a part of) room member list.
229210
*
230211
* @param start nullable continuationToken which can be get {@link MembersIdsResponse#getNext()}
231-
*
232212
* @see <a href="https://developers.line.me/en/reference/messaging-api/#get-room-member-user-ids">//developers.line.me/en/reference/messaging-api/#get-room-member-user-ids</a>
233213
* @see MembersIdsResponse#getNext()
234214
*/
@@ -291,7 +271,7 @@ public interface LineMessagingClient {
291271
* Link rich menu to users.
292272
*
293273
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-users">
294-
* Link rich menu to multiple users</a>
274+
* Link rich menu to multiple users</a>
295275
*/
296276
CompletableFuture<BotApiResponse> linkRichMenuIdToUsers(List<String> userIds, String richMenuId);
297277

@@ -306,7 +286,7 @@ public interface LineMessagingClient {
306286
* Unlink rich menu from users.
307287
*
308288
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#unlink-rich-menu-from-users">
309-
* Unlink rich menu to multiple users</a>
289+
* Unlink rich menu to multiple users</a>
310290
*/
311291
CompletableFuture<BotApiResponse> unlinkRichMenuIdFromUsers(List<String> userIds);
312292

@@ -366,6 +346,7 @@ CompletableFuture<BotApiResponse> setRichMenuImage(
366346

367347
/**
368348
* Get number of message deliveries.
349+
*
369350
* @see LineMessagingService#getNumberOfMessageDeliveries(String)
370351
*/
371352
CompletableFuture<GetNumberOfMessageDeliveriesResponse> getNumberOfMessageDeliveries(String date);
@@ -382,103 +363,6 @@ CompletableFuture<BotApiResponse> setRichMenuImage(
382363
*/
383364
CompletableFuture<GetFriendsDemographicsResponse> getFriendsDemographics();
384365

385-
/**
386-
* Creates an audience for uploading user IDs. You can create up to 1,000 audiences.
387-
*
388-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group">
389-
* Create audience for uploading user IDs</a>
390-
*/
391-
CompletableFuture<CreateAudienceGroupResponse> createAudienceGroup(CreateAudienceGroupRequest request);
392-
393-
/**
394-
* Adds new user IDs or IFAs to an audience for uploading user IDs.
395-
*
396-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group">
397-
* Add user IDs or Identifiers for Advertisers (IFAs) to an audience for uploading user IDs</a>
398-
*/
399-
CompletableFuture<BotApiResponse> addAudienceToAudienceGroup(
400-
AddAudienceToAudienceGroupRequest request);
401-
402-
/**
403-
* Creates an audience for click-based retargeting.
404-
*
405-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-click-audience-group">
406-
* Create audience for click-based retargeting</a>
407-
*/
408-
CompletableFuture<CreateClickBasedAudienceGroupResponse> createClickBasedAudienceGroup(
409-
CreateClickBasedAudienceGroupRequest request);
410-
411-
/**
412-
* Creates an audience for impression-based retargeting.
413-
*
414-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-imp-audience-group">
415-
* Create audience for impression-based retargeting</a>
416-
*/
417-
CompletableFuture<CreateImpBasedAudienceGroupResponse> createImpBasedAudienceGroup(
418-
CreateImpBasedAudienceGroupRequest request);
419-
420-
/**
421-
* Renames an existing audience.
422-
*
423-
* @param audienceGroupId The audience ID.
424-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#set-description-audience-group">
425-
* Rename an audience</a>
426-
*/
427-
CompletableFuture<BotApiResponse> updateAudienceGroupDescription(
428-
long audienceGroupId, UpdateAudienceGroupDescriptionRequest request);
429-
430-
/**
431-
* Deletes an audience.
432-
*
433-
* @param audienceGroupId The audience ID.
434-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#delete-audience-group">
435-
* Delete audience</a>
436-
*/
437-
CompletableFuture<BotApiResponse> deleteAudienceGroup(long audienceGroupId);
438-
439-
/**
440-
* Gets audience data.
441-
*
442-
* @param audienceGroupId The audience ID.
443-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-audience-group">
444-
* Get audience data</a>
445-
*/
446-
CompletableFuture<GetAudienceDataResponse> getAudienceData(long audienceGroupId);
447-
448-
/**
449-
* Gets data for more than one audience.
450-
*
451-
* @param page The page to return when getting (paginated) results. Specify a value of 1 or more.
452-
* @param description The name of the audience(s) to return. You can search for partial matches.
453-
* Comparisons are case-insensitive, so the names AUDIENCE and audience are considered
454-
* identical.
455-
* @param status The audience's status.
456-
* @param size The number of audiences per page. This is 20 by default.
457-
* Max: 40
458-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-audience-groups">
459-
* Get data for multiple audiences</a>
460-
*/
461-
CompletableFuture<GetAudienceGroupsResponse> getAudienceGroups(
462-
long page, String description, AudienceGroupStatus status, Long size,
463-
Boolean includesExternalPublicGroups, AudienceGroupCreateRoute createRoute);
464-
465-
/**
466-
* Get audience group authority level.
467-
*
468-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-authority-level">
469-
* Get authority level</a>
470-
*/
471-
CompletableFuture<GetAudienceGroupAuthorityLevelResponse> getAudienceGroupAuthorityLevel();
472-
473-
/**
474-
* Update audience group authority level.
475-
*
476-
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#change-authority-level">
477-
* Change authority level</a>
478-
*/
479-
CompletableFuture<BotApiResponse> updateAudienceGroupAuthorityLevel(
480-
@Body UpdateAudienceGroupAuthorityLevelRequest request);
481-
482366
static LineMessagingClientBuilder builder(String channelToken) {
483367
return builder(FixedChannelTokenSupplier.of(channelToken));
484368
}

line-bot-api-client/src/main/java/com/linecorp/bot/client/LineMessagingClientImpl.java

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,6 @@
2727
import com.linecorp.bot.model.Narrowcast;
2828
import com.linecorp.bot.model.PushMessage;
2929
import com.linecorp.bot.model.ReplyMessage;
30-
import com.linecorp.bot.model.manageaudience.AudienceGroupCreateRoute;
31-
import com.linecorp.bot.model.manageaudience.AudienceGroupStatus;
32-
import com.linecorp.bot.model.manageaudience.request.AddAudienceToAudienceGroupRequest;
33-
import com.linecorp.bot.model.manageaudience.request.CreateAudienceGroupRequest;
34-
import com.linecorp.bot.model.manageaudience.request.CreateClickBasedAudienceGroupRequest;
35-
import com.linecorp.bot.model.manageaudience.request.CreateImpBasedAudienceGroupRequest;
36-
import com.linecorp.bot.model.manageaudience.request.UpdateAudienceGroupAuthorityLevelRequest;
37-
import com.linecorp.bot.model.manageaudience.request.UpdateAudienceGroupDescriptionRequest;
38-
import com.linecorp.bot.model.manageaudience.response.CreateAudienceGroupResponse;
39-
import com.linecorp.bot.model.manageaudience.response.CreateClickBasedAudienceGroupResponse;
40-
import com.linecorp.bot.model.manageaudience.response.CreateImpBasedAudienceGroupResponse;
41-
import com.linecorp.bot.model.manageaudience.response.GetAudienceDataResponse;
42-
import com.linecorp.bot.model.manageaudience.response.GetAudienceGroupAuthorityLevelResponse;
43-
import com.linecorp.bot.model.manageaudience.response.GetAudienceGroupsResponse;
4430
import com.linecorp.bot.model.profile.MembersIdsResponse;
4531
import com.linecorp.bot.model.profile.UserProfileResponse;
4632
import com.linecorp.bot.model.response.BotApiResponse;
@@ -64,7 +50,6 @@
6450
import retrofit2.Call;
6551
import retrofit2.Callback;
6652
import retrofit2.Response;
67-
import retrofit2.http.Body;
6853

6954
/**
7055
* Proxy implementation of {@link LineMessagingClient} to hind internal implementation.
@@ -290,66 +275,6 @@ public CompletableFuture<GetNumberOfFollowersResponse> getNumberOfFollowers(Stri
290275
return toFuture(retrofitImpl.getNumberOfFollowers(date));
291276
}
292277

293-
@Override
294-
public CompletableFuture<CreateAudienceGroupResponse> createAudienceGroup(
295-
CreateAudienceGroupRequest request) {
296-
return toFuture(retrofitImpl.createAudienceGroup(request));
297-
}
298-
299-
@Override
300-
public CompletableFuture<BotApiResponse> addAudienceToAudienceGroup(
301-
AddAudienceToAudienceGroupRequest request) {
302-
return toBotApiFuture(retrofitImpl.addAudienceToAudienceGroup(request));
303-
}
304-
305-
@Override
306-
public CompletableFuture<CreateClickBasedAudienceGroupResponse> createClickBasedAudienceGroup(
307-
CreateClickBasedAudienceGroupRequest request) {
308-
return toFuture(retrofitImpl.createClickBasedAudienceGroup(request));
309-
}
310-
311-
@Override
312-
public CompletableFuture<CreateImpBasedAudienceGroupResponse> createImpBasedAudienceGroup(
313-
CreateImpBasedAudienceGroupRequest request) {
314-
return toFuture(retrofitImpl.createImpBasedAudienceGroup(request));
315-
}
316-
317-
@Override
318-
public CompletableFuture<BotApiResponse> updateAudienceGroupDescription(
319-
long audienceGroupId, UpdateAudienceGroupDescriptionRequest request) {
320-
return toBotApiFuture(retrofitImpl.updateAudienceGroupDescription(audienceGroupId, request));
321-
}
322-
323-
@Override
324-
public CompletableFuture<BotApiResponse> deleteAudienceGroup(long audienceGroupId) {
325-
return toBotApiFuture(retrofitImpl.deleteAudienceGroup(audienceGroupId));
326-
}
327-
328-
@Override
329-
public CompletableFuture<GetAudienceGroupsResponse> getAudienceGroups(
330-
long page, String description, AudienceGroupStatus status, Long size,
331-
Boolean includesExternalPublicGroups, AudienceGroupCreateRoute createRoute) {
332-
return toFuture(retrofitImpl.getAudienceGroups(
333-
page, description, status, size,
334-
includesExternalPublicGroups, createRoute));
335-
}
336-
337-
@Override
338-
public CompletableFuture<GetAudienceDataResponse> getAudienceData(long audienceGroupId) {
339-
return toFuture(retrofitImpl.getAudienceData(audienceGroupId));
340-
}
341-
342-
@Override
343-
public CompletableFuture<GetAudienceGroupAuthorityLevelResponse> getAudienceGroupAuthorityLevel() {
344-
return toFuture(retrofitImpl.getAudienceGroupAuthorityLevel());
345-
}
346-
347-
@Override
348-
public CompletableFuture<BotApiResponse> updateAudienceGroupAuthorityLevel(
349-
@Body UpdateAudienceGroupAuthorityLevelRequest request) {
350-
return toBotApiFuture(retrofitImpl.updateAudienceGroupAuthorityLevel(request));
351-
}
352-
353278
// TODO: Extract this method.
354279
static <T> CompletableFuture<T> toFuture(Call<T> callToWrap) {
355280
final CallbackAdaptor<T> completableFuture = new CallbackAdaptor<>();

0 commit comments

Comments
 (0)