Repository: line/line-bot-sdk-python
Pull request #168 (2019-05-31 07:55:29)

Add support for altUri.desktop property
https://github.com/line/line-bot-sdk-python/issues/155


Patch:
diff --git a/linebot/models/__init__.py b/linebot/models/__init__.py
index e7233e8..e4f87c8 100644
--- a/linebot/models/__init__.py
+++ b/linebot/models/__init__.py
@@ -28,6 +28,7 @@ from .actions import (  # noqa
     MessageAction as MessageTemplateAction,  # backward compatibility
     URIAction as URITemplateAction,  # backward compatibility
     DatetimePickerAction as DatetimePickerTemplateAction,  # backward compatibility
+    AltUri,
 )
 from .base import (  # noqa
     Base,
diff --git a/linebot/models/actions.py b/linebot/models/actions.py
index 07143dd..e1bed60 100644
--- a/linebot/models/actions.py
+++ b/linebot/models/actions.py
@@ -126,12 +126,14 @@ class URIAction(Action):
     the URI specified in the uri property is opened.
     """
 
-    def __init__(self, label=None, uri=None, **kwargs):
+    def __init__(self, label=None, uri=None, alt_uri=None, **kwargs):
         """__init__ method.
 
         :param str label: Label for the action
             Max: 20 characters
         :param str uri: URI opened when the action is performed.
+        :param alt_uri: URI opened when the desktop app.
+        :type alt_uri: T <= :py:class:`linebot.models.actions.AltUri`
         :param kwargs:
         """
         super(URIAction, self).__init__(**kwargs)
@@ -139,6 +141,29 @@ class URIAction(Action):
         self.type = 'uri'
         self.label = label
         self.uri = uri
+        self.alt_uri = self.get_or_new_from_json_dict(alt_uri, AltUri)
+
+
+class AltUri(with_metaclass(ABCMeta, Base)):
+    """AltUri.
+
+    https://github.com/line/line-bot-sdk-python/issues/155
+
+    URI opened when the desktop app.
+    """
+
+    def __init__(self, desktop=None, **kwargs):
+        """__init__ method.
+
+        :param str desktop: URI opened on LINE for macOS and Windows
+            when the action is performed.
+            If the altUri.desktop property is set,
+            the uri property is ignored on LINE for macOS and Windows.
+        :param kwargs:
+        """
+        super(AltUri, self).__init__(**kwargs)
+
+        self.desktop = desktop
 
 
 class DatetimePickerAction(Action):


Test patch:
diff --git a/tests/api/test_send_template_message.py b/tests/api/test_send_template_message.py
index de8f840..a6ab7ab 100644
--- a/tests/api/test_send_template_message.py
+++ b/tests/api/test_send_template_message.py
@@ -25,7 +25,7 @@ from linebot import (
 from linebot.models import (
     TemplateSendMessage, ButtonsTemplate,
     PostbackAction, MessageAction,
-    URIAction, DatetimePickerAction,
+    URIAction, AltUri, DatetimePickerAction,
     ConfirmTemplate, CarouselTemplate, CarouselColumn,
     ImageCarouselTemplate, ImageCarouselColumn
 )
@@ -51,7 +51,8 @@ class TestLineBotApi(unittest.TestCase):
                         label='message', text='message text'
                     ),
                     URIAction(
-                        label='uri', uri='http://example.com/'
+                        label='uri', uri='http://example.com/',
+                        alt_uri=AltUri(desktop="http://example.com/desktop")
                     )
                 ]
             )
@@ -81,7 +82,10 @@ class TestLineBotApi(unittest.TestCase):
                     {
                         "type": "uri",
                         "label": "uri",
-                        "uri": "http://example.com/"
+                        "uri": "http://example.com/",
+                        "altUri": {
+                            "desktop": "http://example.com/desktop"
+                        }
                     }
                 ]
             }