@@ -35,13 +35,16 @@ class LineBotApi(object):
35
35
"""LineBotApi provides interface for LINE messaging API."""
36
36
37
37
DEFAULT_API_ENDPOINT = 'https://api.line.me'
38
+ DEFAULT_API_DATA_ENDPOINT = 'https://api-data.line.me'
38
39
39
- def __init__ (self , channel_access_token , endpoint = DEFAULT_API_ENDPOINT ,
40
+ def __init__ (self , channel_access_token ,
41
+ endpoint = DEFAULT_API_ENDPOINT , data_endpoint = DEFAULT_API_DATA_ENDPOINT ,
40
42
timeout = HttpClient .DEFAULT_TIMEOUT , http_client = RequestsHttpClient ):
41
43
"""__init__ method.
42
44
43
45
:param str channel_access_token: Your channel access token
44
46
:param str endpoint: (optional) Default is https://api.line.me
47
+ :param str data_endpoint: (optional) Default is https://api-data.line.me
45
48
:param timeout: (optional) How long to wait for the server
46
49
to send data before giving up, as a float,
47
50
or a (connect timeout, read timeout) float tuple.
@@ -51,6 +54,7 @@ def __init__(self, channel_access_token, endpoint=DEFAULT_API_ENDPOINT,
51
54
:py:class:`linebot.http_client.RequestsHttpClient`
52
55
:type http_client: T <= :py:class:`linebot.http_client.HttpClient`
53
56
"""
57
+ self .data_endpoint = data_endpoint
54
58
self .endpoint = endpoint
55
59
self .headers = {
56
60
'Authorization' : 'Bearer ' + channel_access_token ,
@@ -441,7 +445,7 @@ def get_message_content(self, message_id, timeout=None):
441
445
"""
442
446
response = self ._get (
443
447
'/v2/bot/message/{message_id}/content' .format (message_id = message_id ),
444
- stream = True , timeout = timeout
448
+ endpoint = self . data_endpoint , stream = True , timeout = timeout
445
449
)
446
450
447
451
return Content (response )
@@ -664,7 +668,7 @@ def get_rich_menu_image(self, rich_menu_id, timeout=None):
664
668
"""
665
669
response = self ._get (
666
670
'/v2/bot/richmenu/{rich_menu_id}/content' .format (rich_menu_id = rich_menu_id ),
667
- timeout = timeout
671
+ endpoint = self . data_endpoint , timeout = timeout
668
672
)
669
673
670
674
return Content (response )
@@ -687,6 +691,7 @@ def set_rich_menu_image(self, rich_menu_id, content_type, content, timeout=None)
687
691
"""
688
692
self ._post (
689
693
'/v2/bot/richmenu/{rich_menu_id}/content' .format (rich_menu_id = rich_menu_id ),
694
+ endpoint = self .data_endpoint ,
690
695
data = content ,
691
696
headers = {'Content-Type' : content_type },
692
697
timeout = timeout
@@ -961,8 +966,8 @@ def get_insight_message_event(self, request_id, timeout=None):
961
966
962
967
return InsightMessageEventResponse .new_from_json_dict (response .json )
963
968
964
- def _get (self , path , params = None , headers = None , stream = False , timeout = None ):
965
- url = self .endpoint + path
969
+ def _get (self , path , endpoint = None , params = None , headers = None , stream = False , timeout = None ):
970
+ url = ( endpoint or self .endpoint ) + path
966
971
967
972
if headers is None :
968
973
headers = {}
@@ -975,8 +980,8 @@ def _get(self, path, params=None, headers=None, stream=False, timeout=None):
975
980
self .__check_error (response )
976
981
return response
977
982
978
- def _post (self , path , data = None , headers = None , timeout = None ):
979
- url = self .endpoint + path
983
+ def _post (self , path , endpoint = None , data = None , headers = None , timeout = None ):
984
+ url = ( endpoint or self .endpoint ) + path
980
985
981
986
if headers is None :
982
987
headers = {'Content-Type' : 'application/json' }
@@ -989,8 +994,8 @@ def _post(self, path, data=None, headers=None, timeout=None):
989
994
self .__check_error (response )
990
995
return response
991
996
992
- def _delete (self , path , data = None , headers = None , timeout = None ):
993
- url = self .endpoint + path
997
+ def _delete (self , path , endpoint = None , data = None , headers = None , timeout = None ):
998
+ url = ( endpoint or self .endpoint ) + path
994
999
995
1000
if headers is None :
996
1001
headers = {}
0 commit comments