This plan outlines the first step in building the Pocket Casts Python API library: implementing the POST /user/login_pocket_casts endpoint. The goal is to create a robust, testable, and well-documented login feature, establishing patterns for future API functions.
-
Define User Data Model
- Add a
Usermodel inapi_pocketcasts/models/user.pybased ondata-model.md. - Update
api_pocketcasts/models/__init__.pyto import the new model.
- Add a
-
Implement Login API Method
- Add a
login_pocket_casts(email, password)method toapi_pocketcasts/client.py. - Use
httpxfor the HTTP request, parse response into theUsermodel. - Handle errors using custom exceptions from
exceptions.py.
- Add a
-
Add Authentication Logic
- Place authentication helpers in
api_pocketcasts/auth.pyif needed. - Ensure credentials/tokens are only held in memory.
- Place authentication helpers in
-
Write Unit and Integration Tests
- Create
tests/login_test.pyto cover successful login, invalid credentials, and error handling. - Use environment variables for test credentials.
- Create
-
Document the Login Feature
- Update
docs/usage.mdwith login usage examples and expected responses. - Add docstrings to all new functions and models.
- Function Docstrings: Every test function must have a concise docstring explaining the scenario being tested, what is simulated, and the expected outcome.
- Update
-
Update pyproject.toml
- Ensure dependencies (
httpx,attrs,pytest) are listed. - Set project metadata if not already present.
- Ensure dependencies (
-
Linting and CI
- Confirm code style with linters (e.g., flake8, black if used).
- Ensure GitHub Actions runs tests and lint checks.
- Should the login method be synchronous, asynchronous, or both? (Recommend both for consistency.)
- Should error messages be standardized across all API methods?
- Confirm if additional login flows (Google, Sonos) are needed in the future.
This plan expands the Pocket Casts Python API library to fully support user podcast subscriptions, including retrieving, adding, and removing subscriptions via the following endpoints:
POST /user/podcast/list: Retrieve the user's subscribed podcasts.POST /user/podcast/subscribe: Add a podcast to the user's subscriptions.POST /user/podcast/unsubscribe: Remove a podcast from the user's subscriptions.
-
Define Podcast and Subscription Data Models
- Add or update
Podcastand any supporting models inapi_pocketcasts/models/podcast.pybased ondata-model.mdand API responses. - Add a
PodcastListor similar container model if the response is a list. - Add a
SubscriptionResultor similar model for subscribe/unsubscribe responses if needed. - Update
api_pocketcasts/models/__init__.pyto import the new model(s).
- Add or update
-
Implement Subscription API Methods
- Add the following methods to
api_pocketcasts/client.py(and async_client.py):get_subscribed_podcasts()subscribe_to_podcast(podcast_id)unsubscribe_from_podcast(podcast_id)
- Use
httpxfor HTTP requests, parse responses into the new model(s). - Handle errors using custom exceptions from
exceptions.py.
- Add the following methods to
-
Add Authentication Logic (if needed)
- Ensure all methods use the current access token and handle token refresh if required.
-
Write Unit and Integration Tests
- Create or update tests (e.g.,
tests/podcast_list_test.py,tests/podcast_subscribe_test.py) to cover:- Successful retrieval, subscription, and unsubscription
- Edge cases (already subscribed, not found, already unsubscribed, etc.)
- Error handling
- Use environment variables for test credentials.
- Create or update tests (e.g.,
-
Document the Subscription Features
- Update
docs/usage.mdwith usage examples and expected responses for all new methods. - Add docstrings to all new functions and models.
- Update
-
Update pyproject.toml (if needed)
- Ensure any new dependencies are listed.
-
Linting and CI
- Confirm code style with linters (e.g., flake8, black).
- Ensure GitHub Actions runs tests and lint checks.
- Should the methods support pagination or filtering if the API allows?
- Should all methods be available in both sync and async clients?
- Confirm if additional podcast list endpoints (e.g., archived, starred) are needed in the future.
- Consider idempotency and error handling for repeated subscribe/unsubscribe calls.