Skip to content

Commit c274772

Browse files
authored
Merge pull request #168 from line/issue-155
Add support for altUri.desktop property
2 parents 6cd2a02 + dbbe758 commit c274772

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

linebot/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
MessageAction as MessageTemplateAction, # backward compatibility
2929
URIAction as URITemplateAction, # backward compatibility
3030
DatetimePickerAction as DatetimePickerTemplateAction, # backward compatibility
31+
AltUri,
3132
)
3233
from .base import ( # noqa
3334
Base,

linebot/models/actions.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,44 @@ class URIAction(Action):
126126
the URI specified in the uri property is opened.
127127
"""
128128

129-
def __init__(self, label=None, uri=None, **kwargs):
129+
def __init__(self, label=None, uri=None, alt_uri=None, **kwargs):
130130
"""__init__ method.
131131
132132
:param str label: Label for the action
133133
Max: 20 characters
134134
:param str uri: URI opened when the action is performed.
135+
:param alt_uri: URI opened when the desktop app.
136+
:type alt_uri: T <= :py:class:`linebot.models.actions.AltUri`
135137
:param kwargs:
136138
"""
137139
super(URIAction, self).__init__(**kwargs)
138140

139141
self.type = 'uri'
140142
self.label = label
141143
self.uri = uri
144+
self.alt_uri = self.get_or_new_from_json_dict(alt_uri, AltUri)
145+
146+
147+
class AltUri(with_metaclass(ABCMeta, Base)):
148+
"""AltUri.
149+
150+
https://github.com/line/line-bot-sdk-python/issues/155
151+
152+
URI opened when the desktop app.
153+
"""
154+
155+
def __init__(self, desktop=None, **kwargs):
156+
"""__init__ method.
157+
158+
:param str desktop: URI opened on LINE for macOS and Windows
159+
when the action is performed.
160+
If the altUri.desktop property is set,
161+
the uri property is ignored on LINE for macOS and Windows.
162+
:param kwargs:
163+
"""
164+
super(AltUri, self).__init__(**kwargs)
165+
166+
self.desktop = desktop
142167

143168

144169
class DatetimePickerAction(Action):

tests/api/test_send_template_message.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from linebot.models import (
2626
TemplateSendMessage, ButtonsTemplate,
2727
PostbackAction, MessageAction,
28-
URIAction, DatetimePickerAction,
28+
URIAction, AltUri, DatetimePickerAction,
2929
ConfirmTemplate, CarouselTemplate, CarouselColumn,
3030
ImageCarouselTemplate, ImageCarouselColumn
3131
)
@@ -51,7 +51,8 @@ def setUp(self):
5151
label='message', text='message text'
5252
),
5353
URIAction(
54-
label='uri', uri='http://example.com/'
54+
label='uri', uri='http://example.com/',
55+
alt_uri=AltUri(desktop="http://example.com/desktop")
5556
)
5657
]
5758
)
@@ -81,7 +82,10 @@ def setUp(self):
8182
{
8283
"type": "uri",
8384
"label": "uri",
84-
"uri": "http://example.com/"
85+
"uri": "http://example.com/",
86+
"altUri": {
87+
"desktop": "http://example.com/desktop"
88+
}
8589
}
8690
]
8791
}

0 commit comments

Comments
 (0)