@@ -1835,6 +1835,7 @@ def send_invoice(self,
18351835 photo_height = None ,
18361836 need_name = None ,
18371837 need_phone_number = None ,
1838+ need_email = None ,
18381839 need_shipping_address = None ,
18391840 is_flexible = None ,
18401841 disable_notification = False ,
@@ -1867,6 +1868,8 @@ def send_invoice(self,
18671868 the order
18681869 need_phone_number (Optional[bool]): Pass True, if you require the user's phone number
18691870 to complete the order
1871+ need_email (Optional[bool]): Pass True, if you require the user's email to
1872+ complete the order
18701873 need_shipping_address (Optional[bool]): Pass True, if you require the user's shipping
18711874 address to complete the order
18721875 is_flexible (Optional[bool]): Pass True, if the final price depends on the shipping
@@ -1915,6 +1918,8 @@ def send_invoice(self,
19151918 data ['need_name' ] = need_name
19161919 if need_phone_number is not None :
19171920 data ['need_phone_number' ] = need_phone_number
1921+ if need_email is not None :
1922+ data ['need_email' ] = need_email
19181923 if need_shipping_address is not None :
19191924 data ['need_shipping_address' ] = need_shipping_address
19201925 if is_flexible is not None :
@@ -1926,7 +1931,9 @@ def answer_shipping_query(self,
19261931 shipping_query_id ,
19271932 ok ,
19281933 shipping_options = None ,
1929- error_message = None ):
1934+ error_message = None ,
1935+ timeout = None ,
1936+ ** kwargs ):
19301937 """
19311938 If you sent an invoice requesting a shipping address and the parameter is_flexible was
19321939 specified, the Bot API will send an Update with a shipping_query field to the bot. Use
@@ -1943,6 +1950,7 @@ def answer_shipping_query(self,
19431950 form that explains why it is impossible to complete the order (e.g. "Sorry,
19441951 delivery to your desired address is unavailable'). Telegram will display this
19451952 message to the user.
1953+ **kwargs (dict): Arbitrary keyword arguments.
19461954
19471955 Returns:
19481956 bool: On success, `True` is returned.
@@ -1951,18 +1959,32 @@ def answer_shipping_query(self,
19511959 :class:`telegram.TelegramError`
19521960
19531961 """
1954- url = '{0]/answerShippingQuery' .format (self .base_url )
1962+
1963+ if ok is True and (shipping_options is None or error_message is not None ):
1964+ raise TelegramError (
1965+ 'answerShippingQuery: If ok is True, shipping_options '
1966+ 'should not be empty and there should not be error_message' )
1967+
1968+ if ok is False and (shipping_options is not None or error_message is None ):
1969+ raise TelegramError (
1970+ 'answerShippingQuery: If ok is False, error_message '
1971+ 'should not be empty and there should not be shipping_options' )
1972+
1973+ url_ = '{0}/answerShippingQuery' .format (self .base_url )
19551974
19561975 data = {'shipping_query_id' : shipping_query_id , 'ok' : ok }
19571976
1958- if shipping_options is not None :
1977+ if ok is True :
19591978 data ['shipping_options' ] = shipping_options
19601979 if error_message is not None :
19611980 data ['error_message' ] = error_message
19621981
1963- return url , data
1982+ result = self . _request . post ( url_ , data , timeout = timeout )
19641983
1965- def answer_pre_checkout_query (self , pre_checkout_query_id , ok , error_message = None ):
1984+ return result
1985+
1986+ def answer_pre_checkout_query (self , pre_checkout_query_id , ok ,
1987+ error_message = None , timeout = None , ** kwargs ):
19661988 """
19671989 If you sent an invoice requesting a shipping address and the parameter is_flexible was
19681990 specified, the Bot API will send an Update with a shipping_query field to the bot.
@@ -1977,6 +1999,7 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok, error_message=Non
19771999 "Sorry, somebody just bought the last of our amazing black T-shirts while you were
19782000 busy filling out your payment details. Please choose a different color or
19792001 garment!"). Telegram will display this message to the user.
2002+ **kwargs (dict): Arbitrary keyword arguments.
19802003
19812004 Returns:
19822005 bool: On success, `True` is returned.
@@ -1985,14 +2008,23 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok, error_message=Non
19852008 :class:`telegram.TelegramError`
19862009
19872010 """
1988- url = '{0]/answerPreCheckoutQuery' .format (self .base_url )
2011+
2012+ if not (ok ^ (error_message is None )):
2013+ raise TelegramError (
2014+ 'answerPreCheckoutQuery: If ok is True, there should '
2015+ 'not be error_message; if ok is False, error_message '
2016+ 'should not be empty' )
2017+
2018+ url_ = '{0}/answerPreCheckoutQuery' .format (self .base_url )
19892019
19902020 data = {'pre_checkout_query_id' : pre_checkout_query_id , 'ok' : ok }
19912021
19922022 if error_message is not None :
19932023 data ['error_message' ] = error_message
19942024
1995- return url , data
2025+ result = self ._request .post (url_ , data , timeout = timeout )
2026+
2027+ return result
19962028
19972029 @staticmethod
19982030 def de_json (data , bot ):
0 commit comments