Skip to content

Commit 4da7b8b

Browse files
chore: apply cloud review updates
1 parent 21d3b9e commit 4da7b8b

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Development Commands
6+
7+
### Testing
8+
```bash
9+
# Run PHPUnit tests
10+
./vendor/bin/phpunit tests/
11+
12+
# Run specific test file
13+
./vendor/bin/phpunit tests/ApiClientTest.php
14+
15+
# Note: Most integration tests are skipped by default as they require valid API tokens
16+
```
17+
18+
### Dependencies
19+
```bash
20+
# Install Composer dependencies
21+
composer install
22+
23+
# Install dev dependencies
24+
composer install --dev
25+
```
26+
27+
### Git Workflow
28+
```bash
29+
# Quick development push (defined in Makefile)
30+
make dev-push
31+
```
32+
33+
## Architecture Overview
34+
35+
This is a minimal, agnostic PHP SDK for OpenAPI services with only essential HTTP primitives. The architecture follows a clean, simple design inspired by the Rust implementation found in `reference/openapi-rust-sdk/`.
36+
37+
### Core Components
38+
39+
- **`OauthClient`** (`src/OauthClient.php`): Handles OAuth authentication and token management
40+
- Uses Basic Auth with username/apikey for authentication
41+
- Supports both production (`oauth.openapi.it`) and test (`test.oauth.openapi.it`) environments
42+
- Methods: `getScopes()`, `createToken()`, `getTokens()`, `deleteToken()`, `getCounters()`
43+
44+
- **`Client`** (`src/Client.php`): Agnostic HTTP client for making API calls
45+
- Uses Bearer token authentication
46+
- Supports GET, POST, PUT, DELETE, PATCH methods
47+
- Handles URL parameter encoding for GET requests
48+
- JSON payload encoding for POST/PUT/PATCH requests
49+
- 30-second timeout for all requests
50+
51+
- **`Exception`** (`src/Exception.php`): Custom exception handling for HTTP and cURL errors
52+
53+
- **Cache System** (`src/Cache/`): Optional caching interface with array-based implementation
54+
- `CacheInterface`: Contract for cache implementations
55+
- `ArrayCache`: In-memory cache implementation
56+
57+
### Key Design Principles
58+
59+
1. **Agnostic**: No API-specific classes - works with any OpenAPI service
60+
2. **Minimal**: Only core HTTP primitives, minimal dependencies (PHP 8.0+, cURL, JSON)
61+
3. **Clean Interface**: Simple method signatures following REST conventions
62+
4. **Environment Flexibility**: Built-in test/production environment switching
63+
64+
### Examples Usage Patterns
65+
66+
The `examples/` directory contains practical usage demonstrations:
67+
- Token generation with OAuth client
68+
- API calls with different HTTP methods
69+
- Complete workflow integration
70+
71+
### PSR-4 Autoloading
72+
73+
The project uses PSR-4 autoloading with `OpenApi\` namespace mapped to `src/` directory.
74+
75+
## Requirements
76+
77+
- PHP 8.0+
78+
- cURL extension
79+
- JSON extension
80+
- PHPUnit 9.5+ for testing

0 commit comments

Comments
 (0)