Skip to content

Commit 6805fde

Browse files
authored
Support Limit upToRemainingQuota property (#290)
Closed #288 Refer news: https://developers.line.biz/en/news/2020/09/01/messaging-api-update-september-2020/
1 parent 1d0653e commit 6805fde

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

linebot/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ def broadcast(self, messages, retry_key=None, notification_disabled=False, timeo
228228

229229
def narrowcast(
230230
self, messages,
231-
retry_key=None, recipient=None, filter=None, limit=None, timeout=None):
231+
retry_key=None, recipient=None, filter=None, limit=None,
232+
notification_disabled=False, timeout=None):
232233
"""Call narrowcast API.
233234
234235
https://developers.line.biz/en/reference/messaging-api/#send-narrowcast-message
@@ -247,6 +248,8 @@ def narrowcast(
247248
:type filter: T <= :py:class:`linebot.models.filter.DemographicFilter`
248249
:param limit: limit on this narrowcast
249250
:type limit: T <= :py:class:`linebot.models.limit.Limit`
251+
:param bool notification_disabled: (optional) True to disable push notification
252+
when the message is sent. The default value is False.
250253
:param timeout: (optional) How long to wait for the server
251254
to send data before giving up, as a float,
252255
or a (connect timeout, read timeout) float tuple.
@@ -265,6 +268,7 @@ def narrowcast(
265268
'recipient': recipient.as_json_dict(),
266269
'filter': filter.as_json_dict(),
267270
'limit': limit.as_json_dict(),
271+
'notificationDisabled': notification_disabled,
268272
}
269273

270274
response = self._post(

linebot/models/limit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ class Limit(with_metaclass(ABCMeta, Base)):
3030
3131
"""
3232

33-
def __init__(self, max=None, **kwargs):
33+
def __init__(self, max=None, up_to_remaining_quota=False, **kwargs):
3434
"""__init__ method.
3535
3636
:param kwargs:
3737
"""
3838
super(Limit, self).__init__(**kwargs)
3939

4040
self.max = max
41+
self.up_to_remaining_quota = up_to_remaining_quota

tests/api/test_narrowcast_message.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ def test_narrowcast_simple_text_message(self):
8585
}
8686
},
8787
"limit": {
88-
"max": 10
89-
}
88+
"max": 10,
89+
"upToRemainingQuota": False,
90+
},
91+
"notificationDisabled": False,
9092
}
9193
)
9294

@@ -120,7 +122,7 @@ def test_narrowcast_text_message(self):
120122
)
121123
)
122124
),
123-
limit=Limit(max=100),
125+
limit=Limit(max=100, up_to_remaining_quota=True),
124126
)
125127

126128
request = responses.calls[0].request
@@ -211,8 +213,10 @@ def test_narrowcast_text_message(self):
211213
}
212214
},
213215
"limit": {
214-
"max": 100
215-
}
216+
"max": 100,
217+
"upToRemainingQuota": True,
218+
},
219+
"notificationDisabled": False,
216220
}
217221
)
218222
self.assertEqual('request_id_test', response.request_id)
@@ -242,7 +246,7 @@ def test_narrowcast_text_message_with_retry_key(self):
242246
)
243247
)
244248
),
245-
limit=Limit(max=100),
249+
limit=Limit(max=100, up_to_remaining_quota=True),
246250
retry_key='123e4567-e89b-12d3-a456-426614174000',
247251
)
248252

@@ -295,8 +299,10 @@ def test_narrowcast_text_message_with_retry_key(self):
295299
}
296300
},
297301
"limit": {
298-
"max": 100
299-
}
302+
"max": 100,
303+
"upToRemainingQuota": True,
304+
},
305+
"notificationDisabled": False,
300306
}
301307
)
302308
self.assertEqual('request_id_test', response.request_id)

0 commit comments

Comments
 (0)