|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +### Development Setup |
| 8 | +``` |
| 9 | +# Create a virtual environment |
| 10 | +python3.13 -m venv --prompt cuenca venv |
| 11 | +
|
| 12 | +# Activate the virtual environment (bash/zsh) |
| 13 | +source venv/bin/activate |
| 14 | +
|
| 15 | +# Install dependencies |
| 16 | +pip install -qU -r requirements.txt |
| 17 | +pip install -qU -r requirements-test.txt |
| 18 | +``` |
| 19 | + |
| 20 | +### Testing |
| 21 | +``` |
| 22 | +# Run all tests |
| 23 | +pytest |
| 24 | +
|
| 25 | +# Run a single test |
| 26 | +pytest tests/resources/test_transfers.py::test_transfers_create |
| 27 | +
|
| 28 | +# Run tests with VCR recording |
| 29 | +pytest --vcr-record=all tests/resources/test_transfers.py |
| 30 | +
|
| 31 | +# Run tests with coverage |
| 32 | +pytest --cov=cuenca |
| 33 | +``` |
| 34 | + |
| 35 | +### Linting and Formatting |
| 36 | +``` |
| 37 | +# Format code |
| 38 | +make format |
| 39 | +
|
| 40 | +# Run linters (flake8, isort, black, mypy) |
| 41 | +make lint |
| 42 | +
|
| 43 | +# Clean project |
| 44 | +make clean |
| 45 | +``` |
| 46 | + |
| 47 | +### Building and Publishing |
| 48 | +``` |
| 49 | +# Build package |
| 50 | +python setup.py sdist bdist_wheel |
| 51 | +
|
| 52 | +# Release to PyPI (after running tests) |
| 53 | +make release |
| 54 | +``` |
| 55 | + |
| 56 | +## Code Architecture |
| 57 | + |
| 58 | +### Overview |
| 59 | +Cuenca Python is a client library for interacting with the Cuenca API. The library is built around a resource-based architecture using Pydantic models for data validation and type safety. |
| 60 | + |
| 61 | +### Key Components |
| 62 | + |
| 63 | +1. **HTTP Client (`cuenca/http/`)**: |
| 64 | + - Handles API requests, authentication, and response processing |
| 65 | + - Supports both basic auth and JWT authentication |
| 66 | + - Configurable for sandbox or production environments |
| 67 | + |
| 68 | +2. **Resources (`cuenca/resources/`)**: |
| 69 | + - Resource classes represent API entities like Transfers, Users, Cards, etc. |
| 70 | + - Base classes provide common functionality (Retrievable, Creatable, Queryable, etc.) |
| 71 | + - All resources are exposed through the root package imports |
| 72 | + |
| 73 | +3. **Authentication**: |
| 74 | + - Configuration via environment variables (CUENCA_API_KEY, CUENCA_API_SECRET) |
| 75 | + - Manual configuration via `cuenca.configure()` |
| 76 | + - JWT token support with automatic renewal |
| 77 | + |
| 78 | +4. **Query System**: |
| 79 | + - Fluent interface for querying resources |
| 80 | + - Methods: `one()`, `first()`, `all()`, `count()` |
| 81 | + - Automatic pagination handling |
| 82 | + |
| 83 | +### Testing Architecture |
| 84 | + |
| 85 | +1. **VCR Testing**: |
| 86 | + - Uses pytest-vcr to record and replay HTTP interactions |
| 87 | + - Cassettes stored in tests/resources/cassettes/ |
| 88 | + - Filters sensitive authentication headers |
| 89 | + |
| 90 | +2. **Fixtures**: |
| 91 | + - Common test data and setup in tests/conftest.py |
| 92 | + - Resource-specific fixtures in test files |
| 93 | + |
| 94 | +### Error Handling |
| 95 | + |
| 96 | +- Custom exceptions for API errors |
| 97 | +- Validation errors from Pydantic |
| 98 | +- Query errors (NoResultFound, MultipleResultsFound) |
0 commit comments