INFO: Use IDs returned via the webhook event of source users. IDs of groups or rooms cannot be used.
23 | */ 24 | private final SetRich menu images must be one of the following sizes: 2500x1686, 2500x843. */ 10 | RichMenuSize getSize(); 11 | 12 | /** true to display the rich menu by default. Otherwise, false. */ 13 | boolean isSelected(); 14 | 15 | /** 16 | * Name of the rich menu. This value can be used to help manage your rich menus and is not displayed to users. 17 | * 18 | *
Maximum of 300 characters. 19 | */ 20 | String getName(); 21 | 22 | /** 23 | * Text displayed in the chat bar. Maximum of 14 characters. 24 | */ 25 | String getChatBarText(); 26 | 27 | /** 28 | * Array of {@link RichMenuArea} objects which define the coordinates and size of tappable areas. 29 | * 30 | *
Maximum of 20 area objects.
31 | */
32 | List Rich menu images must be one of the following sizes: 2500x1686, 2500x843.
15 | */
16 | RichMenuSize size;
17 |
18 | /** true to display the rich menu by default. Otherwise, false. */
19 | boolean selected;
20 |
21 | /**
22 | * Name of the rich menu. This value can be used to help manage your rich menus and is not displayed to users.
23 | *
24 | * Maximum of 300 characters.
25 | */
26 | String name;
27 |
28 | /**
29 | * Text displayed in the chat bar.
30 | *
31 | * Maximum of 14 characters.
32 | */
33 | String chatBarText;
34 |
35 | /**
36 | * Array of {@link RichMenuArea} objects which define the coordinates and size of tappable areas.
37 | *
38 | * Maximum of 20 area objects.
39 | */
40 | List Max: 100 user IDs
22 | */
23 | List Returned if and only if there are more user IDs remaining.
39 | */
40 | public Optional
25 | * Interface which specifies the actions and tappable regions of an imagemap.
26 | * This annotation serves as a specialization of {@link Component @Component},
32 | * allowing for implementation classes to be autodetected through classpath scanning.
33 | */
34 | @Beta
35 | @Target(ElementType.TYPE)
36 | @Component
37 | @Retention(RetentionPolicy.RUNTIME)
38 | public @interface LineMessageHandler {}
39 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/event/source/Source.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model.event.source;
18 |
19 | import com.fasterxml.jackson.annotation.JsonSubTypes;
20 | import com.fasterxml.jackson.annotation.JsonTypeInfo;
21 |
22 | @JsonSubTypes({
23 | @JsonSubTypes.Type(UserSource.class),
24 | @JsonSubTypes.Type(GroupSource.class),
25 | @JsonSubTypes.Type(RoomSource.class),
26 | })
27 | @JsonTypeInfo(
28 | use = JsonTypeInfo.Id.NAME,
29 | include = JsonTypeInfo.As.PROPERTY,
30 | property = "type",
31 | defaultImpl = UnknownSource.class,
32 | visible = true
33 | )
34 | public interface Source {
35 | String getUserId();
36 |
37 | /**
38 | * message/event sender id. It might be userId/roomId/roomId.
39 | * @return message/event sender id
40 | */
41 | String getSenderId();
42 | }
43 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/message/template/ImageCarouselTemplate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model.message.template;
18 |
19 | import com.fasterxml.jackson.annotation.JsonCreator;
20 | import com.fasterxml.jackson.annotation.JsonProperty;
21 | import com.fasterxml.jackson.annotation.JsonTypeName;
22 | import lombok.Value;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * Template message with multiple columns which can be cycled like a carousel.
28 | */
29 | @Value
30 | @JsonTypeName("image_carousel")
31 | public class ImageCarouselTemplate implements Template {
32 | /**
33 | * List of columns(Max: 5)
34 | */
35 | private final List Rich menu images must be one of the following sizes: 2500x1686, 2500x843.
18 | */
19 | RichMenuSize size;
20 |
21 | /** true to display the rich menu by default. Otherwise, false. */
22 | boolean selected;
23 |
24 | /**
25 | * Name of the rich menu. This value can be used to help manage your rich menus and is not displayed to users.
26 | *
27 | * Maximum of 300 characters.
28 | */
29 | String name;
30 |
31 | /**
32 | * Text displayed in the chat bar.
33 | *
34 | * Maximum of 14 characters.
35 | */
36 | String chatBarText;
37 |
38 | /**
39 | * Array of {@link RichMenuArea} objects which define the coordinates and size of tappable areas.
40 | *
41 | * Maximum of 20 area objects.
42 | */
43 | List
29 | * Respond to events from users, groups, and rooms.
30 | *
32 | * 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.
33 | *
35 | * 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.
36 | * If you want serialize/deserialize of this object, please use Jackson's ObjectMapper with
29 | *
30 | *
30 | * When this action is tapped, a postback event is returned via webhook with the specified string in the data field.
31 | *
34 | * If you have included the text field, the string in the text field is sent as a message from the user.
35 | * Specify a RGB color value. The default value is
29 | *
34 | */
35 | private final String originalContentUrl;
36 |
37 | /**
38 | * Length of audio file (milliseconds)
39 | */
40 | private final Integer duration;
41 | }
42 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/profile/MembersIdsResponse.java:
--------------------------------------------------------------------------------
1 | package com.linecorp.bot.model.profile;
2 |
3 | import static java.util.Objects.requireNonNull;
4 |
5 | import java.util.List;
6 | import java.util.Optional;
7 |
8 | import com.fasterxml.jackson.annotation.JsonCreator;
9 | import com.fasterxml.jackson.annotation.JsonProperty;
10 |
11 | import lombok.Value;
12 |
13 | /**
14 | * @see //devdocs.line.me#get-group-room-member-ids
15 | */
16 | @Value
17 | public class MembersIdsResponse {
18 | /**
19 | * List of user IDs of the members in the group or room.
20 | *
21 | *
40 | * Max: 5
41 | */
42 | private final List
29 | *
34 | */
35 | private final String originalContentUrl;
36 |
37 | /**
38 | * URL of preview image
39 | *
40 | *
45 | */
46 | private final String previewImageUrl;
47 | }
48 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/event/message/TextMessageContent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model.event.message;
18 |
19 | import com.fasterxml.jackson.annotation.JsonCreator;
20 | import com.fasterxml.jackson.annotation.JsonProperty;
21 | import com.fasterxml.jackson.annotation.JsonTypeName;
22 |
23 | import lombok.Value;
24 |
25 | /**
26 | * Message content for text
27 | */
28 | @Value
29 | @JsonTypeName("text")
30 | public class TextMessageContent implements MessageContent {
31 | private final String id;
32 | /**
33 | * Message text
34 | */
35 | private final String text;
36 |
37 | @JsonCreator
38 | public TextMessageContent(
39 | @JsonProperty("id") String id,
40 | @JsonProperty("text") String text) {
41 | this.id = id;
42 | this.text = text;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/message/imagemap/URIImagemapAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model.message.imagemap;
18 |
19 | import com.fasterxml.jackson.annotation.JsonProperty;
20 | import com.fasterxml.jackson.annotation.JsonTypeName;
21 |
22 | import lombok.Value;
23 |
24 | /**
25 | *
26 | */
27 | @Value
28 | @JsonTypeName("uri")
29 | public class URIImagemapAction implements ImagemapAction {
30 | /**
31 | * Webpage URL
32 | */
33 | private final String linkUri;
34 |
35 | /**
36 | * Defined tappable area
37 | */
38 | private final ImagemapArea area;
39 |
40 | public URIImagemapAction(@JsonProperty("linkUri") String linkUri,
41 | @JsonProperty("area") ImagemapArea area) {
42 | this.linkUri = linkUri;
43 | this.area = area;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/line-bot-spring-boot/src/main/java/com/linecorp/bot/spring/boot/annotation/LineMessageHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.spring.boot.annotation;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | import org.springframework.stereotype.Component;
25 |
26 | import com.google.common.annotations.Beta;
27 |
28 | /**
29 | * Indicates that an annotated class has a LINE Messaging Event Handler method.
30 | *
31 | *
35 | * Max: 20 characters
36 | */
37 | private final String label;
38 |
39 | /**
40 | * URI opened when the action is performed
41 | * http, https, tel
42 | */
43 | private final String uri;
44 |
45 | @JsonCreator
46 | public URIAction(
47 | @JsonProperty("label") String label,
48 | @JsonProperty("uri") String uri) {
49 | this.label = label;
50 | this.uri = uri;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/richmenu/RichMenuResponse.java:
--------------------------------------------------------------------------------
1 | package com.linecorp.bot.model.richmenu;
2 |
3 | import java.util.List;
4 |
5 | import com.fasterxml.jackson.annotation.JsonCreator;
6 |
7 | import lombok.Value;
8 |
9 | @Value
10 | public class RichMenuResponse implements RichMenuCommonProperties {
11 | /** Rich menu ID */
12 | String richMenuId;
13 |
14 | /**
15 | * {@link RichMenuSize} object which contains the width and height of the rich menu displayed in the chat.
16 | *
17 | *
39 | *
41 | */
42 | private final String baseUrl;
43 |
44 | /**
45 | * Alternative text
46 | */
47 | private final String altText;
48 |
49 | /**
50 | * Size of base image
51 | */
52 | private final ImagemapBaseSize baseSize;
53 |
54 | /**
55 | * Action when tapped
56 | */
57 | private final List
35 | *
41 | */
42 | private final String imageUrl;
43 |
44 | /**
45 | * Action when tapped
46 | */
47 | private final Action action;
48 |
49 | @JsonCreator
50 | public ImageCarouselColumn(
51 | @JsonProperty("imageUrl") String imageUrl,
52 | @JsonProperty("action") Action action) {
53 | this.imageUrl = imageUrl;
54 | this.action = action;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/line-bot-model/src/test/java/com/linecorp/bot/model/event/MessageEventTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model.event;
18 |
19 | import static org.assertj.core.api.Assertions.assertThat;
20 |
21 | import java.lang.reflect.Constructor;
22 | import java.lang.reflect.Method;
23 |
24 | import org.junit.Test;
25 |
26 | import com.linecorp.bot.model.event.message.MessageContent;
27 |
28 | public class MessageEventTest {
29 | @Test
30 | public void constructor2ndParameterBinaryCompatibilityTest() {
31 | Constructor> constructor = MessageEvent.class.getConstructors()[0];
32 |
33 | Class>[] parameterTypes = constructor.getParameterTypes();
34 | assertThat(parameterTypes).hasSize(4);
35 | assertThat(parameterTypes[2]).isEqualTo(MessageContent.class)
36 | .isNotEqualTo(Object.class);
37 | }
38 |
39 | @Test
40 | public void getMessageBinaryCompatibilityTest() throws NoSuchMethodException {
41 | Method method = MessageEvent.class.getMethod("getMessage");
42 |
43 | assertThat(method.getReturnType()).isEqualTo(MessageContent.class)
44 | .isNotEqualTo(Object.class);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/ReplyMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model;
18 |
19 | import java.util.Collections;
20 | import java.util.List;
21 |
22 | import com.linecorp.bot.model.message.Message;
23 |
24 | import lombok.AllArgsConstructor;
25 | import lombok.Value;
26 |
27 | /**
28 | *
48 | * Max: 5
49 | */
50 | private final ListJSON Deserialization
27 | *
28 | * .registerModule(new ParameterNamesModule());
31 | */
32 | @JsonTypeInfo(
33 | use = JsonTypeInfo.Id.NAME,
34 | include = As.PROPERTY,
35 | property = "type"
36 | )
37 | @JsonSubTypes({
38 | @JsonSubTypes.Type(TextMessage.class),
39 | @JsonSubTypes.Type(ImageMessage.class),
40 | @JsonSubTypes.Type(StickerMessage.class),
41 | @JsonSubTypes.Type(LocationMessage.class),
42 | @JsonSubTypes.Type(AudioMessage.class),
43 | @JsonSubTypes.Type(VideoMessage.class),
44 | @JsonSubTypes.Type(ImagemapMessage.class),
45 | @JsonSubTypes.Type(TemplateMessage.class),
46 | })
47 | public interface Message {
48 | }
49 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/error/ErrorResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model.error;
18 |
19 | import java.util.Collections;
20 | import java.util.List;
21 |
22 | import com.fasterxml.jackson.annotation.JacksonInject;
23 | import com.fasterxml.jackson.annotation.JsonProperty;
24 |
25 | import lombok.Value;
26 |
27 | /**
28 | * Error response from LINE Messaging Server.
29 | *
30 | * @see //devdocs.line.me/#error-response
31 | */
32 | @Value
33 | public class ErrorResponse {
34 | /** Request ID in response header */
35 | String requestId;
36 |
37 | /** Summary or details of the error. */
38 | String message;
39 |
40 | /**
41 | * Details of the error.
42 | *
43 | * In this class, always non-null but can be empty.
44 | */
45 | List
32 |
33 | ### Step 2
34 |
35 | Tap the deploy button.
36 |
37 | [](https://heroku.com/deploy?template=https://github.com/line/line-bot-sdk-java)
38 |
39 | ### Step 3
40 |
41 | Fill in the form and run your instance.
42 |
43 |
44 |
45 | ### Step 4
46 |
47 | Tap the **Manage App** button and copy the name of your Heroku instance.
48 |
49 |
50 |
51 | ### Step 5
52 |
53 | Set the webhook URL for your Channel on the Channel Console using the following URL:
54 | `https://${YOUR_HEROKU_APP_NAME}.herokuapp.com/callback`
55 |
56 |
57 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/event/BeaconEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model.event;
18 |
19 | import java.time.Instant;
20 |
21 | import com.fasterxml.jackson.annotation.JsonCreator;
22 | import com.fasterxml.jackson.annotation.JsonProperty;
23 | import com.fasterxml.jackson.annotation.JsonTypeName;
24 |
25 | import com.linecorp.bot.model.event.beacon.BeaconContent;
26 | import com.linecorp.bot.model.event.source.Source;
27 |
28 | import lombok.Value;
29 |
30 | /**
31 | * Event object for when a user detects a LINE Beacon. You can reply to beacon events.
32 | */
33 | @Value
34 | @JsonTypeName("beacon")
35 | public class BeaconEvent implements Event, ReplyEvent {
36 | /**
37 | * Token for replying to this event
38 | */
39 | private final String replyToken;
40 |
41 | /**
42 | * JSON object which contains the source of the event
43 | */
44 | private final Source source;
45 |
46 | /**
47 | * Content of the beacon event.
48 | */
49 | private final BeaconContent beacon;
50 |
51 | /**
52 | * Time of the event
53 | */
54 | private final Instant timestamp;
55 |
56 | @JsonCreator
57 | public BeaconEvent(
58 | @JsonProperty("replyToken") String replyToken,
59 | @JsonProperty("source") Source source,
60 | @JsonProperty("timestamp") Instant timestamp,
61 | @JsonProperty("beacon") BeaconContent beacon
62 | ) {
63 | this.replyToken = replyToken;
64 | this.source = source;
65 | this.timestamp = timestamp;
66 | this.beacon = beacon;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/event/MessageEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model.event;
18 |
19 | import java.time.Instant;
20 |
21 | import com.fasterxml.jackson.annotation.JsonCreator;
22 | import com.fasterxml.jackson.annotation.JsonProperty;
23 | import com.fasterxml.jackson.annotation.JsonTypeName;
24 |
25 | import com.linecorp.bot.model.event.message.MessageContent;
26 | import com.linecorp.bot.model.event.source.Source;
27 |
28 | import lombok.Value;
29 |
30 | /**
31 | * Event object which contains the sent message.
32 | * The message field contains a message object which corresponds with the message type. You can reply to message events.
33 | */
34 | @Value
35 | @JsonTypeName("message")
36 | public class MessageEvent
49 | *
52 | *
53 | * The default value is {@code rectangle}.
54 | */
55 | private final String imageAspectRatio;
56 |
57 | /**
58 | * Size of the image. Specify one of the following values:
59 | *
60 | *
61 | *
64 | *
65 | * The default value is {@code cover}.
66 | */
67 | private final String imageSize;
68 |
69 | @JsonCreator
70 | public CarouselTemplate(@JsonProperty("columns") List
44 | * Max: 20 characters
45 | */
46 | private final String label;
47 |
48 | /**
49 | * String returned via webhook in the postback.data property of the postback event
50 | * Max: 300 characters
51 | */
52 | private final String data;
53 |
54 | /**
55 | * Text sent when the action is performed
56 | * Max: 300 characters
57 | */
58 | private final String text;
59 |
60 | /**
61 | * Create new instance.
62 | * @param label Label for the action. Max: 20 characters.
63 | * @param data String returned via webhook in the postback.data property of the postback event.
64 | * Max: 300 characters.
65 | * @param text text message (optional)
66 | */
67 | @JsonCreator
68 | public PostbackAction(
69 | @JsonProperty("label") String label,
70 | @JsonProperty("data") String data,
71 | @JsonProperty("text") String text) {
72 | this.label = label;
73 | this.data = data;
74 | this.text = text;
75 | }
76 |
77 | public PostbackAction(String label, String data) {
78 | this(label, data, null);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/line-bot-api-client/src/test/java/com/linecorp/bot/client/HeaderInterceptorWireMockTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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 static java.util.Collections.singletonList;
20 | import static org.assertj.core.api.Assertions.assertThat;
21 | import static org.mockito.Mockito.when;
22 |
23 | import org.junit.Rule;
24 | import org.junit.Test;
25 | import org.mockito.Mock;
26 | import org.mockito.junit.MockitoJUnit;
27 | import org.mockito.junit.MockitoRule;
28 |
29 | import okhttp3.mockwebserver.MockWebServer;
30 | import okhttp3.mockwebserver.RecordedRequest;
31 |
32 | public class HeaderInterceptorWireMockTest extends AbstractWiremockTest {
33 | @Rule
34 | public final MockitoRule mockitoRule = MockitoJUnit.rule();
35 |
36 | @Mock
37 | ChannelTokenSupplier channelTokenSupplier;
38 |
39 | @Test(timeout = ASYNC_TEST_TIMEOUT)
40 | public void forChannelTokenSupplier() throws Exception {
41 | // Do
42 | when(channelTokenSupplier.get()).thenReturn("1st");
43 | lineMessagingClient.getMessageContent("TEST");
44 |
45 | // Verify
46 | final RecordedRequest request1st = mockWebServer.takeRequest();
47 | assertThat(request1st.getHeaders().toMultimap())
48 | .containsEntry("Authorization", singletonList("Bearer 1st"));
49 |
50 | // Do again with another channel token.
51 | when(channelTokenSupplier.get()).thenReturn("2nd");
52 | lineMessagingClient.getMessageContent("TEST");
53 |
54 | // Verify
55 | final RecordedRequest request2nd = mockWebServer.takeRequest();
56 | assertThat(request2nd.getHeaders().toMultimap())
57 | .containsEntry("Authorization", singletonList("Bearer 2nd"));
58 | }
59 |
60 | @Override
61 | protected LineMessagingClientImpl createLineMessagingClient(final MockWebServer mockWebServer) {
62 | LineMessagingService lineMessagingService =
63 | LineMessagingServiceBuilder.create(channelTokenSupplier)
64 | .apiEndPoint("http://localhost:" + mockWebServer.getPort())
65 | .build();
66 | return new LineMessagingClientImpl(lineMessagingService);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/line-bot-model/src/main/java/com/linecorp/bot/model/message/template/CarouselColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 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.model.message.template;
18 |
19 | import java.util.Collections;
20 | import java.util.List;
21 |
22 | import com.fasterxml.jackson.annotation.JsonCreator;
23 | import com.fasterxml.jackson.annotation.JsonProperty;
24 |
25 | import com.linecorp.bot.model.action.Action;
26 |
27 | import lombok.AccessLevel;
28 | import lombok.AllArgsConstructor;
29 | import lombok.Builder;
30 | import lombok.Value;
31 |
32 | /**
33 | * Column object for carousel template
34 | *
35 | * @see CarouselColumnBuilder
36 | */
37 | @Value
38 | @Builder
39 | @AllArgsConstructor(access = AccessLevel.PUBLIC)
40 | public class CarouselColumn {
41 | /**
42 | * Image URL
43 | *
44 | *
50 | */
51 | private final String thumbnailImageUrl;
52 |
53 | /**
54 | * Background color of image.
55 | *
56 | * #FFFFFF (white).
57 | */
58 | private final String imageBackgroundColor;
59 |
60 | /**
61 | * Title (Max: 40 characters)
62 | */
63 | private final String title;
64 |
65 | /**
66 | * Message text
67 | * Max: 120 characters (no image or title)
68 | * Max: 60 characters (message with an image or title)
69 | */
70 | private final String text;
71 |
72 | /**
73 | * Action when tapped(Max: 3)
74 | */
75 | private final List