@@ -1926,7 +1926,9 @@ def answer_shipping_query(self,
19261926 shipping_query_id ,
19271927 ok ,
19281928 shipping_options = None ,
1929- error_message = None ):
1929+ error_message = None ,
1930+ timeout = None ,
1931+ ** kwargs ):
19301932 """
19311933 If you sent an invoice requesting a shipping address and the parameter is_flexible was
19321934 specified, the Bot API will send an Update with a shipping_query field to the bot. Use
@@ -1943,6 +1945,7 @@ def answer_shipping_query(self,
19431945 that explains why it is impossible to complete the order (e.g. "Sorry, delivery
19441946 to your desired address is unavailable'). Telegram will display this message
19451947 to the user.
1948+ **kwargs (dict): Arbitrary keyword arguments.
19461949
19471950 Returns:
19481951 bool: On success, `True` is returned.
@@ -1951,18 +1954,32 @@ def answer_shipping_query(self,
19511954 :class:`telegram.TelegramError`
19521955
19531956 """
1954- url = '{0]/answerShippingQuery' .format (self .base_url )
1957+
1958+ if ok is True and (shipping_options is None or error_message is not None ):
1959+ raise TelegramError (
1960+ 'answerShippingQuery: If ok is True, shipping_options '
1961+ 'should not be empty and there should not be error_message' )
1962+
1963+ if ok is False and (shipping_options is not None or error_message is None ):
1964+ raise TelegramError (
1965+ 'answerShippingQuery: If ok is False, error_message '
1966+ 'should not be empty and there should not be shipping_options' )
1967+
1968+ url_ = '{0}/answerShippingQuery' .format (self .base_url )
19551969
19561970 data = {'shipping_query_id' : shipping_query_id , 'ok' : ok }
19571971
1958- if shipping_options :
1972+ if ok is True :
19591973 data ['shipping_options' ] = shipping_options
19601974 if error_message :
19611975 data ['error_message' ] = error_message
19621976
1963- return url , data
1977+ result = self . _request . post ( url_ , data , timeout = timeout )
19641978
1965- def answer_pre_checkout_query (self , pre_checkout_query_id , ok , error_message = None ):
1979+ return result
1980+
1981+ def answer_pre_checkout_query (self , pre_checkout_query_id , ok ,
1982+ error_message = None , timeout = None , ** kwargs ):
19661983 """
19671984 If you sent an invoice requesting a shipping address and the parameter is_flexible was
19681985 specified, the Bot API will send an Update with a shipping_query field to the bot.
@@ -1977,6 +1994,7 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok, error_message=Non
19771994 just bought the last of our amazing black T-shirts while you were busy filling out
19781995 your payment details. Please choose a different color or garment!"). Telegram will
19791996 display this message to the user.
1997+ **kwargs (dict): Arbitrary keyword arguments.
19801998
19811999 Returns:
19822000 bool: On success, `True` is returned.
@@ -1985,14 +2003,23 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok, error_message=Non
19852003 :class:`telegram.TelegramError`
19862004
19872005 """
1988- url = '{0]/answerPreCheckoutQuery' .format (self .base_url )
2006+
2007+ if (ok is not True and error_message is None ) or (ok is True and error_message is not None ):
2008+ raise TelegramError (
2009+ 'answerPreCheckoutQuery: If ok is True, there should '
2010+ 'not be error_message; if ok is False, error_message '
2011+ 'should not be empty' )
2012+
2013+ url_ = '{0}/answerPreCheckoutQuery' .format (self .base_url )
19892014
19902015 data = {'pre_checkout_query_id' : pre_checkout_query_id , 'ok' : ok }
19912016
19922017 if error_message :
19932018 data ['error_message' ] = error_message
19942019
1995- return url , data
2020+ result = self ._request .post (url_ , data , timeout = timeout )
2021+
2022+ return result
19962023
19972024 @staticmethod
19982025 def de_json (data , bot ):
0 commit comments