templatefox 1.0.0__py3-none-any.whl
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/__init__.py +87 -0
- templatefox/api/__init__.py +8 -0
- templatefox/api/account_api.py +579 -0
- templatefox/api/integrations_api.py +1085 -0
- templatefox/api/pdf_api.py +325 -0
- templatefox/api/templates_api.py +562 -0
- templatefox/api_client.py +805 -0
- templatefox/api_response.py +21 -0
- templatefox/configuration.py +609 -0
- templatefox/exceptions.py +220 -0
- templatefox/models/__init__.py +33 -0
- templatefox/models/account_info_response.py +95 -0
- templatefox/models/create_pdf_request.py +149 -0
- templatefox/models/create_pdf_response.py +94 -0
- templatefox/models/export_type.py +38 -0
- templatefox/models/http_validation_error.py +96 -0
- templatefox/models/location_inner.py +139 -0
- templatefox/models/s3_config_request.py +126 -0
- templatefox/models/s3_config_response.py +98 -0
- templatefox/models/s3_success_response.py +88 -0
- templatefox/models/s3_test_response.py +90 -0
- templatefox/models/template_field.py +101 -0
- templatefox/models/template_list_item.py +94 -0
- templatefox/models/templates_list_response.py +96 -0
- templatefox/models/transaction.py +108 -0
- templatefox/models/transactions_response.py +102 -0
- templatefox/models/validation_error.py +100 -0
- templatefox/py.typed +0 -0
- templatefox/rest.py +264 -0
- templatefox-1.0.0.dist-info/METADATA +225 -0
- templatefox-1.0.0.dist-info/RECORD +34 -0
- templatefox-1.0.0.dist-info/WHEEL +5 -0
- templatefox-1.0.0.dist-info/licenses/LICENSE +21 -0
- templatefox-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
from typing import Any, Optional
|
|
16
|
+
from typing_extensions import Self
|
|
17
|
+
|
|
18
|
+
class OpenApiException(Exception):
|
|
19
|
+
"""The base exception class for all OpenAPIExceptions"""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ApiTypeError(OpenApiException, TypeError):
|
|
23
|
+
def __init__(self, msg, path_to_item=None, valid_classes=None,
|
|
24
|
+
key_type=None) -> None:
|
|
25
|
+
""" Raises an exception for TypeErrors
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
msg (str): the exception message
|
|
29
|
+
|
|
30
|
+
Keyword Args:
|
|
31
|
+
path_to_item (list): a list of keys an indices to get to the
|
|
32
|
+
current_item
|
|
33
|
+
None if unset
|
|
34
|
+
valid_classes (tuple): the primitive classes that current item
|
|
35
|
+
should be an instance of
|
|
36
|
+
None if unset
|
|
37
|
+
key_type (bool): False if our value is a value in a dict
|
|
38
|
+
True if it is a key in a dict
|
|
39
|
+
False if our item is an item in a list
|
|
40
|
+
None if unset
|
|
41
|
+
"""
|
|
42
|
+
self.path_to_item = path_to_item
|
|
43
|
+
self.valid_classes = valid_classes
|
|
44
|
+
self.key_type = key_type
|
|
45
|
+
full_msg = msg
|
|
46
|
+
if path_to_item:
|
|
47
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
48
|
+
super(ApiTypeError, self).__init__(full_msg)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ApiValueError(OpenApiException, ValueError):
|
|
52
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
53
|
+
"""
|
|
54
|
+
Args:
|
|
55
|
+
msg (str): the exception message
|
|
56
|
+
|
|
57
|
+
Keyword Args:
|
|
58
|
+
path_to_item (list) the path to the exception in the
|
|
59
|
+
received_data dict. None if unset
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
self.path_to_item = path_to_item
|
|
63
|
+
full_msg = msg
|
|
64
|
+
if path_to_item:
|
|
65
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
66
|
+
super(ApiValueError, self).__init__(full_msg)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ApiAttributeError(OpenApiException, AttributeError):
|
|
70
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
71
|
+
"""
|
|
72
|
+
Raised when an attribute reference or assignment fails.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
msg (str): the exception message
|
|
76
|
+
|
|
77
|
+
Keyword Args:
|
|
78
|
+
path_to_item (None/list) the path to the exception in the
|
|
79
|
+
received_data dict
|
|
80
|
+
"""
|
|
81
|
+
self.path_to_item = path_to_item
|
|
82
|
+
full_msg = msg
|
|
83
|
+
if path_to_item:
|
|
84
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
85
|
+
super(ApiAttributeError, self).__init__(full_msg)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class ApiKeyError(OpenApiException, KeyError):
|
|
89
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
90
|
+
"""
|
|
91
|
+
Args:
|
|
92
|
+
msg (str): the exception message
|
|
93
|
+
|
|
94
|
+
Keyword Args:
|
|
95
|
+
path_to_item (None/list) the path to the exception in the
|
|
96
|
+
received_data dict
|
|
97
|
+
"""
|
|
98
|
+
self.path_to_item = path_to_item
|
|
99
|
+
full_msg = msg
|
|
100
|
+
if path_to_item:
|
|
101
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
102
|
+
super(ApiKeyError, self).__init__(full_msg)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class ApiException(OpenApiException):
|
|
106
|
+
|
|
107
|
+
def __init__(
|
|
108
|
+
self,
|
|
109
|
+
status=None,
|
|
110
|
+
reason=None,
|
|
111
|
+
http_resp=None,
|
|
112
|
+
*,
|
|
113
|
+
body: Optional[str] = None,
|
|
114
|
+
data: Optional[Any] = None,
|
|
115
|
+
) -> None:
|
|
116
|
+
self.status = status
|
|
117
|
+
self.reason = reason
|
|
118
|
+
self.body = body
|
|
119
|
+
self.data = data
|
|
120
|
+
self.headers = None
|
|
121
|
+
|
|
122
|
+
if http_resp:
|
|
123
|
+
if self.status is None:
|
|
124
|
+
self.status = http_resp.status
|
|
125
|
+
if self.reason is None:
|
|
126
|
+
self.reason = http_resp.reason
|
|
127
|
+
if self.body is None:
|
|
128
|
+
try:
|
|
129
|
+
self.body = http_resp.data.decode('utf-8')
|
|
130
|
+
except Exception:
|
|
131
|
+
pass
|
|
132
|
+
self.headers = http_resp.headers
|
|
133
|
+
|
|
134
|
+
@classmethod
|
|
135
|
+
def from_response(
|
|
136
|
+
cls,
|
|
137
|
+
*,
|
|
138
|
+
http_resp,
|
|
139
|
+
body: Optional[str],
|
|
140
|
+
data: Optional[Any],
|
|
141
|
+
) -> Self:
|
|
142
|
+
if http_resp.status == 400:
|
|
143
|
+
raise BadRequestException(http_resp=http_resp, body=body, data=data)
|
|
144
|
+
|
|
145
|
+
if http_resp.status == 401:
|
|
146
|
+
raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
|
|
147
|
+
|
|
148
|
+
if http_resp.status == 403:
|
|
149
|
+
raise ForbiddenException(http_resp=http_resp, body=body, data=data)
|
|
150
|
+
|
|
151
|
+
if http_resp.status == 404:
|
|
152
|
+
raise NotFoundException(http_resp=http_resp, body=body, data=data)
|
|
153
|
+
|
|
154
|
+
# Added new conditions for 409 and 422
|
|
155
|
+
if http_resp.status == 409:
|
|
156
|
+
raise ConflictException(http_resp=http_resp, body=body, data=data)
|
|
157
|
+
|
|
158
|
+
if http_resp.status == 422:
|
|
159
|
+
raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
|
|
160
|
+
|
|
161
|
+
if 500 <= http_resp.status <= 599:
|
|
162
|
+
raise ServiceException(http_resp=http_resp, body=body, data=data)
|
|
163
|
+
raise ApiException(http_resp=http_resp, body=body, data=data)
|
|
164
|
+
|
|
165
|
+
def __str__(self):
|
|
166
|
+
"""Custom error messages for exception"""
|
|
167
|
+
error_message = "({0})\n"\
|
|
168
|
+
"Reason: {1}\n".format(self.status, self.reason)
|
|
169
|
+
if self.headers:
|
|
170
|
+
error_message += "HTTP response headers: {0}\n".format(
|
|
171
|
+
self.headers)
|
|
172
|
+
|
|
173
|
+
if self.body:
|
|
174
|
+
error_message += "HTTP response body: {0}\n".format(self.body)
|
|
175
|
+
|
|
176
|
+
if self.data:
|
|
177
|
+
error_message += "HTTP response data: {0}\n".format(self.data)
|
|
178
|
+
|
|
179
|
+
return error_message
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class BadRequestException(ApiException):
|
|
183
|
+
pass
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class NotFoundException(ApiException):
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class UnauthorizedException(ApiException):
|
|
191
|
+
pass
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class ForbiddenException(ApiException):
|
|
195
|
+
pass
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class ServiceException(ApiException):
|
|
199
|
+
pass
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class ConflictException(ApiException):
|
|
203
|
+
"""Exception for HTTP 409 Conflict."""
|
|
204
|
+
pass
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class UnprocessableEntityException(ApiException):
|
|
208
|
+
"""Exception for HTTP 422 Unprocessable Entity."""
|
|
209
|
+
pass
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def render_path(path_to_item):
|
|
213
|
+
"""Returns a string representation of a path"""
|
|
214
|
+
result = ""
|
|
215
|
+
for pth in path_to_item:
|
|
216
|
+
if isinstance(pth, int):
|
|
217
|
+
result += "[{0}]".format(pth)
|
|
218
|
+
else:
|
|
219
|
+
result += "['{0}']".format(pth)
|
|
220
|
+
return result
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
"""
|
|
5
|
+
TemplateFox API
|
|
6
|
+
|
|
7
|
+
Generate PDFs from HTML templates via API. Design once, generate thousands.
|
|
8
|
+
|
|
9
|
+
The version of the OpenAPI document: 1.0.0
|
|
10
|
+
Contact: support@pdftemplateapi.com
|
|
11
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
12
|
+
|
|
13
|
+
Do not edit the class manually.
|
|
14
|
+
""" # noqa: E501
|
|
15
|
+
|
|
16
|
+
# import models into model package
|
|
17
|
+
from templatefox.models.account_info_response import AccountInfoResponse
|
|
18
|
+
from templatefox.models.create_pdf_request import CreatePdfRequest
|
|
19
|
+
from templatefox.models.create_pdf_response import CreatePdfResponse
|
|
20
|
+
from templatefox.models.export_type import ExportType
|
|
21
|
+
from templatefox.models.http_validation_error import HTTPValidationError
|
|
22
|
+
from templatefox.models.location_inner import LocationInner
|
|
23
|
+
from templatefox.models.s3_config_request import S3ConfigRequest
|
|
24
|
+
from templatefox.models.s3_config_response import S3ConfigResponse
|
|
25
|
+
from templatefox.models.s3_success_response import S3SuccessResponse
|
|
26
|
+
from templatefox.models.s3_test_response import S3TestResponse
|
|
27
|
+
from templatefox.models.template_field import TemplateField
|
|
28
|
+
from templatefox.models.template_list_item import TemplateListItem
|
|
29
|
+
from templatefox.models.templates_list_response import TemplatesListResponse
|
|
30
|
+
from templatefox.models.transaction import Transaction
|
|
31
|
+
from templatefox.models.transactions_response import TransactionsResponse
|
|
32
|
+
from templatefox.models.validation_error import ValidationError
|
|
33
|
+
|
|
@@ -0,0 +1,95 @@
|
|
|
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 __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
|
|
26
|
+
class AccountInfoResponse(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
Response for account info endpoint
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
credits: StrictInt = Field(description="Remaining credits")
|
|
31
|
+
email: Optional[StrictStr] = None
|
|
32
|
+
__properties: ClassVar[List[str]] = ["credits", "email"]
|
|
33
|
+
|
|
34
|
+
model_config = ConfigDict(
|
|
35
|
+
populate_by_name=True,
|
|
36
|
+
validate_assignment=True,
|
|
37
|
+
protected_namespaces=(),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def to_str(self) -> str:
|
|
42
|
+
"""Returns the string representation of the model using alias"""
|
|
43
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
44
|
+
|
|
45
|
+
def to_json(self) -> str:
|
|
46
|
+
"""Returns the JSON representation of the model using alias"""
|
|
47
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
48
|
+
return json.dumps(self.to_dict())
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
52
|
+
"""Create an instance of AccountInfoResponse from a JSON string"""
|
|
53
|
+
return cls.from_dict(json.loads(json_str))
|
|
54
|
+
|
|
55
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
56
|
+
"""Return the dictionary representation of the model using alias.
|
|
57
|
+
|
|
58
|
+
This has the following differences from calling pydantic's
|
|
59
|
+
`self.model_dump(by_alias=True)`:
|
|
60
|
+
|
|
61
|
+
* `None` is only added to the output dict for nullable fields that
|
|
62
|
+
were set at model initialization. Other fields with value `None`
|
|
63
|
+
are ignored.
|
|
64
|
+
"""
|
|
65
|
+
excluded_fields: Set[str] = set([
|
|
66
|
+
])
|
|
67
|
+
|
|
68
|
+
_dict = self.model_dump(
|
|
69
|
+
by_alias=True,
|
|
70
|
+
exclude=excluded_fields,
|
|
71
|
+
exclude_none=True,
|
|
72
|
+
)
|
|
73
|
+
# set to None if email (nullable) is None
|
|
74
|
+
# and model_fields_set contains the field
|
|
75
|
+
if self.email is None and "email" in self.model_fields_set:
|
|
76
|
+
_dict['email'] = None
|
|
77
|
+
|
|
78
|
+
return _dict
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
82
|
+
"""Create an instance of AccountInfoResponse from a dict"""
|
|
83
|
+
if obj is None:
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
if not isinstance(obj, dict):
|
|
87
|
+
return cls.model_validate(obj)
|
|
88
|
+
|
|
89
|
+
_obj = cls.model_validate({
|
|
90
|
+
"credits": obj.get("credits"),
|
|
91
|
+
"email": obj.get("email")
|
|
92
|
+
})
|
|
93
|
+
return _obj
|
|
94
|
+
|
|
95
|
+
|
|
@@ -0,0 +1,149 @@
|
|
|
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 __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
23
|
+
from typing_extensions import Annotated
|
|
24
|
+
from templatefox.models.export_type import ExportType
|
|
25
|
+
from typing import Optional, Set
|
|
26
|
+
from typing_extensions import Self
|
|
27
|
+
|
|
28
|
+
class CreatePdfRequest(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
Request model for PDF generation
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
template_id: Annotated[str, Field(min_length=12, strict=True, max_length=12)] = Field(description="**Required.** Template short ID (12 characters)")
|
|
33
|
+
data: Dict[str, Any] = Field(description="**Required.** Key-value data to render in the template. Keys must match template variables.")
|
|
34
|
+
export_type: Optional[ExportType] = Field(default=None, description="Export format: `url` uploads to CDN and returns URL, `binary` returns raw PDF bytes")
|
|
35
|
+
expiration: Optional[Annotated[int, Field(le=604800, strict=True, ge=60)]] = Field(default=86400, description="URL expiration in seconds. Min: 60 (1 min), Max: 604800 (7 days). Only applies to `url` export type.")
|
|
36
|
+
filename: Optional[Annotated[str, Field(strict=True, max_length=100)]] = None
|
|
37
|
+
store_s3: Optional[StrictBool] = Field(default=False, description="Upload to your configured S3 bucket instead of CDN")
|
|
38
|
+
s3_filepath: Optional[Annotated[str, Field(strict=True, max_length=500)]] = None
|
|
39
|
+
s3_bucket: Optional[Annotated[str, Field(min_length=3, strict=True, max_length=63)]] = None
|
|
40
|
+
__properties: ClassVar[List[str]] = ["template_id", "data", "export_type", "expiration", "filename", "store_s3", "s3_filepath", "s3_bucket"]
|
|
41
|
+
|
|
42
|
+
@field_validator('filename')
|
|
43
|
+
def filename_validate_regular_expression(cls, value):
|
|
44
|
+
"""Validates the regular expression"""
|
|
45
|
+
if value is None:
|
|
46
|
+
return value
|
|
47
|
+
|
|
48
|
+
if not re.match(r"^[a-zA-Z0-9_\-\.]+$", value):
|
|
49
|
+
raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9_\-\.]+$/")
|
|
50
|
+
return value
|
|
51
|
+
|
|
52
|
+
@field_validator('s3_filepath')
|
|
53
|
+
def s3_filepath_validate_regular_expression(cls, value):
|
|
54
|
+
"""Validates the regular expression"""
|
|
55
|
+
if value is None:
|
|
56
|
+
return value
|
|
57
|
+
|
|
58
|
+
if not re.match(r"^[a-zA-Z0-9_\-\.\/]+$", value):
|
|
59
|
+
raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9_\-\.\/]+$/")
|
|
60
|
+
return value
|
|
61
|
+
|
|
62
|
+
@field_validator('s3_bucket')
|
|
63
|
+
def s3_bucket_validate_regular_expression(cls, value):
|
|
64
|
+
"""Validates the regular expression"""
|
|
65
|
+
if value is None:
|
|
66
|
+
return value
|
|
67
|
+
|
|
68
|
+
if not re.match(r"^[a-z0-9][a-z0-9.\-]*[a-z0-9]$", value):
|
|
69
|
+
raise ValueError(r"must validate the regular expression /^[a-z0-9][a-z0-9.\-]*[a-z0-9]$/")
|
|
70
|
+
return value
|
|
71
|
+
|
|
72
|
+
model_config = ConfigDict(
|
|
73
|
+
populate_by_name=True,
|
|
74
|
+
validate_assignment=True,
|
|
75
|
+
protected_namespaces=(),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def to_str(self) -> str:
|
|
80
|
+
"""Returns the string representation of the model using alias"""
|
|
81
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
82
|
+
|
|
83
|
+
def to_json(self) -> str:
|
|
84
|
+
"""Returns the JSON representation of the model using alias"""
|
|
85
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
86
|
+
return json.dumps(self.to_dict())
|
|
87
|
+
|
|
88
|
+
@classmethod
|
|
89
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
90
|
+
"""Create an instance of CreatePdfRequest from a JSON string"""
|
|
91
|
+
return cls.from_dict(json.loads(json_str))
|
|
92
|
+
|
|
93
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
94
|
+
"""Return the dictionary representation of the model using alias.
|
|
95
|
+
|
|
96
|
+
This has the following differences from calling pydantic's
|
|
97
|
+
`self.model_dump(by_alias=True)`:
|
|
98
|
+
|
|
99
|
+
* `None` is only added to the output dict for nullable fields that
|
|
100
|
+
were set at model initialization. Other fields with value `None`
|
|
101
|
+
are ignored.
|
|
102
|
+
"""
|
|
103
|
+
excluded_fields: Set[str] = set([
|
|
104
|
+
])
|
|
105
|
+
|
|
106
|
+
_dict = self.model_dump(
|
|
107
|
+
by_alias=True,
|
|
108
|
+
exclude=excluded_fields,
|
|
109
|
+
exclude_none=True,
|
|
110
|
+
)
|
|
111
|
+
# set to None if filename (nullable) is None
|
|
112
|
+
# and model_fields_set contains the field
|
|
113
|
+
if self.filename is None and "filename" in self.model_fields_set:
|
|
114
|
+
_dict['filename'] = None
|
|
115
|
+
|
|
116
|
+
# set to None if s3_filepath (nullable) is None
|
|
117
|
+
# and model_fields_set contains the field
|
|
118
|
+
if self.s3_filepath is None and "s3_filepath" in self.model_fields_set:
|
|
119
|
+
_dict['s3_filepath'] = None
|
|
120
|
+
|
|
121
|
+
# set to None if s3_bucket (nullable) is None
|
|
122
|
+
# and model_fields_set contains the field
|
|
123
|
+
if self.s3_bucket is None and "s3_bucket" in self.model_fields_set:
|
|
124
|
+
_dict['s3_bucket'] = None
|
|
125
|
+
|
|
126
|
+
return _dict
|
|
127
|
+
|
|
128
|
+
@classmethod
|
|
129
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
130
|
+
"""Create an instance of CreatePdfRequest from a dict"""
|
|
131
|
+
if obj is None:
|
|
132
|
+
return None
|
|
133
|
+
|
|
134
|
+
if not isinstance(obj, dict):
|
|
135
|
+
return cls.model_validate(obj)
|
|
136
|
+
|
|
137
|
+
_obj = cls.model_validate({
|
|
138
|
+
"template_id": obj.get("template_id"),
|
|
139
|
+
"data": obj.get("data"),
|
|
140
|
+
"export_type": obj.get("export_type"),
|
|
141
|
+
"expiration": obj.get("expiration") if obj.get("expiration") is not None else 86400,
|
|
142
|
+
"filename": obj.get("filename"),
|
|
143
|
+
"store_s3": obj.get("store_s3") if obj.get("store_s3") is not None else False,
|
|
144
|
+
"s3_filepath": obj.get("s3_filepath"),
|
|
145
|
+
"s3_bucket": obj.get("s3_bucket")
|
|
146
|
+
})
|
|
147
|
+
return _obj
|
|
148
|
+
|
|
149
|
+
|
|
@@ -0,0 +1,94 @@
|
|
|
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 __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
|
|
26
|
+
class CreatePdfResponse(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
Response for URL export type
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
url: StrictStr = Field(description="Signed URL to download the PDF (expires after specified time)")
|
|
31
|
+
filename: StrictStr = Field(description="Filename of the generated PDF")
|
|
32
|
+
credits_remaining: StrictInt = Field(description="Remaining credits after this request")
|
|
33
|
+
expires_in: StrictInt = Field(description="Seconds until URL expires")
|
|
34
|
+
__properties: ClassVar[List[str]] = ["url", "filename", "credits_remaining", "expires_in"]
|
|
35
|
+
|
|
36
|
+
model_config = ConfigDict(
|
|
37
|
+
populate_by_name=True,
|
|
38
|
+
validate_assignment=True,
|
|
39
|
+
protected_namespaces=(),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def to_str(self) -> str:
|
|
44
|
+
"""Returns the string representation of the model using alias"""
|
|
45
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
46
|
+
|
|
47
|
+
def to_json(self) -> str:
|
|
48
|
+
"""Returns the JSON representation of the model using alias"""
|
|
49
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
50
|
+
return json.dumps(self.to_dict())
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
54
|
+
"""Create an instance of CreatePdfResponse from a JSON string"""
|
|
55
|
+
return cls.from_dict(json.loads(json_str))
|
|
56
|
+
|
|
57
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
58
|
+
"""Return the dictionary representation of the model using alias.
|
|
59
|
+
|
|
60
|
+
This has the following differences from calling pydantic's
|
|
61
|
+
`self.model_dump(by_alias=True)`:
|
|
62
|
+
|
|
63
|
+
* `None` is only added to the output dict for nullable fields that
|
|
64
|
+
were set at model initialization. Other fields with value `None`
|
|
65
|
+
are ignored.
|
|
66
|
+
"""
|
|
67
|
+
excluded_fields: Set[str] = set([
|
|
68
|
+
])
|
|
69
|
+
|
|
70
|
+
_dict = self.model_dump(
|
|
71
|
+
by_alias=True,
|
|
72
|
+
exclude=excluded_fields,
|
|
73
|
+
exclude_none=True,
|
|
74
|
+
)
|
|
75
|
+
return _dict
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
79
|
+
"""Create an instance of CreatePdfResponse from a dict"""
|
|
80
|
+
if obj is None:
|
|
81
|
+
return None
|
|
82
|
+
|
|
83
|
+
if not isinstance(obj, dict):
|
|
84
|
+
return cls.model_validate(obj)
|
|
85
|
+
|
|
86
|
+
_obj = cls.model_validate({
|
|
87
|
+
"url": obj.get("url"),
|
|
88
|
+
"filename": obj.get("filename"),
|
|
89
|
+
"credits_remaining": obj.get("credits_remaining"),
|
|
90
|
+
"expires_in": obj.get("expires_in")
|
|
91
|
+
})
|
|
92
|
+
return _obj
|
|
93
|
+
|
|
94
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
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 __future__ import annotations
|
|
17
|
+
import json
|
|
18
|
+
from enum import Enum
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ExportType(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
PDF export type options
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
allowed enum values
|
|
29
|
+
"""
|
|
30
|
+
URL = 'url'
|
|
31
|
+
BINARY = 'binary'
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_json(cls, json_str: str) -> Self:
|
|
35
|
+
"""Create an instance of ExportType from a JSON string"""
|
|
36
|
+
return cls(json.loads(json_str))
|
|
37
|
+
|
|
38
|
+
|