# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

PHP SDK for the Fortnox API, generated from an OpenAPI v3 specification. Fortnox is a Swedish accounting/ERP platform. The library provides access to invoices, orders, customers, articles, suppliers, vouchers, payroll, warehouse, and more.

## Build Commands

### Regenerate PHP Library
```bash
./openapi/build.sh
```
Regenerates the entire library from `openapi/openapi.json` using OpenAPI Generator v7.19.0 via Docker.

### Testing
```bash
composer install
vendor/bin/phpunit                    # Run all tests
vendor/bin/phpunit --filter ClassName # Run specific test class
```

### Code Style
```bash
vendor/bin/php-cs-fixer fix           # Fix code style issues
vendor/bin/php-cs-fixer fix --dry-run # Check without fixing
```

## Architecture

### Generated Library Structure
- **`lib/Api/`** — 82 API classes, one per resource group (e.g. `FortnoxInvoicesApi`, `FortnoxCustomersApi`, `FortnoxVouchersApi`)
- **`lib/Model/`** — 621 model classes for requests and responses
- **`lib/Configuration.php`** — Client configuration including base URL and OAuth2 bearer token
- **`lib/ObjectSerializer.php`** — JSON serialization/deserialization

### API Class Naming Conventions
Files in `lib/Api/` follow three naming prefixes:
- **`Fortnox*Api`** — Core accounting resources (invoices, customers, articles, vouchers, etc.)
- **`Warehouse*Api`** — Warehouse/inventory management resources
- **`Integration*Api`**, **`TimeReporting*Api`**, **`FileAttachments*Api`** — Supplementary integrations

### Method Pattern Per API Class
Each API class exposes four variants per operation:
- `someControllerDoAction(...)` — Synchronous, returns deserialized model
- `someControllerDoActionWithHttpInfo(...)` — Synchronous, returns `[data, statusCode, headers]`
- `someControllerDoActionAsync(...)` — Returns a Promise
- `someControllerDoActionAsyncWithHttpInfo(...)` — Async with HTTP info

### Authentication
Fortnox uses OAuth2. Configure a bearer token via `Configuration::setAccessToken()`:

```php
$config = Fortnox\Configuration::getDefaultConfiguration()
    ->setAccessToken('your-oauth2-access-token');

$api = new Fortnox\Api\FortnoxInvoicesApi(
    new GuzzleHttp\Client(),
    $config
);
```

Base URL is `https://api.fortnox.se`.

### Rate Limits
25 requests per 5 seconds (300/minute) per access token.

## Important Notes

### Code Generation
- **Do not manually edit** files in `lib/`, `docs/`, or `test/` — they are fully regenerated by `build.sh`
- All customisations must be made to `openapi/openapi.json` or `openapi/config.json`
- `openapi/config.json` sets namespace (`Fortnox`), package name (`talisman/fortnox`), and version

### Package Details
- **Namespace**: `Fortnox\`
- **PHP Requirement**: ^8.1
- **Package**: `talisman/fortnox`
- **Dependencies**: Guzzle HTTP client, PSR-7
