Repository: line/line-bot-sdk-python
Pull request #110 (2018-06-27 16:35:47)

Add display_text in PostbackAction
https://developers.line.me/en/docs/messaging-api/reference/#postback-action

`text` of Postback action was **Deprecated**


Patch:
diff --git a/linebot/models/actions.py b/linebot/models/actions.py
index b8cd7ab..2755d2d 100644
--- a/linebot/models/actions.py
+++ b/linebot/models/actions.py
@@ -70,13 +70,15 @@ class PostbackAction(Action):
     a postback event is returned via webhook with the specified string in the data property.
     """
 
-    def __init__(self, label=None, data=None, text=None, **kwargs):
+    def __init__(self, label=None, data=None, display_text=None, text=None, **kwargs):
         """__init__ method.
 
         :param str label: Label for the action.
         :param str data: String returned via webhook
             in the postback.data property of the postback event.
-        :param str text: Text displayed in the chat as a message sent by
+        :param str display_text: Text displayed in the chat as a message sent by
+            the user when the action is performed.
+        :param str text: Deprecated. Text displayed in the chat as a message sent by
             the user when the action is performed. Returned from the server through a webhook.
         :param kwargs:
         """
@@ -85,6 +87,7 @@ class PostbackAction(Action):
         self.type = 'postback'
         self.label = label
         self.data = data
+        self.display_text = display_text
         self.text = text
 
 


Test patch:
diff --git a/tests/api/test_send_template_message.py b/tests/api/test_send_template_message.py
index e224d11..c0e2e81 100644
--- a/tests/api/test_send_template_message.py
+++ b/tests/api/test_send_template_message.py
@@ -44,7 +44,7 @@ class TestLineBotApi(unittest.TestCase):
                 title='Menu', text='Please select',
                 actions=[
                     PostbackAction(
-                        label='postback', text='postback text',
+                        label='postback', display_text='postback text',
                         data='action=buy&itemid=1'
                     ),
                     MessageAction(
@@ -70,7 +70,7 @@ class TestLineBotApi(unittest.TestCase):
                     {
                         "type": "postback",
                         "label": "postback",
-                        "text": "postback text",
+                        "displayText": "postback text",
                         "data": "action=buy&itemid=1"
                     },
                     {
@@ -93,7 +93,7 @@ class TestLineBotApi(unittest.TestCase):
                 text='Are you sure?',
                 actions=[
                     PostbackAction(
-                        label='postback', text='postback text',
+                        label='postback', display_text='postback text',
                         data='action=buy&itemid=1'
                     ),
                     MessageAction(
@@ -113,7 +113,7 @@ class TestLineBotApi(unittest.TestCase):
                     {
                         "type": "postback",
                         "label": "postback",
-                        "text": "postback text",
+                        "displayText": "postback text",
                         "data": "action=buy&itemid=1"
                     },
                     {
@@ -135,7 +135,7 @@ class TestLineBotApi(unittest.TestCase):
                         title='this is menu1', text='description1',
                         actions=[
                             PostbackAction(
-                                label='postback1', text='postback text1',
+                                label='postback1', display_text='postback text1',
                                 data='action=buy&itemid=1'
                             ),
                             MessageAction(
@@ -154,7 +154,7 @@ class TestLineBotApi(unittest.TestCase):
                         title='this is menu2', text='description2',
                         actions=[
                             PostbackAction(
-                                label='postback2', text='postback text2',
+                                label='postback2', display_text='postback text2',
                                 data='action=buy&itemid=2'
                             ),
                             MessageAction(
@@ -216,7 +216,7 @@ class TestLineBotApi(unittest.TestCase):
                             {
                                 "type": "postback",
                                 "label": "postback1",
-                                "text": "postback text1",
+                                "displayText": "postback text1",
                                 "data": "action=buy&itemid=1"
                             },
                             {
@@ -241,7 +241,7 @@ class TestLineBotApi(unittest.TestCase):
                             {
                                 "type": "postback",
                                 "label": "postback2",
-                                "text": "postback text2",
+                                "displayText": "postback text2",
                                 "data": "action=buy&itemid=2"
                             },
                             {