From 8b7911c046034f16c2986d0373a14d9d9dd6e5e5 Mon Sep 17 00:00:00 2001 From: sugyan Date: Mon, 22 Apr 2019 18:33:17 +0900 Subject: [PATCH] Add URIAction.AltURI.Desktop --- examples/kitchensink/server.go | 5 ++++- linebot/actions.go | 24 ++++++++++++++++-------- linebot/flex_test.go | 8 +++++++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/examples/kitchensink/server.go b/examples/kitchensink/server.go index db263699..92d894bb 100644 --- a/examples/kitchensink/server.go +++ b/examples/kitchensink/server.go @@ -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" + } } }, { diff --git a/linebot/actions.go b/linebot/actions.go index 9123b842..12ec72a4 100644 --- a/linebot/actions.go +++ b/linebot/actions.go @@ -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, }) } diff --git a/linebot/flex_test.go b/linebot/flex_test.go index 11881938..117066b8 100644 --- a/linebot/flex_test.go +++ b/linebot/flex_test.go @@ -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" + } } }, { @@ -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,