diff --git a/hass_nabucasa/cloud_api.py b/hass_nabucasa/cloud_api.py index d761d2975..4a5e3f9df 100644 --- a/hass_nabucasa/cloud_api.py +++ b/hass_nabucasa/cloud_api.py @@ -133,3 +133,15 @@ async def async_subscription_info(cloud): await cloud.auth.async_renew_access_token() return data + + +@_check_token +async def async_migrate_paypal_agreement(cloud): + """Migrate a paypal agreement from legacy.""" + resp = await cloud.websession.post( + f"https://{cloud.accounts_server}/migrate_paypal_agreement", + headers={"authorization": cloud.id_token}, + ) + _do_log_response(resp) + resp.raise_for_status() + return await resp.json() diff --git a/setup.py b/setup.py index b4be7eb53..f4dd30d9a 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -VERSION = "0.56.0" +VERSION = "0.57.0" setup( name="hass-nabucasa", diff --git a/tests/test_cloud_api.py b/tests/test_cloud_api.py index 2065332cf..f44ab572f 100644 --- a/tests/test_cloud_api.py +++ b/tests/test_cloud_api.py @@ -152,3 +152,21 @@ async def test_subscription_info(auth_cloud_mock, aioclient_mock): "provider": "mock-provider", } assert len(mock_renew.mock_calls) == 1 + + +async def test_migrate_paypal_agreement(auth_cloud_mock, aioclient_mock): + """Test a paypal agreement from legacy.""" + aioclient_mock.post( + "https://example.com/migrate_paypal_agreement", + json={ + "url": "https://example.com/some/path", + }, + ) + auth_cloud_mock.id_token = "mock-id-token" + auth_cloud_mock.accounts_server = "example.com" + + data = await cloud_api.async_migrate_paypal_agreement(auth_cloud_mock) + assert len(aioclient_mock.mock_calls) == 1 + assert data == { + "url": "https://example.com/some/path", + }