payment: Small fixes

- Semantic fixes bot.py (if XXX is not None: ...).
 - Documentation fixes (arguments which are optional).
This commit is contained in:
Noam Meltzer 2017-05-26 20:02:18 +03:00
parent 630b63ec10
commit cd24bb4ba5

View file

@ -1843,21 +1843,21 @@ class Bot(TelegramObject):
'prices': [p.to_dict() for p in prices] 'prices': [p.to_dict() for p in prices]
} }
if photo_url: if photo_url is not None:
data['photo_url'] = photo_url data['photo_url'] = photo_url
if photo_size: if photo_size is not None:
data['photo_size'] = photo_size data['photo_size'] = photo_size
if photo_width: if photo_width is not None:
data['photo_width'] = photo_width data['photo_width'] = photo_width
if photo_height: if photo_height is not None:
data['photo_height'] = photo_height data['photo_height'] = photo_height
if need_name: if need_name is not None:
data['need_name'] = need_name data['need_name'] = need_name
if need_phone_number: if need_phone_number is not None:
data['need_phone_number'] = need_phone_number data['need_phone_number'] = need_phone_number
if need_shipping_address: if need_shipping_address is not None:
data['need_shipping_address'] = need_shipping_address data['need_shipping_address'] = need_shipping_address
if is_flexible: if is_flexible is not None:
data['is_flexible'] = is_flexible data['is_flexible'] = is_flexible
return url, data return url, data
@ -1877,12 +1877,12 @@ class Bot(TelegramObject):
ok (bool): Specify True if delivery to the specified address is possible and False if ok (bool): Specify True if delivery to the specified address is possible and False if
there are any problems (for example, if delivery to the specified address there are any problems (for example, if delivery to the specified address
is not possible) is not possible)
shipping_options (List[:class:`telegram.ShippingOption`]): Required if ok is True. A shipping_options (Optional[List[:class:`telegram.ShippingOption`]]): Required if ok is
list of available shipping options. True. A list of available shipping options.
error_message (str): Required if ok is False. Error message in human readable form error_message (Optional[str]): Required if ok is False. Error message in human readable
that explains why it is impossible to complete the order (e.g. "Sorry, delivery form that explains why it is impossible to complete the order (e.g. "Sorry,
to your desired address is unavailable'). Telegram will display this message delivery to your desired address is unavailable'). Telegram will display this
to the user. message to the user.
Returns: Returns:
bool: On success, `True` is returned. bool: On success, `True` is returned.
@ -1895,9 +1895,9 @@ class Bot(TelegramObject):
data = {'shipping_query_id': shipping_query_id, 'ok': ok} data = {'shipping_query_id': shipping_query_id, 'ok': ok}
if shipping_options: if shipping_options is not None:
data['shipping_options'] = shipping_options data['shipping_options'] = shipping_options
if error_message: if error_message is not None:
data['error_message'] = error_message data['error_message'] = error_message
return url, data return url, data
@ -1912,11 +1912,11 @@ class Bot(TelegramObject):
pre_checkout_query_id (str): Unique identifier for the query to be answered pre_checkout_query_id (str): Unique identifier for the query to be answered
ok (bool): Specify True if everything is alright (goods are available, etc.) and the ok (bool): Specify True if everything is alright (goods are available, etc.) and the
bot is ready to proceed with the order. Use False if there are any problems. bot is ready to proceed with the order. Use False if there are any problems.
error_message (str): Required if ok is False. Error message in human readable form that error_message (Optional[str]): Required if ok is False. Error message in human readable
explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody form that explains the reason for failure to proceed with the checkout (e.g.
just bought the last of our amazing black T-shirts while you were busy filling out "Sorry, somebody just bought the last of our amazing black T-shirts while you were
your payment details. Please choose a different color or garment!"). Telegram will busy filling out your payment details. Please choose a different color or
display this message to the user. garment!"). Telegram will display this message to the user.
Returns: Returns:
bool: On success, `True` is returned. bool: On success, `True` is returned.
@ -1929,7 +1929,7 @@ class Bot(TelegramObject):
data = {'pre_checkout_query_id': pre_checkout_query_id, 'ok': ok} data = {'pre_checkout_query_id': pre_checkout_query_id, 'ok': ok}
if error_message: if error_message is not None:
data['error_message'] = error_message data['error_message'] = error_message
return url, data return url, data