Skip to content

Commit

Permalink
Merge pull request #147 from sugyan/issue-143
Browse files Browse the repository at this point in the history
Add URIAction.AltURI.Desktop
  • Loading branch information
sugyan authored Apr 23, 2019
2 parents 2980c5f + 8b7911c commit 687547c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
5 changes: 4 additions & 1 deletion examples/kitchensink/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,10 @@ func (app *KitchenSink) handleText(message *linebot.TextMessage, replyToken stri
"action": {
"type": "uri",
"label": "WEBSITE",
"uri": "https://linecorp.com"
"uri": "https://linecorp.com",
"altUri": {
"desktop": "https://line.me/ja/download"
}
}
},
{
Expand Down
24 changes: 16 additions & 8 deletions linebot/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,28 @@ type QuickReplyAction interface {

// URIAction type
type URIAction struct {
Label string
URI string
Label string
URI string
AltURI *URIActionAltURI
}

// URIActionAltURI type
type URIActionAltURI struct {
Desktop string `json:"desktop"`
}

// MarshalJSON method of URIAction
func (a *URIAction) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type ActionType `json:"type"`
Label string `json:"label,omitempty"`
URI string `json:"uri"`
Type ActionType `json:"type"`
Label string `json:"label,omitempty"`
URI string `json:"uri"`
AltURI *URIActionAltURI `json:"altUri,omitempty"`
}{
Type: ActionTypeURI,
Label: a.Label,
URI: a.URI,
Type: ActionTypeURI,
Label: a.Label,
URI: a.URI,
AltURI: a.AltURI,
})
}

Expand Down
8 changes: 7 additions & 1 deletion linebot/flex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ func TestUnmarshalFlexMessageJSON(t *testing.T) {
"action": {
"type": "uri",
"label": "WEBSITE",
"uri": "https://linecorp.com"
"uri": "https://linecorp.com",
"altUri": {
"desktop": "https://line.me/ja/download"
}
}
},
{
Expand Down Expand Up @@ -414,6 +417,9 @@ func TestUnmarshalFlexMessageJSON(t *testing.T) {
Action: &URIAction{
Label: "WEBSITE",
URI: "https://linecorp.com",
AltURI: &URIActionAltURI{
Desktop: "https://line.me/ja/download",
},
},
Height: FlexButtonHeightTypeSm,
Style: FlexButtonStyleTypeLink,
Expand Down

0 comments on commit 687547c

Please sign in to comment.