Skip to content

Commit d74045d

Browse files
authored
Merge pull request #2 from FiscalAPI/feat/AddLadingSupport
Added lading examples
2 parents 3e33729 + 1ecc33a commit d74045d

5 files changed

Lines changed: 9644 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
PHP SDK for FiscalAPI — a Mexican electronic invoicing (CFDI) platform. Package: `fiscalapi/fiscalapi`, licensed MPL-2.0, requires PHP >= 7.4.
8+
9+
## Build & Dependencies
10+
11+
```bash
12+
composer install # Install dependencies
13+
composer dump-autoload # Regenerate autoloader after namespace/class changes
14+
```
15+
16+
No test suite exists in the repo. No linting or static analysis tools are configured.
17+
18+
## Architecture
19+
20+
**Two-layer design:** HTTP layer (`src/Http/`) and Service layer (`src/Services/`).
21+
22+
### HTTP Layer (`Fiscalapi\Http`)
23+
- `FiscalApiSettings` — Configuration object (API URL, key, tenant, version, debug, SSL, timezone)
24+
- `FiscalApiHttpClient` — Guzzle wrapper that auto-injects `X-API-KEY`, `X-TENANT-KEY`, `X-TIME-ZONE` headers. Debug mode logs requests/responses and disables SSL.
25+
- `FiscalApiHttpResponse` — PSR-7 response wrapper with JSON caching
26+
27+
### Service Layer (`Fiscalapi\Services`)
28+
- `AbstractService` — Base CRUD: `list()`, `get()`, `create()`, `update()`, `delete()`. All services extend this.
29+
- `FiscalApiClient` — Main entry point. Lazy-loads 9 services via getters (e.g., `getInvoiceService()`).
30+
- `FiscalApiClientFactory` — Static factory with instance caching keyed by `apiKey:tenant:apiUrl`.
31+
32+
### Notable Service Implementations
33+
- **InvoiceService** — Type-based routing: `'I'``income`, `'E'``credit-note`, `'P'``payment`. Has specialized methods: `cancel()`, `getPdf()`, `getXml()`, `send()`, `getStatus()`.
34+
- **CatalogService** — Custom `search(catalogName, searchText)` and `getById(catalogName, id)` methods. Min search term: 4 chars.
35+
- **DownloadCatalogService** — Throws `BadMethodCallException` for standard CRUD; uses `getList()` and `listCatalog()` instead.
36+
- **DownloadRequestService** — Methods for downloading XMLs, metadata, ZIP packages, and SAT request/response files.
37+
38+
## Coding Conventions
39+
40+
- `declare(strict_types=1)` in all files
41+
- PSR-4 autoloading: `Fiscalapi\``src/`
42+
- Explicit return types and parameter type hints throughout
43+
- Classes: PascalCase, Methods: camelCase, Constants: UPPER_SNAKE_CASE
44+
- Interfaces live alongside implementations in the same directory
45+
- Error handling: `InvalidArgumentException` (validation), `RuntimeException` (HTTP errors with chained exceptions), `BadMethodCallException` (unsupported operations)
46+
47+
## Configuration
48+
49+
Environment variables used in examples and Laravel integration:
50+
```
51+
FISCALAPI_URL, FISCALAPI_KEY, FISCALAPI_TENANT, FISCALAPI_DEBUG,
52+
FISCALAPI_VERIFY_SSL, FISCALAPI_API_VERSION, FISCALAPI_TIMEZONE
53+
```
54+
55+
Default timezone: `America/Mexico_City`. API version: `v4`.
56+
57+
## CI/CD
58+
59+
GitHub Actions workflow (`.github/workflows/CICD.yml`) triggers on tags to update Packagist via API token.

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "fiscalapi/fiscalapi",
33
"description": "SDK de PHP para FiscalAPI",
4+
"version": "4.0.384",
45
"type": "library",
56
"license": "MPL-2.0",
67
"homepage": "https://www.fiscalapi.com",

0 commit comments

Comments
 (0)