Repository: line/line-bot-sdk-go
Pull request #267 (2021-03-14 06:22:25)

Add URI action support to quick reply
- with example
- with test
Ref: https://developers.line.biz/en/news/2021/03/10/messaging-api-update-march-2021/#202103-01


Patch:
diff --git a/examples/kitchensink/server.go b/examples/kitchensink/server.go
index 0f26e98..21948a5 100644
--- a/examples/kitchensink/server.go
+++ b/examples/kitchensink/server.go
@@ -591,6 +591,9 @@ func (app *KitchenSink) handleText(message *linebot.TextMessage, replyToken stri
 					linebot.NewQuickReplyButton(
 						"",
 						linebot.NewLocationAction("Send location")),
+					linebot.NewQuickReplyButton(
+						"",
+						linebot.NewURIAction("LINE Developer", "https://developers.line.biz/")),
 				)),
 		).Do(); err != nil {
 			return err
diff --git a/linebot/actions.go b/linebot/actions.go
index 12ec72a..c965819 100644
--- a/linebot/actions.go
+++ b/linebot/actions.go
@@ -227,6 +227,9 @@ func (*CameraRollAction) QuickReplyAction() {}
 // QuickReplyAction implements QuickReplyAction interface
 func (*LocationAction) QuickReplyAction() {}
 
+// QuickReplyAction implements URI's QuickReplyAction interface
+func (*URIAction) QuickReplyAction() {}
+
 // NewURIAction function
 func NewURIAction(label, uri string) *URIAction {
 	return &URIAction{


Test patch:
diff --git a/linebot/send_message_test.go b/linebot/send_message_test.go
index 35a2ea9..fef4035 100644
--- a/linebot/send_message_test.go
+++ b/linebot/send_message_test.go
@@ -429,13 +429,15 @@ func TestPushMessages(t *testing.T) {
 						NewQuickReplyButton("https://example.com/sushi.png", NewMessageAction("Sushi", "Sushi")),
 						NewQuickReplyButton("https://example.com/tempura.png", NewMessageAction("Tempura", "Tempura")),
 						NewQuickReplyButton("", NewLocationAction("Send location")),
+						NewQuickReplyButton("", NewCameraAction("Open camera")),
+						NewQuickReplyButton("", NewURIAction("Phone order", "tel:09001234567")),
 					),
 				),
 			},
 			ResponseCode: 200,
 			Response:     []byte(`{}`),
 			Want: want{
-				RequestBody: []byte(`{"to":"U0cc15697597f61dd8b01cea8b027050e","messages":[{"type":"text","text":"Select your favorite food category or send me your location!","quickReply":{"items":[{"type":"action","imageUrl":"https://example.com/sushi.png","action":{"type":"message","label":"Sushi","text":"Sushi"}},{"type":"action","imageUrl":"https://example.com/tempura.png","action":{"type":"message","label":"Tempura","text":"Tempura"}},{"type":"action","action":{"type":"location","label":"Send location"}}]}}]}` + "\n"),
+				RequestBody: []byte(`{"to":"U0cc15697597f61dd8b01cea8b027050e","messages":[{"type":"text","text":"Select your favorite food category or send me your location!","quickReply":{"items":[{"type":"action","imageUrl":"https://example.com/sushi.png","action":{"type":"message","label":"Sushi","text":"Sushi"}},{"type":"action","imageUrl":"https://example.com/tempura.png","action":{"type":"message","label":"Tempura","text":"Tempura"}},{"type":"action","action":{"type":"location","label":"Send location"}},{"type":"action","action":{"type":"camera","label":"Open camera"}},{"type":"action","action":{"type":"uri","label":"Phone order","uri":"tel:09001234567"}}]}}]}` + "\n"),
 				Response:    &BasicResponse{},
 			},
 		},