@@ -35,13 +35,16 @@ class LineBotApi(object):
3535 """LineBotApi provides interface for LINE messaging API."""
3636
3737 DEFAULT_API_ENDPOINT = 'https://api.line.me'
38+ DEFAULT_API_DATA_ENDPOINT = 'https://api-data.line.me'
3839
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 ,
4042 timeout = HttpClient .DEFAULT_TIMEOUT , http_client = RequestsHttpClient ):
4143 """__init__ method.
4244
4345 :param str channel_access_token: Your channel access token
4446 :param str endpoint: (optional) Default is https://api.line.me
47+ :param str data_endpoint: (optional) Default is https://api-data.line.me
4548 :param timeout: (optional) How long to wait for the server
4649 to send data before giving up, as a float,
4750 or a (connect timeout, read timeout) float tuple.
@@ -51,6 +54,7 @@ def __init__(self, channel_access_token, endpoint=DEFAULT_API_ENDPOINT,
5154 :py:class:`linebot.http_client.RequestsHttpClient`
5255 :type http_client: T <= :py:class:`linebot.http_client.HttpClient`
5356 """
57+ self .data_endpoint = data_endpoint
5458 self .endpoint = endpoint
5559 self .headers = {
5660 'Authorization' : 'Bearer ' + channel_access_token ,
@@ -441,7 +445,7 @@ def get_message_content(self, message_id, timeout=None):
441445 """
442446 response = self ._get (
443447 '/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
445449 )
446450
447451 return Content (response )
@@ -664,7 +668,7 @@ def get_rich_menu_image(self, rich_menu_id, timeout=None):
664668 """
665669 response = self ._get (
666670 '/v2/bot/richmenu/{rich_menu_id}/content' .format (rich_menu_id = rich_menu_id ),
667- timeout = timeout
671+ endpoint = self . data_endpoint , timeout = timeout
668672 )
669673
670674 return Content (response )
@@ -687,6 +691,7 @@ def set_rich_menu_image(self, rich_menu_id, content_type, content, timeout=None)
687691 """
688692 self ._post (
689693 '/v2/bot/richmenu/{rich_menu_id}/content' .format (rich_menu_id = rich_menu_id ),
694+ endpoint = self .data_endpoint ,
690695 data = content ,
691696 headers = {'Content-Type' : content_type },
692697 timeout = timeout
@@ -961,8 +966,8 @@ def get_insight_message_event(self, request_id, timeout=None):
961966
962967 return InsightMessageEventResponse .new_from_json_dict (response .json )
963968
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
966971
967972 if headers is None :
968973 headers = {}
@@ -975,8 +980,8 @@ def _get(self, path, params=None, headers=None, stream=False, timeout=None):
975980 self .__check_error (response )
976981 return response
977982
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
980985
981986 if headers is None :
982987 headers = {'Content-Type' : 'application/json' }
@@ -989,8 +994,8 @@ def _post(self, path, data=None, headers=None, timeout=None):
989994 self .__check_error (response )
990995 return response
991996
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
994999
9951000 if headers is None :
9961001 headers = {}
0 commit comments