All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.linecorp.bot.client.LineMessagingClient Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
/*
 * 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.client;

import java.util.List;
import java.util.concurrent.CompletableFuture;

import com.linecorp.bot.model.Broadcast;
import com.linecorp.bot.model.Multicast;
import com.linecorp.bot.model.Narrowcast;
import com.linecorp.bot.model.PushMessage;
import com.linecorp.bot.model.ReplyMessage;
import com.linecorp.bot.model.event.source.GroupSource;
import com.linecorp.bot.model.event.source.RoomSource;
import com.linecorp.bot.model.profile.MembersIdsResponse;
import com.linecorp.bot.model.profile.UserProfileResponse;
import com.linecorp.bot.model.response.BotApiResponse;
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.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.demographics.GetFriendsDemographicsResponse;
import com.linecorp.bot.model.richmenu.RichMenu;
import com.linecorp.bot.model.richmenu.RichMenuIdResponse;
import com.linecorp.bot.model.richmenu.RichMenuListResponse;
import com.linecorp.bot.model.richmenu.RichMenuResponse;

public interface LineMessagingClient {
    /**
     * Reply to messages from users.
     *
     * 

Webhooks are used to notify you when an event occurs. For events that you can respond to, * a replyToken is issued for replying to messages. * *

Because the replyToken becomes invalid after a certain period of time, * responses should be sent as soon as a message is received. Reply tokens can only be used once. * * @see #pushMessage(PushMessage) * @see //developers.line.me/en/reference/messaging-api/#send-reply-message */ CompletableFuture replyMessage(ReplyMessage replyMessage); /** * Send messages to users when you want to. * *

INFO: Use of the Push Message API is limited to certain plans. * * @see #replyMessage(ReplyMessage) * @see //developers.line.me/en/reference/messaging-api/#send-push-message */ CompletableFuture pushMessage(PushMessage pushMessage); /** * Send messages to multiple users at any time. IDs of groups or rooms cannot be used. * *

INFO: Only available for plans which support push messages. * Messages cannot be sent to groups or rooms. * *

INFO: Use IDs returned via the webhook event of source users. IDs of groups or rooms cannot be used. * Do not use the LINE ID found on the LINE app.

* * @see #pushMessage(PushMessage) * @see //developers.line.me/en/reference/messaging-api/#send-multicast-messages */ CompletableFuture multicast(Multicast multicast); /** * Sends push messages to multiple users at any time. * Note: LINE@ accounts cannot call this API endpoint. Please migrate it to a LINE official account. * For more information, see * Migration of LINE@ accounts. */ CompletableFuture broadcast(Broadcast broadcast); /** * Sends a push message to multiple users. You can specify recipients using attributes (such as age, gender, * OS, and region) or by retargeting (audiences). Messages cannot be sent to groups or rooms. * *

Note: LINE-@ accounts cannot call this API endpoint. Please migrate it to a LINE official account. * For more information, see * Migration of LINE@ accounts. */ CompletableFuture narrowcast(Narrowcast broadcast); /** * Gets the status of a narrowcast message. */ CompletableFuture getNarrowcastProgress(String requestId); /** * Download image, video, and audio data sent from users. * * @see //developers.line.me/en/reference/messaging-api/#get-content * @deprecated use {@link LineBlobClient} instead. */ @Deprecated CompletableFuture getMessageContent(String messageId); /** * Gets the target limit for additional messages in the current month. The number of messages retrieved by * this operation includes the number of messages sent from LINE Official Account Manager. * Set a target limit with LINE Official Account Manager. For the procedures, refer to the LINE Official * Account Manager manual. * Note: LINE@ accounts cannot call this API endpoint. */ CompletableFuture getMessageQuota(); /** * Gets the number of messages sent in the current month. The number of messages retrieved by this * operation includes the number of messages sent from LINE Official Account Manager. The number of * messages retrieved by this operation is approximate. To get the correct number of sent messages, * use LINE Official Account Manager or execute API operations for getting the number of sent messages. * Note: LINE@ accounts cannot call this API endpoint. */ CompletableFuture getMessageQuotaConsumption(); /** * Gets the number of messages sent with the /bot/message/reply endpoint. Note that the number of messages * retrieved by this operation does not include the number of messages sent from LINE@ Manager. * * @param date Date the messages were sent. The format should be {@code yyyyMMdd} (for Example: * {@literal "20191231"}) and the timezone should be UTC+9. */ CompletableFuture getNumberOfSentReplyMessages(String date); /** * Gets the number of messages sent with the /bot/message/push endpoint. Note that the number of messages * retrieved by this operation does not include the number of messages sent from LINE@ Manager. * * @param date Date the messages were sent. The format should be {@code yyyyMMdd} (for Example: * {@literal "20191231"}) and the timezone should be UTC+9. */ CompletableFuture getNumberOfSentPushMessages(String date); /** * Gets the number of messages sent with the /bot/message/multicast endpoint. The number of messages * retrieved by this operation does not include the number of messages sent from LINE@ Manager. * * @param date Date the messages were sent. The format should be {@code yyyyMMdd} (for Example: * {@literal "20191231"}) and the timezone should be UTC+9. */ CompletableFuture getNumberOfSentMulticastMessages(String date); /** * Gets the number of messages sent with the {@code "/bot/message/broadcast"} endpoint. The number of * messages retrieved by this operation does not include the number of messages sent from LINE Official * Account Manager. * Note: LINE@ accounts cannot call this API endpoint. Please migrate it to a LINE official account. * For more information, see * Migration of LINE@ accounts. * * @param date Date the messages were sent. The format should be {@code yyyyMMdd} (for Example: * {@literal "20191231"}) and the timezone should be UTC+9. */ CompletableFuture getNumberOfSentBroadcastMessages(String date); /** * Get user profile information. * * @see //developers.line.me/en/reference/messaging-api/#get-profile */ CompletableFuture getProfile(String userId); /** * Get group member profile. * * @param groupId Identifier of the group. Can be get by {@link GroupSource#getGroupId()}. * @param userId Identifier of the user. * @see //developers.line.me/en/reference/messaging-api/#get-group-member-profile */ CompletableFuture getGroupMemberProfile(String groupId, String userId); /** * Get room member profile. * * @param roomId Identifier of the group. Can be get by {@link RoomSource#getRoomId()}. * @param userId Identifier of the user. * @see //developers.line.me/en/reference/messaging-api/#get-room-member-profile */ CompletableFuture getRoomMemberProfile(String roomId, String userId); /** * Get (a part of) group member list. * * @param start nullable continuationToken which can be get {@link MembersIdsResponse#getNext()} * @see //developers.line.me/en/reference/messaging-api/#get-group-member-user-ids * @see MembersIdsResponse#getNext() */ CompletableFuture getGroupMembersIds(String groupId, String start); /** * Get (a part of) room member list. * * @param start nullable continuationToken which can be get {@link MembersIdsResponse#getNext()} * @see //developers.line.me/en/reference/messaging-api/#get-room-member-user-ids * @see MembersIdsResponse#getNext() */ CompletableFuture getRoomMembersIds(String roomId, String start); /** * Leave a group. * * @see //developers.line.me/en/reference/messaging-api/#leave-group */ CompletableFuture leaveGroup(String groupId); /** * Leave a room. * * @see //developers.line.me/en/reference/messaging-api/#leave-room */ CompletableFuture leaveRoom(String roomId); /** * Get a rich menu. * * @see //developers.line.me/en/docs/messaging-api/reference/#get-rich-menu */ CompletableFuture getRichMenu(String richMenuId); /** * Creates a rich menu. * *

Note: You must upload a rich menu image * and link the rich menu to a user for the rich menu to be displayed. * You can create up to 10 rich menus for one bot. * * @see //developers.line.me/en/docs/messaging-api/reference/#create-rich-menu */ CompletableFuture createRichMenu(RichMenu richMenu); /** * Deletes a rich menu. * * @see //developers.line.me/en/reference/messaging-api/#delete-rich-menu */ CompletableFuture deleteRichMenu(String richMenuId); /** * Get rich menu ID of user. * * @see //developers.line.me/en/reference/messaging-api/#get-rich-menu-id-of-user */ CompletableFuture getRichMenuIdOfUser(String userId); /** * Link rich menu to user. * * @see //developers.line.me/en/docs/messaging-api/reference/#link-rich-menu-to-user */ CompletableFuture linkRichMenuIdToUser(String userId, String richMenuId); /** * Link rich menu to users. * * @see * Link rich menu to multiple users */ CompletableFuture linkRichMenuIdToUsers(List userIds, String richMenuId); /** * Unlink rich menu from user. * * @see //developers.line.me/en/docs/messaging-api/reference/#unlink-rich-menu-from-user */ CompletableFuture unlinkRichMenuIdFromUser(String userId); /** * Unlink rich menu from users. * * @see * Unlink rich menu to multiple users */ CompletableFuture unlinkRichMenuIdFromUsers(List userIds); /** * Download rich menu image. * * @see //developers.line.me/en/docs/messaging-api/reference/#download-rich-menu-image * @deprecated use {@link LineBlobClient} instead. */ @Deprecated CompletableFuture getRichMenuImage(String richMenuId); /** * Set RichMenu image. * * @see //developers.line.me/en/docs/messaging-api/reference/#upload-rich-menu-image * @deprecated use {@link LineBlobClient} instead. */ @Deprecated CompletableFuture setRichMenuImage( String richMenuId, String contentType, byte[] content); /** * Gets a list of all uploaded rich menus. * * @see //developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-list */ CompletableFuture getRichMenuList(); /** * Set default rich menu. * * @see //developers.line.me/en/reference/messaging-api/#set-default-rich-menu */ CompletableFuture setDefaultRichMenu(String richMenuId); /** * Get default rich menu ID. * * @see //developers.line.me/en/reference/messaging-api/#get-default-rich-menu-id */ CompletableFuture getDefaultRichMenuId(); /** * Cancel default rich menu. * * @see //developers.line.me/en/reference/messaging-api/#cancel-default-rich-menu */ CompletableFuture cancelDefaultRichMenu(); /** * Issues a link token used for the account link feature. * * @see Issue link token */ CompletableFuture issueLinkToken(String userId); /** * Get number of message deliveries. * * @see LineMessagingService#getNumberOfMessageDeliveries(String) */ CompletableFuture getNumberOfMessageDeliveries(String date); /** * Gets the number of users who have added the bot on or before a specified date. */ CompletableFuture getNumberOfFollowers(String date); /** * Returns statistics about how users interact with narrowcast messages or broadcast messages sent from your * LINE Official Account. * *

You can get statistics per message or per bubble.

* @param requestId Request ID of a narrowcast message or broadcast message. Each Messaging API request has * a request ID. Find it in the response headers. */ CompletableFuture getMessageEvent(String requestId); /** * Retrieves the demographic attributes for a bot's friends. * * @see Get friends demographics */ CompletableFuture getFriendsDemographics(); static LineMessagingClientBuilder builder(String channelToken) { return builder(FixedChannelTokenSupplier.of(channelToken)); } static LineMessagingClientBuilder builder(ChannelTokenSupplier channelTokenSupplier) { return new LineMessagingClientBuilder().channelTokenSupplier(channelTokenSupplier); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy