PropertyMe Cache And OAuth ========================== PropertyMe is treated as the source of truth. Alba Core should keep working from the privacy-shaped local cache when live API access is unavailable. .. autofunction:: app.propertyme.cache.load_property_cache Example: load the local cache ----------------------------- .. code-block:: python from app.propertyme.cache import load_property_cache properties = load_property_cache("data/propertyme_property_seed_latest.json") print(len(properties)) print(properties[0].to_public_dict()) .. autoclass:: app.propertyme.oauth.PropertyMeOAuthConfig :members: .. autofunction:: app.propertyme.oauth.build_authorization_url .. autofunction:: app.propertyme.oauth.token_exchange_payload .. autofunction:: app.propertyme.oauth.refresh_payload Example: build OAuth requests ----------------------------- .. code-block:: python from app.propertyme.oauth import ( PropertyMeOAuthConfig, build_authorization_url, refresh_payload, token_exchange_payload, ) config = PropertyMeOAuthConfig( client_id="from-env", client_secret="from-env", redirect_uri="http://localhost:65385/home/callback", auth_url="https://login.propertyme.com/connect/authorize", token_url="https://login.propertyme.com/connect/token", scope="offline_access property_read", ) auth_url, state = build_authorization_url(config) token_payload = token_exchange_payload(config, code="callback-code") refresh_body = refresh_payload(config, refresh_token="stored-refresh-token") print(auth_url) print(state) print(token_payload["grant_type"]) print(refresh_body["grant_type"]) .. autoclass:: app.propertyme.client.PropertyMeClient :members: Example: refresh a raw rental cache ----------------------------------- .. code-block:: python import asyncio from app.propertyme.client import PropertyMeClient async def main() -> None: client = PropertyMeClient(access_token="from-secure-storage") count = await client.save_rentals_cache("reference/propertyme_rentals_raw.json") print(count) asyncio.run(main()) Raw exports should be mapped or redacted before they are used as committed test fixtures.