本文整理汇总了Python中edx_rest_api_client.client.EdxRestApiClient.orders方法的典型用法代码示例。如果您正苦于以下问题:Python EdxRestApiClient.orders方法的具体用法?Python EdxRestApiClient.orders怎么用?Python EdxRestApiClient.orders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edx_rest_api_client.client.EdxRestApiClient
的用法示例。
在下文中一共展示了EdxRestApiClient.orders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fulfill_order
# 需要导入模块: from edx_rest_api_client.client import EdxRestApiClient [as 别名]
# 或者: from edx_rest_api_client.client.EdxRestApiClient import orders [as 别名]
def fulfill_order(self, order_number, site_code=None):
"""Fulfills an order.
Arguments:
order_number (str): Order number indicating which order to fulfill.
Returns:
None
"""
ecommerce_api_root = get_configuration('ECOMMERCE_API_ROOT', site_code=site_code)
max_fulfillment_retries = get_configuration('MAX_FULFILLMENT_RETRIES', site_code=site_code)
signing_key = get_configuration('JWT_SECRET_KEY', site_code=site_code)
issuer = get_configuration('JWT_ISSUER', site_code=site_code)
service_username = get_configuration('ECOMMERCE_SERVICE_USERNAME', site_code=site_code)
api = EdxRestApiClient(ecommerce_api_root, signing_key=signing_key, issuer=issuer, username=service_username)
try:
logger.info('Requesting fulfillment of order [%s].', order_number)
api.orders(order_number).fulfill.put()
except exceptions.HttpClientError as exc:
status_code = exc.response.status_code # pylint: disable=no-member
if status_code == 406:
# The order is not fulfillable. Therefore, it must be complete.
logger.info('Order [%s] has already been fulfilled. Ignoring.', order_number)
raise Ignore()
else:
# Unknown client error. Let's retry to resolve it.
logger.warning(
'Fulfillment of order [%s] failed because of HttpClientError. Retrying',
order_number,
exc_info=True
)
_retry_order(self, exc, max_fulfillment_retries, order_number)
except (exceptions.HttpServerError, exceptions.Timeout) as exc:
# Fulfillment failed, retry
_retry_order(self, exc, max_fulfillment_retries, order_number)