Skip to content

Commit b775c12

Browse files
authored
Add two parameters to PostbackAction (#386)
* add: PostbackInputOption * update: PostbackAction * update: TestActions::test_postback * update: constants __init__ * update: PostbackInputOption * update: PostbackInputOption
1 parent 1b63fb0 commit b775c12

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

linebot/constants/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# https://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
"""linebot.constants package."""
14+
15+
from .postback_input_option import PostbackInputOption # noqa
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# https://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
"""linebot.constants.postback_input_option module."""
14+
15+
16+
class PostbackInputOption:
17+
"""Constant class for Postback input option."""
18+
19+
CLOSE_RICH_MENU = "closeRichMenu"
20+
OPEN_RICH_MENU = "openRichMenu"
21+
OPEN_KEYBOARD = "openKeyboard"
22+
OPEN_VOICE = "openVoice"

linebot/models/actions.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,16 @@ class PostbackAction(Action):
7373
a postback event is returned via webhook with the specified string in the data property.
7474
"""
7575

76-
def __init__(self, label=None, data=None, display_text=None, text=None, **kwargs):
76+
def __init__(
77+
self,
78+
label=None,
79+
data=None,
80+
display_text=None,
81+
text=None,
82+
input_option=None,
83+
fill_in_text=None,
84+
**kwargs
85+
):
7786
"""__init__ method.
7887
7988
:param str label: Label for the action.
@@ -92,6 +101,8 @@ def __init__(self, label=None, data=None, display_text=None, text=None, **kwargs
92101
self.data = data
93102
self.display_text = display_text
94103
self.text = text
104+
self.input_option = input_option
105+
self.fill_in_text = fill_in_text
95106

96107

97108
class MessageAction(Action):

tests/models/test_actions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from __future__ import unicode_literals, absolute_import
1616

1717
import unittest
18+
from linebot.constants.postback_input_option import PostbackInputOption
1819

1920
from linebot.models import (
2021
PostbackAction,
@@ -34,7 +35,9 @@ def test_postback(self):
3435
arg = {
3536
'label': 'Buy',
3637
'data': 'action=buy&id=1',
37-
'display_text': 'buy'
38+
'display_text': 'buy',
39+
'input_option': PostbackInputOption.OPEN_KEYBOARD,
40+
'fill_in_text': 'fill in text',
3841
}
3942
self.assertEqual(
4043
self.serialize_as_dict(arg, type=self.POSTBACK),

0 commit comments

Comments
 (0)