Repository: line/line-bot-sdk-go
Pull request #307 (2022-03-17 07:18:07)

Support Flex Message Update v3
#305 

- Support `maxWidth` and `maxHeight` in `BoxComponent`
- Support `lineSpacing` in `TextComponent`



Patch:
diff --git a/linebot/flex.go b/linebot/flex.go
index 06e84f1..abc9584 100644
--- a/linebot/flex.go
+++ b/linebot/flex.go
@@ -501,7 +501,9 @@ type BoxComponent struct {
 	Spacing         FlexComponentSpacingType
 	Margin          FlexComponentMarginType
 	Width           string
+	MaxWidth        string
 	Height          string
+	MaxHeight       string
 	CornerRadius    FlexComponentCornerRadiusType
 	BackgroundColor string
 	BorderColor     string
@@ -532,7 +534,9 @@ func (c *BoxComponent) MarshalJSON() ([]byte, error) {
 		Spacing         FlexComponentSpacingType        `json:"spacing,omitempty"`
 		Margin          FlexComponentMarginType         `json:"margin,omitempty"`
 		Width           string                          `json:"width,omitempty"`
+		MaxWidth        string                          `json:"maxWidth,omitempty"`
 		Height          string                          `json:"height,omitempty"`
+		MaxHeight       string                          `json:"maxHeight,omitempty"`
 		CornerRadius    FlexComponentCornerRadiusType   `json:"cornerRadius,omitempty"`
 		BackgroundColor string                          `json:"backgroundColor,omitempty"`
 		BorderColor     string                          `json:"borderColor,omitempty"`
@@ -559,7 +563,9 @@ func (c *BoxComponent) MarshalJSON() ([]byte, error) {
 		Spacing:         c.Spacing,
 		Margin:          c.Margin,
 		Width:           c.Width,
+		MaxWidth:        c.MaxWidth,
 		Height:          c.Height,
+		MaxHeight:       c.MaxHeight,
 		CornerRadius:    c.CornerRadius,
 		BackgroundColor: c.BackgroundColor,
 		BorderColor:     c.BorderColor,
@@ -829,6 +835,7 @@ type TextComponent struct {
 	Align        FlexComponentAlignType
 	Gravity      FlexComponentGravityType
 	Wrap         bool
+	LineSpacing  string
 	Weight       FlexTextWeightType
 	Color        string
 	Action       TemplateAction
@@ -855,6 +862,7 @@ func (c *TextComponent) MarshalJSON() ([]byte, error) {
 		Align        FlexComponentAlignType      `json:"align,omitempty"`
 		Gravity      FlexComponentGravityType    `json:"gravity,omitempty"`
 		Wrap         bool                        `json:"wrap,omitempty"`
+		LineSpacing  string                      `json:"lineSpacing,omitempty"`
 		Weight       FlexTextWeightType          `json:"weight,omitempty"`
 		Color        string                      `json:"color,omitempty"`
 		Action       TemplateAction              `json:"action,omitempty"`
@@ -877,6 +885,7 @@ func (c *TextComponent) MarshalJSON() ([]byte, error) {
 		Align:        c.Align,
 		Gravity:      c.Gravity,
 		Wrap:         c.Wrap,
+		LineSpacing:  c.LineSpacing,
 		Weight:       c.Weight,
 		Color:        c.Color,
 		Action:       c.Action,


Test patch:
diff --git a/linebot/flex_test.go b/linebot/flex_test.go
index 1f78f61..dba42f8 100644
--- a/linebot/flex_test.go
+++ b/linebot/flex_test.go
@@ -38,7 +38,8 @@ func TestUnmarshalFlexMessageJSON(t *testing.T) {
 		"contents": [
 			{
 				"type": "text",
-				"text": "hello"
+				"text": "hello",
+				"lineSpacing": "20px"
 			}
 		]
 	}
@@ -53,8 +54,9 @@ func TestUnmarshalFlexMessageJSON(t *testing.T) {
 					CornerRadius: "20px",
 					Contents: []FlexComponent{
 						&TextComponent{
-							Type: FlexComponentTypeText,
-							Text: "hello",
+							Type:        FlexComponentTypeText,
+							Text:        "hello",
+							LineSpacing: "20px",
 						},
 					},
 				},
@@ -709,7 +711,9 @@ func TestUnmarshalFlexMessageJSON(t *testing.T) {
 				"layout": "vertical",
 				"contents": [],
 				"width": "30px",
+				"maxWidth": "30px",
 				"height": "30px",
+				"maxHeight": "30px",
 				"background": {
 					"type": "linearGradient",
 					"angle": "0deg",
@@ -745,11 +749,13 @@ func TestUnmarshalFlexMessageJSON(t *testing.T) {
 							AdjustMode: FlexComponentAdjustModeTypeShrinkToFit,
 						},
 						&BoxComponent{
-							Type:     FlexComponentTypeBox,
-							Layout:   FlexBoxLayoutTypeVertical,
-							Contents: []FlexComponent{},
-							Width:    "30px",
-							Height:   "30px",
+							Type:      FlexComponentTypeBox,
+							Layout:    FlexBoxLayoutTypeVertical,
+							Contents:  []FlexComponent{},
+							Width:     "30px",
+							MaxWidth:  "30px",
+							Height:    "30px",
+							MaxHeight: "30px",
 							Background: &BoxBackground{
 								Type:           FlexBoxBackgroundTypeLinearGradient,
 								Angle:          "0deg",