Use the async_migrate_paypal_agreement function to get the migration URL (#83469)
* Use the async_migrate_paypal_agreement function to get the migration URL * Update URL * Handle timeout error
This commit is contained in:
parent
dfb0887765
commit
f5cfd0329c
4 changed files with 100 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
"""Subscription information."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
|
@ -18,7 +19,28 @@ async def async_subscription_info(cloud: Cloud) -> dict[str, Any] | None:
|
|||
try:
|
||||
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||
return await cloud_api.async_subscription_info(cloud)
|
||||
except asyncio.TimeoutError:
|
||||
_LOGGER.error(
|
||||
"A timeout of %s was reached while trying to fetch subscription information",
|
||||
REQUEST_TIMEOUT,
|
||||
)
|
||||
except ClientError:
|
||||
_LOGGER.error("Failed to fetch subscription information")
|
||||
|
||||
return None
|
||||
|
||||
|
||||
async def async_migrate_paypal_agreement(cloud: Cloud) -> dict[str, Any] | None:
|
||||
"""Migrate a paypal agreement from legacy."""
|
||||
try:
|
||||
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||
return await cloud_api.async_migrate_paypal_agreement(cloud)
|
||||
except asyncio.TimeoutError:
|
||||
_LOGGER.error(
|
||||
"A timeout of %s was reached while trying to start agreement migration",
|
||||
REQUEST_TIMEOUT,
|
||||
)
|
||||
except ClientError as exception:
|
||||
_LOGGER.error("Failed to start agreement migration - %s", exception)
|
||||
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue