templatefox 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- templatefox-1.0.0/LICENSE +21 -0
- templatefox-1.0.0/PKG-INFO +225 -0
- templatefox-1.0.0/README.md +204 -0
- templatefox-1.0.0/pyproject.toml +95 -0
- templatefox-1.0.0/setup.cfg +7 -0
- templatefox-1.0.0/setup.py +50 -0
- templatefox-1.0.0/templatefox/__init__.py +87 -0
- templatefox-1.0.0/templatefox/api/__init__.py +8 -0
- templatefox-1.0.0/templatefox/api/account_api.py +579 -0
- templatefox-1.0.0/templatefox/api/integrations_api.py +1085 -0
- templatefox-1.0.0/templatefox/api/pdf_api.py +325 -0
- templatefox-1.0.0/templatefox/api/templates_api.py +562 -0
- templatefox-1.0.0/templatefox/api_client.py +805 -0
- templatefox-1.0.0/templatefox/api_response.py +21 -0
- templatefox-1.0.0/templatefox/configuration.py +609 -0
- templatefox-1.0.0/templatefox/exceptions.py +220 -0
- templatefox-1.0.0/templatefox/models/__init__.py +33 -0
- templatefox-1.0.0/templatefox/models/account_info_response.py +95 -0
- templatefox-1.0.0/templatefox/models/create_pdf_request.py +149 -0
- templatefox-1.0.0/templatefox/models/create_pdf_response.py +94 -0
- templatefox-1.0.0/templatefox/models/export_type.py +38 -0
- templatefox-1.0.0/templatefox/models/http_validation_error.py +96 -0
- templatefox-1.0.0/templatefox/models/location_inner.py +139 -0
- templatefox-1.0.0/templatefox/models/s3_config_request.py +126 -0
- templatefox-1.0.0/templatefox/models/s3_config_response.py +98 -0
- templatefox-1.0.0/templatefox/models/s3_success_response.py +88 -0
- templatefox-1.0.0/templatefox/models/s3_test_response.py +90 -0
- templatefox-1.0.0/templatefox/models/template_field.py +101 -0
- templatefox-1.0.0/templatefox/models/template_list_item.py +94 -0
- templatefox-1.0.0/templatefox/models/templates_list_response.py +96 -0
- templatefox-1.0.0/templatefox/models/transaction.py +108 -0
- templatefox-1.0.0/templatefox/models/transactions_response.py +102 -0
- templatefox-1.0.0/templatefox/models/validation_error.py +100 -0
- templatefox-1.0.0/templatefox/py.typed +0 -0
- templatefox-1.0.0/templatefox/rest.py +264 -0
- templatefox-1.0.0/templatefox.egg-info/PKG-INFO +225 -0
- templatefox-1.0.0/templatefox.egg-info/SOURCES.txt +59 -0
- templatefox-1.0.0/templatefox.egg-info/dependency_links.txt +1 -0
- templatefox-1.0.0/templatefox.egg-info/requires.txt +4 -0
- templatefox-1.0.0/templatefox.egg-info/top_level.txt +1 -0
- templatefox-1.0.0/test/test_account_api.py +46 -0
- templatefox-1.0.0/test/test_account_info_response.py +54 -0
- templatefox-1.0.0/test/test_create_pdf_request.py +61 -0
- templatefox-1.0.0/test/test_create_pdf_response.py +59 -0
- templatefox-1.0.0/test/test_export_type.py +34 -0
- templatefox-1.0.0/test/test_http_validation_error.py +59 -0
- templatefox-1.0.0/test/test_integrations_api.py +60 -0
- templatefox-1.0.0/test/test_location_inner.py +51 -0
- templatefox-1.0.0/test/test_pdf_api.py +39 -0
- templatefox-1.0.0/test/test_s3_config_request.py +59 -0
- templatefox-1.0.0/test/test_s3_config_response.py +63 -0
- templatefox-1.0.0/test/test_s3_success_response.py +53 -0
- templatefox-1.0.0/test/test_s3_test_response.py +55 -0
- templatefox-1.0.0/test/test_template_field.py +58 -0
- templatefox-1.0.0/test/test_template_list_item.py +59 -0
- templatefox-1.0.0/test/test_templates_api.py +46 -0
- templatefox-1.0.0/test/test_templates_list_response.py +65 -0
- templatefox-1.0.0/test/test_transaction.py +61 -0
- templatefox-1.0.0/test/test_transactions_response.py +75 -0
- templatefox-1.0.0/test/test_validation_error.py +61 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 TemplateFox
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: templatefox
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official TemplateFox Python SDK - Generate PDFs from HTML templates
|
|
5
|
+
Home-page: https://github.com/TemplateFoxPDF/pythonsdk
|
|
6
|
+
Author: TemplateFox
|
|
7
|
+
Author-email: TemplateFox <support@pdftemplateapi.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Repository, https://github.com/TemplateFoxPDF/pythonsdk
|
|
10
|
+
Keywords: OpenAPI,OpenAPI-Generator,TemplateFox API
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: urllib3<3.0.0,>=2.1.0
|
|
15
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
16
|
+
Requires-Dist: pydantic>=2
|
|
17
|
+
Requires-Dist: typing-extensions>=4.7.1
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# TemplateFox Python SDK
|
|
23
|
+
|
|
24
|
+
Official Python SDK for [TemplateFox](https://pdftemplateapi.com) - Generate PDFs from HTML templates via API.
|
|
25
|
+
|
|
26
|
+
[](https://pypi.org/project/templatefox/)
|
|
27
|
+
[](https://opensource.org/licenses/MIT)
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install templatefox
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or with poetry:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
poetry add templatefox
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from templatefox import ApiClient, Configuration
|
|
45
|
+
from templatefox.api import PDFApi
|
|
46
|
+
from templatefox.models import CreatePdfRequest
|
|
47
|
+
|
|
48
|
+
# Initialize the client
|
|
49
|
+
config = Configuration()
|
|
50
|
+
config.api_key['ApiKeyAuth'] = 'your-api-key'
|
|
51
|
+
|
|
52
|
+
with ApiClient(config) as client:
|
|
53
|
+
api = PDFApi(client)
|
|
54
|
+
|
|
55
|
+
# Generate a PDF
|
|
56
|
+
response = api.create_pdf(
|
|
57
|
+
CreatePdfRequest(
|
|
58
|
+
template_id='YOUR_TEMPLATE_ID',
|
|
59
|
+
data={
|
|
60
|
+
'name': 'John Doe',
|
|
61
|
+
'invoice_number': 'INV-001',
|
|
62
|
+
'total_amount': 150.00,
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
print(f'PDF URL: {response.url}')
|
|
68
|
+
print(f'Credits remaining: {response.credits_remaining}')
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Features
|
|
72
|
+
|
|
73
|
+
- **Template-based PDF generation** - Create templates with dynamic variables, generate PDFs with your data
|
|
74
|
+
- **Multiple export options** - Get a signed URL (default) or raw binary PDF
|
|
75
|
+
- **S3 integration** - Upload generated PDFs directly to your own S3-compatible storage
|
|
76
|
+
- **Type hints** - Full type annotations for IDE support
|
|
77
|
+
|
|
78
|
+
## API Methods
|
|
79
|
+
|
|
80
|
+
### PDF Generation
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from templatefox.models import CreatePdfRequest
|
|
84
|
+
|
|
85
|
+
# Generate PDF and get URL
|
|
86
|
+
response = api.create_pdf(
|
|
87
|
+
CreatePdfRequest(
|
|
88
|
+
template_id='TEMPLATE_ID',
|
|
89
|
+
data={'name': 'John Doe'},
|
|
90
|
+
export_type='url', # 'url' or 'binary'
|
|
91
|
+
expiration=86400, # URL expiration in seconds (default: 24h)
|
|
92
|
+
filename='invoice-001' # Custom filename
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Templates
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from templatefox.api import TemplatesApi
|
|
101
|
+
|
|
102
|
+
templates_api = TemplatesApi(client)
|
|
103
|
+
|
|
104
|
+
# List all templates
|
|
105
|
+
templates = templates_api.list_templates()
|
|
106
|
+
for template in templates.templates:
|
|
107
|
+
print(f'{template.id}: {template.name}')
|
|
108
|
+
|
|
109
|
+
# Get template fields
|
|
110
|
+
fields = templates_api.get_template_fields(template_id='TEMPLATE_ID')
|
|
111
|
+
for field in fields:
|
|
112
|
+
print(f'{field.key}: {field.type} (required: {field.required})')
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Account
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from templatefox.api import AccountApi
|
|
119
|
+
|
|
120
|
+
account_api = AccountApi(client)
|
|
121
|
+
|
|
122
|
+
# Get account info
|
|
123
|
+
account = account_api.get_account()
|
|
124
|
+
print(f'Credits: {account.credits}')
|
|
125
|
+
print(f'Email: {account.email}')
|
|
126
|
+
|
|
127
|
+
# List transactions
|
|
128
|
+
transactions = account_api.list_transactions(limit=100, offset=0)
|
|
129
|
+
for tx in transactions.transactions:
|
|
130
|
+
print(f'{tx.transaction_type}: {tx.credits} credits')
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### S3 Integration
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from templatefox.api import IntegrationsApi
|
|
137
|
+
from templatefox.models import S3ConfigRequest
|
|
138
|
+
|
|
139
|
+
integrations_api = IntegrationsApi(client)
|
|
140
|
+
|
|
141
|
+
# Save S3 configuration
|
|
142
|
+
integrations_api.save_s3_config(
|
|
143
|
+
S3ConfigRequest(
|
|
144
|
+
endpoint_url='https://s3.amazonaws.com',
|
|
145
|
+
access_key_id='AKIAIOSFODNN7EXAMPLE',
|
|
146
|
+
secret_access_key='your-secret-key',
|
|
147
|
+
bucket_name='my-pdf-bucket',
|
|
148
|
+
default_prefix='generated/pdfs/'
|
|
149
|
+
)
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# Test connection
|
|
153
|
+
test = integrations_api.test_s3_connection()
|
|
154
|
+
print(f'Connection: {"OK" if test.success else "Failed"}')
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Configuration
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
from templatefox import Configuration
|
|
161
|
+
|
|
162
|
+
config = Configuration(
|
|
163
|
+
host='https://api.pdftemplateapi.com', # Default API URL
|
|
164
|
+
)
|
|
165
|
+
config.api_key['ApiKeyAuth'] = 'your-api-key'
|
|
166
|
+
|
|
167
|
+
# Or use environment variable
|
|
168
|
+
import os
|
|
169
|
+
config.api_key['ApiKeyAuth'] = os.environ.get('TEMPLATEFOX_API_KEY')
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Error Handling
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from templatefox.exceptions import ApiException
|
|
176
|
+
|
|
177
|
+
try:
|
|
178
|
+
response = api.create_pdf(CreatePdfRequest(...))
|
|
179
|
+
except ApiException as e:
|
|
180
|
+
if e.status == 402:
|
|
181
|
+
print('Insufficient credits')
|
|
182
|
+
elif e.status == 403:
|
|
183
|
+
print('Access denied - check your API key')
|
|
184
|
+
elif e.status == 404:
|
|
185
|
+
print('Template not found')
|
|
186
|
+
else:
|
|
187
|
+
print(f'Error: {e.reason}')
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Async Support
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
import asyncio
|
|
194
|
+
from templatefox import ApiClient, Configuration
|
|
195
|
+
from templatefox.api import PDFApi
|
|
196
|
+
from templatefox.models import CreatePdfRequest
|
|
197
|
+
|
|
198
|
+
async def generate_pdfs():
|
|
199
|
+
config = Configuration()
|
|
200
|
+
config.api_key['ApiKeyAuth'] = 'your-api-key'
|
|
201
|
+
|
|
202
|
+
async with ApiClient(config) as client:
|
|
203
|
+
api = PDFApi(client)
|
|
204
|
+
# Use async methods
|
|
205
|
+
response = await api.create_pdf(
|
|
206
|
+
CreatePdfRequest(template_id='...', data={...})
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
asyncio.run(generate_pdfs())
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Documentation
|
|
213
|
+
|
|
214
|
+
- [API Documentation](https://pdftemplateapi.com/docs)
|
|
215
|
+
- [Swagger UI](https://api.pdftemplateapi.com/docs)
|
|
216
|
+
- [Dashboard](https://pdftemplateapi.com/dashboard)
|
|
217
|
+
|
|
218
|
+
## Support
|
|
219
|
+
|
|
220
|
+
- Email: support@pdftemplateapi.com
|
|
221
|
+
- Issues: [GitHub Issues](https://github.com/TemplateFoxPDF/pythonsdk/issues)
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# TemplateFox Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [TemplateFox](https://pdftemplateapi.com) - Generate PDFs from HTML templates via API.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/templatefox/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install templatefox
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or with poetry:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
poetry add templatefox
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from templatefox import ApiClient, Configuration
|
|
24
|
+
from templatefox.api import PDFApi
|
|
25
|
+
from templatefox.models import CreatePdfRequest
|
|
26
|
+
|
|
27
|
+
# Initialize the client
|
|
28
|
+
config = Configuration()
|
|
29
|
+
config.api_key['ApiKeyAuth'] = 'your-api-key'
|
|
30
|
+
|
|
31
|
+
with ApiClient(config) as client:
|
|
32
|
+
api = PDFApi(client)
|
|
33
|
+
|
|
34
|
+
# Generate a PDF
|
|
35
|
+
response = api.create_pdf(
|
|
36
|
+
CreatePdfRequest(
|
|
37
|
+
template_id='YOUR_TEMPLATE_ID',
|
|
38
|
+
data={
|
|
39
|
+
'name': 'John Doe',
|
|
40
|
+
'invoice_number': 'INV-001',
|
|
41
|
+
'total_amount': 150.00,
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
print(f'PDF URL: {response.url}')
|
|
47
|
+
print(f'Credits remaining: {response.credits_remaining}')
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- **Template-based PDF generation** - Create templates with dynamic variables, generate PDFs with your data
|
|
53
|
+
- **Multiple export options** - Get a signed URL (default) or raw binary PDF
|
|
54
|
+
- **S3 integration** - Upload generated PDFs directly to your own S3-compatible storage
|
|
55
|
+
- **Type hints** - Full type annotations for IDE support
|
|
56
|
+
|
|
57
|
+
## API Methods
|
|
58
|
+
|
|
59
|
+
### PDF Generation
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from templatefox.models import CreatePdfRequest
|
|
63
|
+
|
|
64
|
+
# Generate PDF and get URL
|
|
65
|
+
response = api.create_pdf(
|
|
66
|
+
CreatePdfRequest(
|
|
67
|
+
template_id='TEMPLATE_ID',
|
|
68
|
+
data={'name': 'John Doe'},
|
|
69
|
+
export_type='url', # 'url' or 'binary'
|
|
70
|
+
expiration=86400, # URL expiration in seconds (default: 24h)
|
|
71
|
+
filename='invoice-001' # Custom filename
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Templates
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from templatefox.api import TemplatesApi
|
|
80
|
+
|
|
81
|
+
templates_api = TemplatesApi(client)
|
|
82
|
+
|
|
83
|
+
# List all templates
|
|
84
|
+
templates = templates_api.list_templates()
|
|
85
|
+
for template in templates.templates:
|
|
86
|
+
print(f'{template.id}: {template.name}')
|
|
87
|
+
|
|
88
|
+
# Get template fields
|
|
89
|
+
fields = templates_api.get_template_fields(template_id='TEMPLATE_ID')
|
|
90
|
+
for field in fields:
|
|
91
|
+
print(f'{field.key}: {field.type} (required: {field.required})')
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Account
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from templatefox.api import AccountApi
|
|
98
|
+
|
|
99
|
+
account_api = AccountApi(client)
|
|
100
|
+
|
|
101
|
+
# Get account info
|
|
102
|
+
account = account_api.get_account()
|
|
103
|
+
print(f'Credits: {account.credits}')
|
|
104
|
+
print(f'Email: {account.email}')
|
|
105
|
+
|
|
106
|
+
# List transactions
|
|
107
|
+
transactions = account_api.list_transactions(limit=100, offset=0)
|
|
108
|
+
for tx in transactions.transactions:
|
|
109
|
+
print(f'{tx.transaction_type}: {tx.credits} credits')
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### S3 Integration
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from templatefox.api import IntegrationsApi
|
|
116
|
+
from templatefox.models import S3ConfigRequest
|
|
117
|
+
|
|
118
|
+
integrations_api = IntegrationsApi(client)
|
|
119
|
+
|
|
120
|
+
# Save S3 configuration
|
|
121
|
+
integrations_api.save_s3_config(
|
|
122
|
+
S3ConfigRequest(
|
|
123
|
+
endpoint_url='https://s3.amazonaws.com',
|
|
124
|
+
access_key_id='AKIAIOSFODNN7EXAMPLE',
|
|
125
|
+
secret_access_key='your-secret-key',
|
|
126
|
+
bucket_name='my-pdf-bucket',
|
|
127
|
+
default_prefix='generated/pdfs/'
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
# Test connection
|
|
132
|
+
test = integrations_api.test_s3_connection()
|
|
133
|
+
print(f'Connection: {"OK" if test.success else "Failed"}')
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Configuration
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from templatefox import Configuration
|
|
140
|
+
|
|
141
|
+
config = Configuration(
|
|
142
|
+
host='https://api.pdftemplateapi.com', # Default API URL
|
|
143
|
+
)
|
|
144
|
+
config.api_key['ApiKeyAuth'] = 'your-api-key'
|
|
145
|
+
|
|
146
|
+
# Or use environment variable
|
|
147
|
+
import os
|
|
148
|
+
config.api_key['ApiKeyAuth'] = os.environ.get('TEMPLATEFOX_API_KEY')
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Error Handling
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from templatefox.exceptions import ApiException
|
|
155
|
+
|
|
156
|
+
try:
|
|
157
|
+
response = api.create_pdf(CreatePdfRequest(...))
|
|
158
|
+
except ApiException as e:
|
|
159
|
+
if e.status == 402:
|
|
160
|
+
print('Insufficient credits')
|
|
161
|
+
elif e.status == 403:
|
|
162
|
+
print('Access denied - check your API key')
|
|
163
|
+
elif e.status == 404:
|
|
164
|
+
print('Template not found')
|
|
165
|
+
else:
|
|
166
|
+
print(f'Error: {e.reason}')
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Async Support
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
import asyncio
|
|
173
|
+
from templatefox import ApiClient, Configuration
|
|
174
|
+
from templatefox.api import PDFApi
|
|
175
|
+
from templatefox.models import CreatePdfRequest
|
|
176
|
+
|
|
177
|
+
async def generate_pdfs():
|
|
178
|
+
config = Configuration()
|
|
179
|
+
config.api_key['ApiKeyAuth'] = 'your-api-key'
|
|
180
|
+
|
|
181
|
+
async with ApiClient(config) as client:
|
|
182
|
+
api = PDFApi(client)
|
|
183
|
+
# Use async methods
|
|
184
|
+
response = await api.create_pdf(
|
|
185
|
+
CreatePdfRequest(template_id='...', data={...})
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
asyncio.run(generate_pdfs())
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Documentation
|
|
192
|
+
|
|
193
|
+
- [API Documentation](https://pdftemplateapi.com/docs)
|
|
194
|
+
- [Swagger UI](https://api.pdftemplateapi.com/docs)
|
|
195
|
+
- [Dashboard](https://pdftemplateapi.com/dashboard)
|
|
196
|
+
|
|
197
|
+
## Support
|
|
198
|
+
|
|
199
|
+
- Email: support@pdftemplateapi.com
|
|
200
|
+
- Issues: [GitHub Issues](https://github.com/TemplateFoxPDF/pythonsdk/issues)
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "templatefox"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Official TemplateFox Python SDK - Generate PDFs from HTML templates"
|
|
5
|
+
license = {text = "MIT"}
|
|
6
|
+
authors = [
|
|
7
|
+
{name = "TemplateFox",email = "support@pdftemplateapi.com"},
|
|
8
|
+
]
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["OpenAPI", "OpenAPI-Generator", "TemplateFox API"]
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
|
|
13
|
+
dependencies = [
|
|
14
|
+
"urllib3 (>=2.1.0,<3.0.0)",
|
|
15
|
+
"python-dateutil (>=2.8.2)",
|
|
16
|
+
"pydantic (>=2)",
|
|
17
|
+
"typing-extensions (>=4.7.1)",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Repository = "https://github.com/TemplateFoxPDF/pythonsdk"
|
|
22
|
+
|
|
23
|
+
[tool.poetry]
|
|
24
|
+
requires-poetry = ">=2.0"
|
|
25
|
+
|
|
26
|
+
[tool.poetry.group.dev.dependencies]
|
|
27
|
+
pytest = ">= 7.2.1"
|
|
28
|
+
pytest-cov = ">= 2.8.1"
|
|
29
|
+
tox = ">= 3.9.0"
|
|
30
|
+
flake8 = ">= 4.0.0"
|
|
31
|
+
types-python-dateutil = ">= 2.8.19.14"
|
|
32
|
+
mypy = ">= 1.5"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["setuptools"]
|
|
37
|
+
build-backend = "setuptools.build_meta"
|
|
38
|
+
|
|
39
|
+
[tool.pylint.'MESSAGES CONTROL']
|
|
40
|
+
extension-pkg-whitelist = "pydantic"
|
|
41
|
+
|
|
42
|
+
[tool.mypy]
|
|
43
|
+
files = [
|
|
44
|
+
"templatefox",
|
|
45
|
+
#"test", # auto-generated tests
|
|
46
|
+
"tests", # hand-written tests
|
|
47
|
+
]
|
|
48
|
+
# TODO: enable "strict" once all these individual checks are passing
|
|
49
|
+
# strict = true
|
|
50
|
+
|
|
51
|
+
# List from: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options
|
|
52
|
+
warn_unused_configs = true
|
|
53
|
+
warn_redundant_casts = true
|
|
54
|
+
warn_unused_ignores = true
|
|
55
|
+
|
|
56
|
+
## Getting these passing should be easy
|
|
57
|
+
strict_equality = true
|
|
58
|
+
extra_checks = true
|
|
59
|
+
|
|
60
|
+
## Strongly recommend enabling this one as soon as you can
|
|
61
|
+
check_untyped_defs = true
|
|
62
|
+
|
|
63
|
+
## These shouldn't be too much additional work, but may be tricky to
|
|
64
|
+
## get passing if you use a lot of untyped libraries
|
|
65
|
+
disallow_subclassing_any = true
|
|
66
|
+
disallow_untyped_decorators = true
|
|
67
|
+
disallow_any_generics = true
|
|
68
|
+
|
|
69
|
+
### These next few are various gradations of forcing use of type annotations
|
|
70
|
+
#disallow_untyped_calls = true
|
|
71
|
+
#disallow_incomplete_defs = true
|
|
72
|
+
#disallow_untyped_defs = true
|
|
73
|
+
#
|
|
74
|
+
### This one isn't too hard to get passing, but return on investment is lower
|
|
75
|
+
#no_implicit_reexport = true
|
|
76
|
+
#
|
|
77
|
+
### This one can be tricky to get passing if you use a lot of untyped libraries
|
|
78
|
+
#warn_return_any = true
|
|
79
|
+
|
|
80
|
+
[[tool.mypy.overrides]]
|
|
81
|
+
module = [
|
|
82
|
+
"templatefox.configuration",
|
|
83
|
+
]
|
|
84
|
+
warn_unused_ignores = true
|
|
85
|
+
strict_equality = true
|
|
86
|
+
extra_checks = true
|
|
87
|
+
check_untyped_defs = true
|
|
88
|
+
disallow_subclassing_any = true
|
|
89
|
+
disallow_untyped_decorators = true
|
|
90
|
+
disallow_any_generics = true
|
|
91
|
+
disallow_untyped_calls = true
|
|
92
|
+
disallow_incomplete_defs = true
|
|
93
|
+
disallow_untyped_defs = true
|
|
94
|
+
no_implicit_reexport = true
|
|
95
|
+
warn_return_any = true
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
TemplateFox API
|
|
5
|
+
|
|
6
|
+
Generate PDFs from HTML templates via API. Design once, generate thousands.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0
|
|
9
|
+
Contact: support@pdftemplateapi.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from setuptools import setup, find_packages # noqa: H301
|
|
17
|
+
|
|
18
|
+
# To install the library, run the following
|
|
19
|
+
#
|
|
20
|
+
# python setup.py install
|
|
21
|
+
#
|
|
22
|
+
# prerequisite: setuptools
|
|
23
|
+
# http://pypi.python.org/pypi/setuptools
|
|
24
|
+
NAME = "templatefox"
|
|
25
|
+
VERSION = "1.0.0"
|
|
26
|
+
PYTHON_REQUIRES = ">= 3.9"
|
|
27
|
+
REQUIRES = [
|
|
28
|
+
"urllib3 >= 2.1.0, < 3.0.0",
|
|
29
|
+
"python-dateutil >= 2.8.2",
|
|
30
|
+
"pydantic >= 2",
|
|
31
|
+
"typing-extensions >= 4.7.1",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
setup(
|
|
35
|
+
name=NAME,
|
|
36
|
+
version=VERSION,
|
|
37
|
+
description="TemplateFox API",
|
|
38
|
+
author="TemplateFox",
|
|
39
|
+
author_email="support@pdftemplateapi.com",
|
|
40
|
+
url="https://github.com/TemplateFoxPDF/pythonsdk",
|
|
41
|
+
keywords=["OpenAPI", "OpenAPI-Generator", "TemplateFox API"],
|
|
42
|
+
install_requires=REQUIRES,
|
|
43
|
+
packages=find_packages(exclude=["test", "tests"]),
|
|
44
|
+
include_package_data=True,
|
|
45
|
+
long_description_content_type='text/markdown',
|
|
46
|
+
long_description="""\
|
|
47
|
+
Generate PDFs from HTML templates via API. Design once, generate thousands.
|
|
48
|
+
""", # noqa: E501
|
|
49
|
+
package_data={"templatefox": ["py.typed"]},
|
|
50
|
+
)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
TemplateFox API
|
|
7
|
+
|
|
8
|
+
Generate PDFs from HTML templates via API. Design once, generate thousands.
|
|
9
|
+
|
|
10
|
+
The version of the OpenAPI document: 1.0.0
|
|
11
|
+
Contact: support@pdftemplateapi.com
|
|
12
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
13
|
+
|
|
14
|
+
Do not edit the class manually.
|
|
15
|
+
""" # noqa: E501
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__version__ = "1.0.0"
|
|
19
|
+
|
|
20
|
+
# Define package exports
|
|
21
|
+
__all__ = [
|
|
22
|
+
"AccountApi",
|
|
23
|
+
"IntegrationsApi",
|
|
24
|
+
"PDFApi",
|
|
25
|
+
"TemplatesApi",
|
|
26
|
+
"ApiResponse",
|
|
27
|
+
"ApiClient",
|
|
28
|
+
"Configuration",
|
|
29
|
+
"OpenApiException",
|
|
30
|
+
"ApiTypeError",
|
|
31
|
+
"ApiValueError",
|
|
32
|
+
"ApiKeyError",
|
|
33
|
+
"ApiAttributeError",
|
|
34
|
+
"ApiException",
|
|
35
|
+
"AccountInfoResponse",
|
|
36
|
+
"CreatePdfRequest",
|
|
37
|
+
"CreatePdfResponse",
|
|
38
|
+
"ExportType",
|
|
39
|
+
"HTTPValidationError",
|
|
40
|
+
"LocationInner",
|
|
41
|
+
"S3ConfigRequest",
|
|
42
|
+
"S3ConfigResponse",
|
|
43
|
+
"S3SuccessResponse",
|
|
44
|
+
"S3TestResponse",
|
|
45
|
+
"TemplateField",
|
|
46
|
+
"TemplateListItem",
|
|
47
|
+
"TemplatesListResponse",
|
|
48
|
+
"Transaction",
|
|
49
|
+
"TransactionsResponse",
|
|
50
|
+
"ValidationError",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
# import apis into sdk package
|
|
54
|
+
from templatefox.api.account_api import AccountApi as AccountApi
|
|
55
|
+
from templatefox.api.integrations_api import IntegrationsApi as IntegrationsApi
|
|
56
|
+
from templatefox.api.pdf_api import PDFApi as PDFApi
|
|
57
|
+
from templatefox.api.templates_api import TemplatesApi as TemplatesApi
|
|
58
|
+
|
|
59
|
+
# import ApiClient
|
|
60
|
+
from templatefox.api_response import ApiResponse as ApiResponse
|
|
61
|
+
from templatefox.api_client import ApiClient as ApiClient
|
|
62
|
+
from templatefox.configuration import Configuration as Configuration
|
|
63
|
+
from templatefox.exceptions import OpenApiException as OpenApiException
|
|
64
|
+
from templatefox.exceptions import ApiTypeError as ApiTypeError
|
|
65
|
+
from templatefox.exceptions import ApiValueError as ApiValueError
|
|
66
|
+
from templatefox.exceptions import ApiKeyError as ApiKeyError
|
|
67
|
+
from templatefox.exceptions import ApiAttributeError as ApiAttributeError
|
|
68
|
+
from templatefox.exceptions import ApiException as ApiException
|
|
69
|
+
|
|
70
|
+
# import models into sdk package
|
|
71
|
+
from templatefox.models.account_info_response import AccountInfoResponse as AccountInfoResponse
|
|
72
|
+
from templatefox.models.create_pdf_request import CreatePdfRequest as CreatePdfRequest
|
|
73
|
+
from templatefox.models.create_pdf_response import CreatePdfResponse as CreatePdfResponse
|
|
74
|
+
from templatefox.models.export_type import ExportType as ExportType
|
|
75
|
+
from templatefox.models.http_validation_error import HTTPValidationError as HTTPValidationError
|
|
76
|
+
from templatefox.models.location_inner import LocationInner as LocationInner
|
|
77
|
+
from templatefox.models.s3_config_request import S3ConfigRequest as S3ConfigRequest
|
|
78
|
+
from templatefox.models.s3_config_response import S3ConfigResponse as S3ConfigResponse
|
|
79
|
+
from templatefox.models.s3_success_response import S3SuccessResponse as S3SuccessResponse
|
|
80
|
+
from templatefox.models.s3_test_response import S3TestResponse as S3TestResponse
|
|
81
|
+
from templatefox.models.template_field import TemplateField as TemplateField
|
|
82
|
+
from templatefox.models.template_list_item import TemplateListItem as TemplateListItem
|
|
83
|
+
from templatefox.models.templates_list_response import TemplatesListResponse as TemplatesListResponse
|
|
84
|
+
from templatefox.models.transaction import Transaction as Transaction
|
|
85
|
+
from templatefox.models.transactions_response import TransactionsResponse as TransactionsResponse
|
|
86
|
+
from templatefox.models.validation_error import ValidationError as ValidationError
|
|
87
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# flake8: noqa
|
|
2
|
+
|
|
3
|
+
# import apis into api package
|
|
4
|
+
from templatefox.api.account_api import AccountApi
|
|
5
|
+
from templatefox.api.integrations_api import IntegrationsApi
|
|
6
|
+
from templatefox.api.pdf_api import PDFApi
|
|
7
|
+
from templatefox.api.templates_api import TemplatesApi
|
|
8
|
+
|