forked from Viber/viber-bot-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponse.java
More file actions
61 lines (52 loc) · 2.21 KB
/
Copy pathResponse.java
File metadata and controls
61 lines (52 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.viber.bot;
import com.google.common.util.concurrent.ListenableFuture;
import com.viber.bot.api.ApiException;
import com.viber.bot.api.ViberBot;
import com.viber.bot.message.Message;
import com.viber.bot.message.TextMessage;
import com.viber.bot.profile.UserProfile;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;
import java.util.Collection;
@Immutable
public class Response {
private final UserProfile to;
private final ViberBot bot;
public Response(final UserProfile to, final ViberBot bot) {
this.to = to;
this.bot = bot;
}
/**
* Shorthand for {@link ViberBot#sendMessage(UserProfile, Collection)}
* Where the {@link UserProfile} is already set.
*
* @param messages collection of messages to be sent
* @return future which contains a collection of message tokens as strings, that may throw {@link ApiException}.
* @see ViberBot#sendMessage(UserProfile, Collection)
*/
public ListenableFuture<Collection<String>> send(final @Nonnull Collection<Message> messages) {
return bot.sendMessage(to, messages);
}
/**
* Shorthand for {@link ViberBot#sendMessage(UserProfile, Message...)}
* Where the {@link UserProfile} is already set.
*
* @param messages collection of messages to be sent
* @return future which contains a collection of message tokens as strings, that may throw {@link ApiException}.
* @see ViberBot#sendMessage(UserProfile, Message...)
*/
public ListenableFuture<Collection<String>> send(final @Nonnull Message... messages) {
return bot.sendMessage(to, messages);
}
/**
* Shorthand for {@link ViberBot#sendMessage(UserProfile, Message...)}
* The method will create a {@link TextMessage} for you with the String provided to it.
*
* @param textMessage string to be as text for the message
* @return future which contains a collection of message tokens as strings, that may throw {@link ApiException}.
* @see ViberBot#sendMessage(UserProfile, Message...)
*/
public ListenableFuture<Collection<String>> send(final @Nonnull String textMessage) {
return bot.sendMessage(to, new TextMessage(textMessage));
}
}