Skip to content

Commit 7c2716a

Browse files
synkimasahiro
authored andcommitted
flex message update1 (#358)
1 parent b078deb commit 7c2716a

File tree

15 files changed

+817
-23
lines changed

15 files changed

+817
-23
lines changed

line-bot-api-client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LINE Messaging API client for Java 8 or later.
55
## Synopsis
66

77
```java
8-
LineMessagingService client = LineMessagingClient.builder("YOUR_CHANNEL_TOKEN").build();
8+
LineMessagingClient client = LineMessagingClient.builder("YOUR_CHANNEL_TOKEN").build();
99
```
1010

1111
## Description

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Box.java

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.linecorp.bot.model.message.flex.component;
1818

19+
import java.util.ArrayList;
20+
import java.util.Arrays;
1921
import java.util.Collections;
2022
import java.util.List;
2123

@@ -26,8 +28,13 @@
2628
import com.fasterxml.jackson.annotation.JsonTypeName;
2729

2830
import com.linecorp.bot.model.action.Action;
31+
import com.linecorp.bot.model.message.flex.unit.FlexBorderWidthSize;
32+
import com.linecorp.bot.model.message.flex.unit.FlexCornerRadiusSize;
2933
import com.linecorp.bot.model.message.flex.unit.FlexLayout;
3034
import com.linecorp.bot.model.message.flex.unit.FlexMarginSize;
35+
import com.linecorp.bot.model.message.flex.unit.FlexOffsetSize;
36+
import com.linecorp.bot.model.message.flex.unit.FlexPaddingSize;
37+
import com.linecorp.bot.model.message.flex.unit.FlexPosition;
3138

3239
import lombok.Builder;
3340
import lombok.Value;
@@ -48,6 +55,38 @@ public class Box implements FlexComponent {
4855

4956
private final FlexMarginSize margin;
5057

58+
private final FlexPosition position;
59+
60+
private final String offsetTop;
61+
62+
private final String offsetBottom;
63+
64+
private final String offsetStart;
65+
66+
private final String offsetEnd;
67+
68+
private final String backgroundColor;
69+
70+
private final String borderColor;
71+
72+
private final String borderWidth;
73+
74+
private final String cornerRadius;
75+
76+
private final String width;
77+
78+
private final String height;
79+
80+
private final String paddingAll;
81+
82+
private final String paddingTop;
83+
84+
private final String paddingBottom;
85+
86+
private final String paddingStart;
87+
88+
private final String paddingEnd;
89+
5190
private final Action action;
5291

5392
@JsonCreator
@@ -57,12 +96,171 @@ public Box(
5796
@JsonProperty("contents") List<FlexComponent> contents,
5897
@JsonProperty("spacing") FlexMarginSize spacing,
5998
@JsonProperty("margin") FlexMarginSize margin,
99+
@JsonProperty("position") FlexPosition position,
100+
@JsonProperty("offsetTop") String offsetTop,
101+
@JsonProperty("offsetBottom") String offsetBottom,
102+
@JsonProperty("offsetStart") String offsetStart,
103+
@JsonProperty("offsetEnd") String offsetEnd,
104+
@JsonProperty("backgroundColor") String backgroundColor,
105+
@JsonProperty("borderColor") String borderColor,
106+
@JsonProperty("borderWidth") String borderWidth,
107+
@JsonProperty("cornerRadius") String cornerRadius,
108+
@JsonProperty("width") String width,
109+
@JsonProperty("height") String height,
110+
@JsonProperty("paddingAll") String paddingAll,
111+
@JsonProperty("paddingTop") String paddingTop,
112+
@JsonProperty("paddingBottom") String paddingBottom,
113+
@JsonProperty("paddingStart") String paddingStart,
114+
@JsonProperty("paddingEnd") String paddingEnd,
60115
@JsonProperty("action") Action action) {
61116
this.layout = layout;
62117
this.flex = flex;
63118
this.contents = contents != null ? contents : Collections.emptyList();
64119
this.spacing = spacing;
65120
this.margin = margin;
121+
this.position = position;
122+
this.offsetTop = offsetTop;
123+
this.offsetBottom = offsetBottom;
124+
this.offsetStart = offsetStart;
125+
this.offsetEnd = offsetEnd;
126+
this.backgroundColor = backgroundColor;
127+
this.borderColor = borderColor;
128+
this.borderWidth = borderWidth;
129+
this.cornerRadius = cornerRadius;
130+
this.width = width;
131+
this.height = height;
132+
this.paddingAll = paddingAll;
133+
this.paddingTop = paddingTop;
134+
this.paddingBottom = paddingBottom;
135+
this.paddingStart = paddingStart;
136+
this.paddingEnd = paddingEnd;
66137
this.action = action;
67138
}
139+
140+
public static class BoxBuilder {
141+
142+
public BoxBuilder contents(List<FlexComponent> contents) {
143+
this.contents = new ArrayList<>(contents);
144+
return this;
145+
}
146+
147+
public BoxBuilder contents(FlexComponent... contents) {
148+
this.contents = Arrays.asList(contents);
149+
return this;
150+
}
151+
152+
public BoxBuilder content(FlexComponent content) {
153+
return contents(content);
154+
}
155+
156+
public BoxBuilder paddingAll(FlexPaddingSize padding) {
157+
paddingAll = padding.getPropertyValue();
158+
return this;
159+
}
160+
161+
public BoxBuilder paddingAll(String padding) {
162+
paddingAll = padding;
163+
return this;
164+
}
165+
166+
public BoxBuilder paddingTop(FlexPaddingSize padding) {
167+
paddingTop = padding.getPropertyValue();
168+
return this;
169+
}
170+
171+
public BoxBuilder paddingTop(String padding) {
172+
paddingTop = padding;
173+
return this;
174+
}
175+
176+
public BoxBuilder paddingBottom(FlexPaddingSize padding) {
177+
paddingBottom = padding.getPropertyValue();
178+
return this;
179+
}
180+
181+
public BoxBuilder paddingBottom(String padding) {
182+
paddingBottom = padding;
183+
return this;
184+
}
185+
186+
public BoxBuilder paddingStart(FlexPaddingSize padding) {
187+
paddingStart = padding.getPropertyValue();
188+
return this;
189+
}
190+
191+
public BoxBuilder paddingStart(String padding) {
192+
paddingStart = padding;
193+
return this;
194+
}
195+
196+
public BoxBuilder paddingEnd(FlexPaddingSize padding) {
197+
paddingEnd = padding.getPropertyValue();
198+
return this;
199+
}
200+
201+
public BoxBuilder paddingEnd(String padding) {
202+
paddingEnd = padding;
203+
return this;
204+
}
205+
206+
public BoxBuilder offsetTop(FlexOffsetSize padding) {
207+
offsetTop = padding.getPropertyValue();
208+
return this;
209+
}
210+
211+
public BoxBuilder offsetTop(String offset) {
212+
offsetTop = offset;
213+
return this;
214+
}
215+
216+
public BoxBuilder offsetBottom(FlexOffsetSize offset) {
217+
offsetBottom = offset.getPropertyValue();
218+
return this;
219+
}
220+
221+
public BoxBuilder offsetBottom(String offset) {
222+
offsetBottom = offset;
223+
return this;
224+
}
225+
226+
public BoxBuilder offsetStart(FlexOffsetSize offset) {
227+
offsetStart = offset.getPropertyValue();
228+
return this;
229+
}
230+
231+
public BoxBuilder offsetStart(String offset) {
232+
offsetStart = offset;
233+
return this;
234+
}
235+
236+
public BoxBuilder offsetEnd(FlexOffsetSize offset) {
237+
offsetEnd = offset.getPropertyValue();
238+
return this;
239+
}
240+
241+
public BoxBuilder offsetEnd(String offset) {
242+
offsetEnd = offset;
243+
return this;
244+
}
245+
246+
public BoxBuilder borderWidth(FlexBorderWidthSize width) {
247+
borderWidth = width.getPropertyValue();
248+
return this;
249+
}
250+
251+
public BoxBuilder borderWidth(String width) {
252+
borderWidth = width;
253+
return this;
254+
}
255+
256+
public BoxBuilder cornerRadius(FlexCornerRadiusSize radius) {
257+
cornerRadius = radius.getPropertyValue();
258+
return this;
259+
}
260+
261+
public BoxBuilder cornerRadius(String radius) {
262+
cornerRadius = radius;
263+
return this;
264+
}
265+
}
68266
}

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Button.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.linecorp.bot.model.action.Action;
2626
import com.linecorp.bot.model.message.flex.unit.FlexGravity;
2727
import com.linecorp.bot.model.message.flex.unit.FlexMarginSize;
28+
import com.linecorp.bot.model.message.flex.unit.FlexOffsetSize;
29+
import com.linecorp.bot.model.message.flex.unit.FlexPosition;
2830

2931
import lombok.Builder;
3032
import lombok.Value;
@@ -63,6 +65,16 @@ public enum ButtonHeight {
6365

6466
private FlexMarginSize margin;
6567

68+
private FlexPosition position;
69+
70+
private String offsetTop;
71+
72+
private String offsetBottom;
73+
74+
private String offsetStart;
75+
76+
private String offsetEnd;
77+
6678
private ButtonHeight height;
6779

6880
@JsonCreator
@@ -73,13 +85,67 @@ public Button(
7385
@JsonProperty("action") Action action,
7486
@JsonProperty("gravity") FlexGravity gravity,
7587
@JsonProperty("margin") FlexMarginSize margin,
88+
@JsonProperty("position") FlexPosition position,
89+
@JsonProperty("offsetTop") String offsetTop,
90+
@JsonProperty("offsetBottom") String offsetBottom,
91+
@JsonProperty("offsetStart") String offsetStart,
92+
@JsonProperty("offsetEnd") String offsetEnd,
7693
@JsonProperty("height") ButtonHeight height) {
7794
this.flex = flex;
7895
this.color = color;
7996
this.style = style;
8097
this.action = action;
8198
this.gravity = gravity;
8299
this.margin = margin;
100+
this.position = position;
101+
this.offsetTop = offsetTop;
102+
this.offsetBottom = offsetBottom;
103+
this.offsetStart = offsetStart;
104+
this.offsetEnd = offsetEnd;
83105
this.height = height;
84106
}
107+
108+
public static class ButtonBuilder {
109+
110+
public ButtonBuilder offsetTop(FlexOffsetSize offset) {
111+
offsetTop = offset.getPropertyValue();
112+
return this;
113+
}
114+
115+
public ButtonBuilder offsetTop(String offset) {
116+
offsetTop = offset;
117+
return this;
118+
}
119+
120+
public ButtonBuilder offsetBottom(FlexOffsetSize offset) {
121+
offsetBottom = offset.getPropertyValue();
122+
return this;
123+
}
124+
125+
public ButtonBuilder offsetBottom(String offset) {
126+
offsetBottom = offset;
127+
return this;
128+
}
129+
130+
public ButtonBuilder offsetStart(FlexOffsetSize offset) {
131+
offsetStart = offset.getPropertyValue();
132+
return this;
133+
}
134+
135+
public ButtonBuilder offsetStart(String offset) {
136+
offsetStart = offset;
137+
return this;
138+
}
139+
140+
public ButtonBuilder offsetEnd(FlexOffsetSize offset) {
141+
offsetEnd = offset.getPropertyValue();
142+
return this;
143+
}
144+
145+
public ButtonBuilder offsetEnd(String offset) {
146+
offsetEnd = offset;
147+
return this;
148+
}
149+
150+
}
85151
}

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Filler.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,29 @@
1616

1717
package com.linecorp.bot.model.message.flex.component;
1818

19+
import com.fasterxml.jackson.annotation.JsonCreator;
20+
import com.fasterxml.jackson.annotation.JsonInclude;
21+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
22+
import com.fasterxml.jackson.annotation.JsonProperty;
1923
import com.fasterxml.jackson.annotation.JsonTypeName;
2024

25+
import lombok.Builder;
2126
import lombok.Value;
2227

2328
@Value
29+
@Builder
2430
@JsonTypeName("filler")
31+
@JsonInclude(Include.NON_NULL)
2532
public class Filler implements FlexComponent {
33+
34+
private Integer flex;
35+
36+
@JsonCreator
37+
public Filler(@JsonProperty("flex") Integer flex) {
38+
this.flex = flex;
39+
}
40+
41+
public Filler() {
42+
this(null);
43+
}
2644
}

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/FlexComponent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
@JsonSubTypes({
2424
@JsonSubTypes.Type(Text.class),
25+
@JsonSubTypes.Type(Span.class),
2526
@JsonSubTypes.Type(Image.class),
2627
@JsonSubTypes.Type(Box.class),
2728
@JsonSubTypes.Type(Separator.class),

0 commit comments

Comments
 (0)