108 lines
3.0 KiB
Markdown
108 lines
3.0 KiB
Markdown
docker run --rm -p 3030:3000 gotenberg/gotenberg:8
|
|
|
|
## Configuration
|
|
|
|
This application can be configured using a `config.json` file in the root of the project, or by using environment variables. Values set in environment variables will override the values from the `config.json` file.
|
|
|
|
You can use the `config.example.json` file as a starting point for your `config.json`.
|
|
|
|
### Environment Variables
|
|
|
|
The following environment variables can be used for configuration:
|
|
|
|
| Variable | Description |
|
|
| --------------------- | --------------------------------------------- |
|
|
| `PDF_HOSTNAME` | The hostname of the PDF generator (Gotenberg) |
|
|
| `GITEA_URL` | The URL of your Gitea instance |
|
|
| `GITEA_TOKEN` | Your Gitea API token |
|
|
| `EMAIL_FROM` | The "From" address for sending emails |
|
|
| `EMAIL_SMTP_HOST` | The SMTP server host |
|
|
| `EMAIL_SMTP_PORT` | The SMTP server port |
|
|
| `EMAIL_SMTP_USER` | The username for SMTP authentication |
|
|
| `EMAIL_SMTP_PASSWORD` | The password for SMTP authentication |
|
|
|
|
## API Endpoints
|
|
|
|
### POST /invoice
|
|
|
|
Creates a new invoice.
|
|
|
|
```bash
|
|
curl -X POST -H "Content-Type: application/json" -d '{
|
|
"debtor": {
|
|
"name": "John Doe",
|
|
"Address": {
|
|
"street": "Musterstrasse",
|
|
"number": "1",
|
|
"zipCode": "1234",
|
|
"place": "Musterstadt",
|
|
"country": "CH"
|
|
},
|
|
"contact": "john.doe@example.com"
|
|
},
|
|
"creditor": {
|
|
"name": "Jane Doe",
|
|
"Address": {
|
|
"street": "Beispielweg",
|
|
"number": "2",
|
|
"zipCode": "5678",
|
|
"place": "Beispielhausen",
|
|
"country": "CH"
|
|
},
|
|
"contact": "jane.doe@example.com",
|
|
"iban": "CH1234567890123456789"
|
|
},
|
|
"durationThreshold": "1h",
|
|
"hourlyRate": 100,
|
|
"repositories": [
|
|
"lou-taylor/accounting"
|
|
]
|
|
}' http://localhost:8080/invoice
|
|
```
|
|
|
|
### POST /invoice/send
|
|
|
|
Creates a new invoice and sends it by email.
|
|
|
|
```bash
|
|
curl -X POST -H "Content-Type: application/json" -d '{
|
|
"to": ["john.doe@example.com"],
|
|
"subject": "Invoice for project lou-taylor/accounting",
|
|
"body": "Hi John,\n\nPlease find attached the invoice for the project lou-taylor/accounting.\n\nBest regards,\nJane Doe",
|
|
"invoice": {
|
|
"debtor": {
|
|
"name": "John Doe",
|
|
"Address": {
|
|
"street": "Musterstrasse",
|
|
"number": "1",
|
|
"zipCode": "1234",
|
|
"place": "Musterstadt",
|
|
"country": "CH"
|
|
},
|
|
"contact": "john.doe@example.com"
|
|
},
|
|
"creditor": {
|
|
"name": "Jane Doe",
|
|
"Address": {
|
|
"street": "Beispielweg",
|
|
"number": "2",
|
|
"zipCode": "5678",
|
|
"place": "Beispielhausen",
|
|
"country": "CH"
|
|
},
|
|
"contact": "jane.doe@example.com",
|
|
"iban": "CH1234567890123456789"
|
|
},
|
|
"durationThreshold": "1h",
|
|
"hourlyRate": 100,
|
|
"repositories": [
|
|
"lou-taylor/accounting"
|
|
]
|
|
}
|
|
}' http://localhost:8080/invoice/send
|
|
```
|
|
|
|
```
|
|
|
|
```
|