|
1 | 1 | # extend-python |
| 2 | + |
2 | 3 | Python library for the Extend API |
| 4 | + |
| 5 | +[](https://www.python.org/downloads/) |
| 6 | +[](https://opensource.org/licenses/MIT) |
| 7 | +[](https://github.com/psf/black) |
| 8 | + |
| 9 | +A Python client for the Extend API, providing a simple and intuitive interface for managing virtual cards, transactions, |
| 10 | +and more. |
| 11 | + |
| 12 | +## Features |
| 13 | + |
| 14 | +- Create and manage virtual cards |
| 15 | +- Handle recurring card operations |
| 16 | +- Track transactions |
| 17 | +- Full async/await support |
| 18 | +- Type hints and validation |
| 19 | +- Comprehensive test suite |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +### From PyPI |
| 24 | + |
| 25 | +```bash |
| 26 | +pip install extend-api-client |
| 27 | +``` |
| 28 | + |
| 29 | +### From Source |
| 30 | + |
| 31 | +```bash |
| 32 | +git clone https://github.com/yourusername/extend-api-client.git |
| 33 | +cd extend-api-client |
| 34 | +pip install -e . |
| 35 | +``` |
| 36 | + |
| 37 | +## Quick Start |
| 38 | + |
| 39 | +```python |
| 40 | +import asyncio |
| 41 | +from extend import ExtendAPI |
| 42 | + |
| 43 | + |
| 44 | +async def main(): |
| 45 | + # Initialize the client |
| 46 | + client = ExtendAPI( |
| 47 | + api_key="your-api-key", |
| 48 | + api_secret="your-api-secret" |
| 49 | + ) |
| 50 | + |
| 51 | + # Get all virtual cards |
| 52 | + cards = await client.get_virtual_cards() |
| 53 | + print("Virtual Cards:", cards) |
| 54 | + |
| 55 | + # Get all transactions |
| 56 | + transactions = await client.get_transactions() |
| 57 | + print("Transactions:", transactions) |
| 58 | + |
| 59 | + |
| 60 | +# Run the async function |
| 61 | +asyncio.run(main()) |
| 62 | +``` |
| 63 | + |
| 64 | +## Environment Variables |
| 65 | + |
| 66 | +The following environment variables are required for integration tests and examples: |
| 67 | + |
| 68 | +- `EXTEND_API_KEY`: Your Extend API key |
| 69 | +- `EXTEND_API_SECRET`: Your Extend API secret |
| 70 | +- `EXTEND_TEST_RECIPIENT`: Email address for test card recipient |
| 71 | +- `EXTEND_TEST_CARDHOLDER`: Email address for test cardholder |
| 72 | + |
| 73 | +## Development Setup |
| 74 | + |
| 75 | +1. Clone the repository: |
| 76 | + ```bash |
| 77 | + git clone https://github.com/yourusername/extend-api-client.git |
| 78 | + cd extend-api-client |
| 79 | + ``` |
| 80 | + |
| 81 | +2. Create and activate a virtual environment: |
| 82 | + ```bash |
| 83 | + python -m venv venv |
| 84 | + source venv/bin/activate # On Windows: venv\Scripts\activate |
| 85 | + ``` |
| 86 | + |
| 87 | +3. Install development dependencies: |
| 88 | + ```bash |
| 89 | + pip install -e ".[dev]" |
| 90 | + ``` |
| 91 | + |
| 92 | +4. Run tests: |
| 93 | + ```bash |
| 94 | + # Run all tests |
| 95 | + pytest |
| 96 | + |
| 97 | + # Run only unit tests |
| 98 | + pytest tests/test_client.py |
| 99 | + |
| 100 | + # Run only integration tests |
| 101 | + pytest tests/test_integration.py |
| 102 | + ``` |
| 103 | + |
| 104 | +5. Format code: |
| 105 | + ```bash |
| 106 | + black . |
| 107 | + isort . |
| 108 | + ``` |
| 109 | + |
| 110 | +## Testing |
| 111 | + |
| 112 | +The project includes both unit tests and integration tests: |
| 113 | + |
| 114 | +- Unit tests (`tests/test_client.py`): Test the client's internal logic and validation |
| 115 | +- Integration tests (`tests/test_integration.py`): Test actual API interactions |
| 116 | +- Example notebook (`notebooks/api_testing.ipynb`): Interactive examples |
| 117 | + |
| 118 | +To run integration tests, make sure you have set up the required environment variables. |
| 119 | + |
| 120 | +## Contributing |
| 121 | + |
| 122 | +Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to |
| 123 | +discuss what you would like to change. |
| 124 | + |
| 125 | +1. Fork the repository |
| 126 | +2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
| 127 | +3. Commit your changes (`git commit -m 'Add some amazing feature'`) |
| 128 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 129 | +5. Open a Pull Request |
| 130 | + |
| 131 | +## License |
| 132 | + |
| 133 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 134 | + |
| 135 | +## Acknowledgments |
| 136 | + |
| 137 | +- [Extend API Documentation](https://docs.extend.com) |
| 138 | +- [httpx](https://www.python-httpx.org/) for async HTTP requests |
0 commit comments