GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — docspring-python/docspring/models/combined_pdf.py at main · DocSpring/docspring-python

Expand file tree

/

combined_pdf.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
163 lines (136 loc) · 8.41 KB
/

combined_pdf.py

Copy path

File metadata and controls

163 lines (136 loc) · 8.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# coding: utf-8
"""
DocSpring API
Use DocSpring's API to fill PDF forms, generate PDFs and Word documents from HTML or Word templates, merge PDFs, and request legally binding e-signatures.
The version of the OpenAPI document: v2
Contact: [email protected]
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from docspring.models.combined_pdf_files import CombinedPdfFiles
from docspring.models.combined_pdf_source import CombinedPdfSource
from docspring.models.combined_pdf_state import CombinedPdfState
from docspring.models.submission_action import SubmissionAction
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python
class CombinedPdf(BaseModel):
"""
A PDF made by merging other PDFs: submissions, other combined PDFs, templates, custom files and PDFs from URLs.
""" # noqa: E501
id: StrictStr = Field(description="The combined PDF's ID.")
state: CombinedPdfState = Field(description="`pending` until the PDF has been generated, then `processed`. `insufficient_credits`: waiting for credits; `error_message` says whether the PDF is generated once you add them. `account_suspended`: waiting for the account to be reactivated, for up to 30 days. `error`: the PDFs couldn't be merged (see `error_message`). Waiting ends in `error` if it's discarded or takes over 30 days.")
source_pdfs: List[CombinedPdfSource] = Field(description="The PDFs to merge, in order.")
metadata: Dict[str, Any] = Field(description="Your own data about the combined PDF, such as an ID from your app. Its `pdf_filename` key names the PDF's file (`files.pdf.filename`, and its download): a `.pdf` ending is removed, each run of characters other than letters, digits, `-`, `_` and `.` becomes one `_`, and the first 128 characters are kept, then `.pdf` is added. Without it, the file is named after the combined PDF's ID (`com_1234567890abcdef01.pdf`).")
has_password: StrictBool = Field(description="Whether the PDF needs a password to open (`password`).")
delete_custom_files: StrictBool = Field(description="Delete the custom files in `source_pdfs` once the combined PDF has been generated (they're kept if it fails). Other combined PDFs can't use them after that. A test API token can't delete custom files.")
error_message: Optional[StrictStr] = Field(description="Why the PDFs couldn't be merged, when `state` is `error`.")
files: CombinedPdfFiles = Field(description="The generated files, by format. Empty until the PDF has been generated, and once it has expired.")
actions: List[SubmissionAction] = Field(description="The uploads of the PDF to your storage (account integrations).")
expired: StrictBool = Field(description="An expired combined PDF's PDF, metadata, password and source URLs have been deleted.")
expires_at: Optional[datetime] = Field(description="When the combined PDF expires (`expires_in` after it's generated). Null if it's kept until you delete it.")
processed_at: Optional[datetime] = Field(description="When the PDF was generated. Null until then.")
created_at: datetime = Field(description="When the combined PDF was created.")
updated_at: datetime = Field(description="When the combined PDF was last updated.")
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["id", "state", "source_pdfs", "metadata", "has_password", "delete_custom_files", "error_message", "files", "actions", "expired", "expires_at", "processed_at", "created_at", "updated_at"]
model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=True,
validate_assignment=True,
protected_namespaces=(),
)
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(to_jsonable_python(self.to_dict()))
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of CombinedPdf from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
* Fields in `self.additional_properties` are added to the output dict.
"""
excluded_fields: Set[str] = set([
"additional_properties",
])
_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of each item in source_pdfs (list)
_items = []
if self.source_pdfs:
for _item_source_pdfs in self.source_pdfs:
_items.append(_item_source_pdfs.to_dict() if _item_source_pdfs is not None else None)
_dict['source_pdfs'] = _items
# override the default output from pydantic by calling `to_dict()` of files
if self.files:
_dict['files'] = self.files.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in actions (list)
_items = []
if self.actions:
for _item_actions in self.actions:
_items.append(_item_actions.to_dict() if _item_actions is not None else None)
_dict['actions'] = _items
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
# set to None if error_message (nullable) is None
# and model_fields_set contains the field
if self.error_message is None and "error_message" in self.model_fields_set:
_dict['error_message'] = None
# set to None if expires_at (nullable) is None
# and model_fields_set contains the field
if self.expires_at is None and "expires_at" in self.model_fields_set:
_dict['expires_at'] = None
# set to None if processed_at (nullable) is None
# and model_fields_set contains the field
if self.processed_at is None and "processed_at" in self.model_fields_set:
_dict['processed_at'] = None
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of CombinedPdf from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj, context={"skip_enum_validation": True})
_obj = cls.model_validate({
"id": obj.get("id"),
"state": obj.get("state"),
"source_pdfs": [CombinedPdfSource.from_dict(_item) for _item in obj["source_pdfs"]] if obj.get("source_pdfs") is not None else None,
"metadata": obj.get("metadata"),
"has_password": obj.get("has_password"),
"delete_custom_files": obj.get("delete_custom_files"),
"error_message": obj.get("error_message"),
"files": CombinedPdfFiles.from_dict(obj["files"]) if obj.get("files") is not None else None,
"actions": [SubmissionAction.from_dict(_item) for _item in obj["actions"]] if obj.get("actions") is not None else None,
"expired": obj.get("expired"),
"expires_at": obj.get("expires_at"),
"processed_at": obj.get("processed_at"),
"created_at": obj.get("created_at"),
"updated_at": obj.get("updated_at")
}, context={"skip_enum_validation": True})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
return _obj
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.