signedly 0.1.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.
Files changed (74) hide show
  1. signedly/__init__.py +92 -0
  2. signedly/api/__init__.py +14 -0
  3. signedly/api/api_request_logs_api.py +686 -0
  4. signedly/api/authentication_api.py +603 -0
  5. signedly/api/bulk_sending_api.py +858 -0
  6. signedly/api/documents_api.py +2465 -0
  7. signedly/api/downloads_api.py +840 -0
  8. signedly/api/fields_api.py +2308 -0
  9. signedly/api/sending_api.py +890 -0
  10. signedly/api/signatories_api.py +1165 -0
  11. signedly/api/templates_api.py +1452 -0
  12. signedly/api/webhooks_api.py +2582 -0
  13. signedly/api_client.py +798 -0
  14. signedly/api_response.py +21 -0
  15. signedly/configuration.py +596 -0
  16. signedly/exceptions.py +200 -0
  17. signedly/helpers.py +89 -0
  18. signedly/models/__init__.py +66 -0
  19. signedly/models/create_bulk_send202_response.py +105 -0
  20. signedly/models/create_bulk_send_request.py +101 -0
  21. signedly/models/create_document_fields_request_inner.py +156 -0
  22. signedly/models/create_document_from_template200_response.py +101 -0
  23. signedly/models/create_document_from_template_request.py +115 -0
  24. signedly/models/create_document_from_template_request_recipients_inner.py +92 -0
  25. signedly/models/create_signatories_request.py +100 -0
  26. signedly/models/create_signatories_request_signatories_inner.py +92 -0
  27. signedly/models/create_signatory_request.py +94 -0
  28. signedly/models/create_template_fields_request_inner.py +156 -0
  29. signedly/models/create_webhook_endpoint_request.py +103 -0
  30. signedly/models/delete_field_request.py +88 -0
  31. signedly/models/document.py +159 -0
  32. signedly/models/document_page.py +113 -0
  33. signedly/models/document_status_page.py +113 -0
  34. signedly/models/document_status_row.py +90 -0
  35. signedly/models/fill_and_send_document_request.py +116 -0
  36. signedly/models/fill_and_send_document_request_elements_inner.py +96 -0
  37. signedly/models/get_access_token_request.py +90 -0
  38. signedly/models/get_audit_trail_link200_response.py +88 -0
  39. signedly/models/get_download_status200_response.py +90 -0
  40. signedly/models/list_bulk_send_columns200_response_inner.py +92 -0
  41. signedly/models/model_field.py +202 -0
  42. signedly/models/page.py +102 -0
  43. signedly/models/refresh_access_token200_response.py +99 -0
  44. signedly/models/refresh_access_token_request.py +88 -0
  45. signedly/models/request_count_page.py +113 -0
  46. signedly/models/request_hit.py +93 -0
  47. signedly/models/request_log.py +108 -0
  48. signedly/models/request_log_page.py +113 -0
  49. signedly/models/send_document200_response.py +88 -0
  50. signedly/models/send_document_by_link200_response.py +90 -0
  51. signedly/models/send_document_by_link_request.py +91 -0
  52. signedly/models/send_document_request.py +102 -0
  53. signedly/models/signatory.py +119 -0
  54. signedly/models/template.py +124 -0
  55. signedly/models/template_field.py +202 -0
  56. signedly/models/template_page.py +113 -0
  57. signedly/models/update_document_field_by_body_request.py +158 -0
  58. signedly/models/update_document_field_by_body_request_items_inner.py +92 -0
  59. signedly/models/update_webhook_endpoint_request.py +105 -0
  60. signedly/models/upload.py +110 -0
  61. signedly/models/upload_document_for_one_signer200_response.py +90 -0
  62. signedly/models/upload_document_for_one_signer_request.py +96 -0
  63. signedly/models/upload_document_request.py +101 -0
  64. signedly/models/webhook_delivery.py +140 -0
  65. signedly/models/webhook_delivery_page.py +113 -0
  66. signedly/models/webhook_endpoint.py +116 -0
  67. signedly/models/webhook_endpoint_with_secret.py +120 -0
  68. signedly/py.typed +0 -0
  69. signedly/rest.py +258 -0
  70. signedly-0.1.0.dist-info/LICENSE +21 -0
  71. signedly-0.1.0.dist-info/METADATA +18 -0
  72. signedly-0.1.0.dist-info/RECORD +74 -0
  73. signedly-0.1.0.dist-info/WHEEL +5 -0
  74. signedly-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,603 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Signedly API
5
+
6
+ The Signedly REST API lets your system upload documents, add signatories and fields, send them for signing and download the signed result. Every path starts with `/ap1/`, and every request and response body is JSON unless an endpoint says otherwise (the uploads are `multipart/form-data`). ## Authentication 1. In the Signedly web app, open **Account & Settings → API** and generate a **client ID** and **client secret** for your organisation. 2. `POST /ap1/token/` with them. You get an `access_token` (valid **2 hours**) and a `refresh_token` (valid **7 days**). While both are still valid, calling `/ap1/token/` again returns the same pair. 3. Send the access token on every other call: `Authorization: Bearer <access_token>`. 4. When the access token expires, `POST /ap1/refreshtoken/` with the refresh token for a new access token. When the refresh token has expired too, call `/ap1/token/` again. `/ap1/token/` and `/ap1/refreshtoken/` allow 60 calls a minute per IP address; more answer 429. A missing, unknown or expired access token answers 403 (`\"Client not found\"` or `\"Access token expired\"`). The API acts for your **organisation's admin account**: documents you upload belong to it and appear in its Signedly web app, and you can reach only that account's documents, templates, signatories and fields. Another organisation's IDs answer 404, as if they didn't exist. ## Plans What the API allows depends on the Signedly plan of your **organisation's admin account** (Account & Settings → Account & Plan). The same rules apply to live and test keys. | What | Free | Personal Pro | Business Pro | Teams | |---|---|---|---|---| | Generate live and test keys (Account & Settings → API) | – | ✓ | ✓ | ✓ | | Every endpoint, `/ap1/token/` and `/ap1/refreshtoken/` included | – | ✓ | ✓ | ✓ | | `require_email_otp` on `POST /ap1/signatories/` and `POST /ap1/signatories/bulk/` | – | ✓ | ✓ | ✓ | | Bulk send: `GET /ap1/bulk-sends/columns/` and `POST /ap1/bulk-sends/` | – | – | – | ✓ | The API is part of the paid plans. On Free (or with no plan) every call answers 403 `\"... Your plan doesn't include API access.\"`, with live or test keys, also with a token or keys made earlier; they work again once the plan is paid. On a paid plan, a feature it doesn't include answers 400 with `\"Your plan doesn't include ...\"` and changes nothing, and `GET /ap1/bulk-sends/{id}/` still reports bulk sends already made. Live documents also need an API contract with Signedly. Without one, or with an unpaid API invoice, `POST /ap1/upload/` (except templates), `/ap1/upload_app/`, `/ap1/documents/fromtemplate/` and `/ap1/bulk-sends/` answer 402 with live keys. Test keys work without a contract (see Sandbox). ## Sending a document for signing 1. `POST /ap1/upload/` a PDF or DOCX (`type` 2). The document is prepared in the background: find it in `GET /ap1/documents/?name=<name>` (its `upload.id` is the upload's `id`), and wait until `GET /ap1/documents/{id}/pages/` lists its pages. 2. `POST /ap1/signatories/` (one) or `POST /ap1/signatories/bulk/` (several) to add the people who sign. 3. `POST /ap1/documents/fields/` to place the fields each signatory fills in. 4. Send it: - `POST /ap1/document/send/` emails every signatory a signing link (with ordered signing, only the first; each next one is emailed in turn), or - `POST /ap1/document/send_url/` sends no email and returns the first signatory's signing link, for you to show or send yourself. 5. Poll `GET /ap1/documents-status-list/` (or `GET /ap1/documents/`) until the status is 6 (Completed), then `GET /ap1/document/download-link/` for the signed PDF and `GET /ap1/document/download-audit-link/` for its audit trail. **From a template:** upload with `type` 4 and a `template_name` (or make the template in the web app), place its fields with `POST /ap1/templates/fields/`, then for each signing make a document with `POST /ap1/documents/fromtemplate/`, add its signatory, and send it. **One signer, one call:** `POST /ap1/upload_app/` uploads a PDF or DOCX for one signer and returns their signing link in `redirect_url`; the signer places their own signature. After signing they go to the `redirect_url` you sent, and the signed PDF and its audit trail are emailed to `final_email` (otherwise to your organisation's admin). ## Quick start with curl Each step uses an ID from the step before. `$API` is this server, e.g. `https://l0ads.signedly.com`. ```bash # 1. Token curl -X POST $API/ap1/token/ -H 'Content-Type: application/json' \\ -d '{\"client_id\": \"<client id>\", \"client_secret\": \"<client secret>\"}' TOKEN=<access_token from the answer> # 2. Upload a PDF (answers with the upload's id) curl -X POST $API/ap1/upload/ -H \"Authorization: Bearer $TOKEN\" \\ -F file=@nda.pdf -F name=nda-ann-lee -F type=2 # 3. Find the document, then wait until it has pages curl \"$API/ap1/documents/?name=nda-ann-lee\" -H \"Authorization: Bearer $TOKEN\" DOC=<results[0].id> curl $API/ap1/documents/$DOC/pages/ -H \"Authorization: Bearer $TOKEN\" PAGE=<[0].id> # 4. Add the signatory curl -X POST $API/ap1/signatories/ -H \"Authorization: Bearer $TOKEN\" \\ -H 'Content-Type: application/json' \\ -d '{\"document_id\": \"'$DOC'\", \"name\": \"Ann Lee\", \"email\": \"ann@example.com\"}' SIGNER=<id from the answer> # 5. Place her signature: 150 × 40 points, 72 points from the left, 640 from the top curl -X POST $API/ap1/documents/fields/ -H \"Authorization: Bearer $TOKEN\" \\ -H 'Content-Type: application/json' \\ -d '[{\"document_id\": \"'$DOC'\", \"signatory_id\": \"'$SIGNER'\", \"kind\": 2, \"label\": \"Signature\", \"placeholder\": \"Sign here\", \"page\": \"'$PAGE'\", \"page_number\": 0, \"x\": 72, \"y\": 640, \"width\": 150, \"height\": 40}]' # 6. Send it (Ann gets the signing email) curl -X POST $API/ap1/document/send/ -H \"Authorization: Bearer $TOKEN\" \\ -H 'Content-Type: application/json' \\ -d '{\"document_id\": \"'$DOC'\", \"subject\": \"Please sign the NDA\", \"message\": \"Hi Ann, please sign by Friday.\", \"expiry_date\": \"2026-12-31\"}' # 7. Poll until status is 6 (Completed), then get the signed PDF curl \"$API/ap1/documents-status-list/?document_ids=$DOC\" -H \"Authorization: Bearer $TOKEN\" curl \"$API/ap1/document/download-link/?id=$DOC\" -H \"Authorization: Bearer $TOKEN\" ``` ## Postman Import the whole API into Postman with **Import → Link** and `<this server>/swaggerap1/postman.json`. Set `client_id` and `client_secret` in the collection's **Variables**, run **Get an access token** (it saves the token for every other request), and set `document_id` when a request needs one. ## Webhooks Instead of polling, add an endpoint with `POST /ap1/webhooks/` (or in **Account & Settings → API**) and Signedly posts your organisation's document events to it: `document.sent`, `document.viewed`, `document.signed`, `document.approved`, `document.completed`, `document.rejected` and `document.expired` (all of them, or the `events` you choose). Each is a JSON `POST`: ```json {\"id\": \"5b7f…\", \"type\": \"document.signed\", \"created_at\": \"2026-10-27T09:12:00+00:00\", \"test\": false, \"data\": {\"document\": {\"id\": \"6f0c…\", \"name\": \"nda.pdf\", \"status\": 5}, \"recipient\": {\"id\": \"0b6e…\", \"email\": \"ann@example.com\", \"name\": \"Ann Lee\", \"role\": \"signer\"}}} ``` `recipient` is null for events no recipient caused (sent, completed, expired); `test` is true for documents made with your test keys. Fetch anything else, such as download links, with your access token: events never carry links. **Check every event is from Signedly.** The `Signedly-Signature` header is `t=<unix seconds>,v1=<signature>`, where the signature is the hex HMAC-SHA256 of `<t>.<raw body>` with the endpoint's secret. Refuse an event whose signature doesn't match or whose `t` is more than 5 minutes off: ```python import hashlib, hmac, time def is_from_signedly(secret, header, raw_body): parts = dict(item.split(\"=\", 1) for item in header.split(\",\")) signed = f\"{parts['t']}.{raw_body.decode()}\".encode() expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest() fresh = abs(time.time() - int(parts[\"t\"])) <= 300 return fresh and hmac.compare_digest(parts[\"v1\"], expected) ``` **Answer 2xx within 10 seconds**, then do the work. Anything else is retried after 1 and 5 minutes, then 30 minutes and 2, 5 and 10 hours (7 tries in about 18 hours). `Signedly-Event-Id` is the same on every try of an event: use it to ignore repeats. After 20 events in a row fail for good, Signedly switches the endpoint off and emails your organisation's admin; switch it on again with `PUT /ap1/webhooks/{id}/` and `\"is_active\": true`. Each endpoint's deliveries and their last answers are at `GET /ap1/webhooks/{id}/deliveries/`, and any can be sent again. ## Sandbox Build and test against the API without paying for documents: in **Account & Settings → API**, generate your **test keys**, and get a token with them at `/ap1/token/` as usual. Everything works the same, except that what you upload or make from a template with a test token is a **test document** (`is_test` on its upload): - every page of its PDF and of its audit trail says **TEST – NOT LEGALLY BINDING**; - its emails are real, with `[TEST]` at the start of the subject; - it isn't billed or counted toward your plan; - your organisation can make 50 a calendar month (templates don't count); the next upload answers 429. ## Fields Positions and sizes are in **PDF points** (1/72 inch), measured from the **top-left corner** of the page as it is displayed (rotation applied). `page_number` counts pages from 0. A field must sit wholly on its page (1 point of tolerance); otherwise it is refused with 400. A field's page and signatory can't be changed later: delete the field and add it again. ## Status values **Document `status`:** 1 Draft · 2 Signees Added · 3 Prepared · 4 Sent · 5 In Progress · 6 Completed · 7 Rejected · 8 Archived · 9 Expired. Signatories, fields and sends are only accepted while a document is 1–3 (not yet sent). **Signatory `status`:** 1 Waiting · 2 Invited · 3 Signed · 4 Viewed · 5 Rejected. ## Lists `GET /ap1/documents/`, `/ap1/documents-status-list/`, `/ap1/templates/`, `/ap1/logs/` and `/ap1/logs/hits/` are paged: pass `limit` (default 10) and `offset`, and read `count`, `next`, `previous` and `results` from the response. ## Errors | Status | Meaning | |---|---| | 400 | The request was refused, also when your plan doesn't include it (see Plans); the body says why (`{\"error\": \"...\"}`, or the name of each bad field with its messages). Nothing was changed. | | 403 | The access token is missing, unknown or expired; the client ID and secret or the refresh token were refused; the organisation's plan has no API access (Free, see Plans); or an `expiry_date` isn't in the future (`\"Invalid Date Entered\"`). | | 402 | No API contract, or an unpaid API invoice: live documents are refused (test keys keep working). | | 404 | The document, template, signatory or field doesn't exist or isn't yours. | | 429 | Too many token requests (wait a minute), or this month's 50 test documents are used. | | 5xx | Our side failed; retry later. | A send that times out may still have worked: check the document's status before sending again (a second send of a sent document answers 400). Download, view and audit links are valid for about 7 days; ask for a new one whenever you need it.
7
+
8
+ The version of the OpenAPI document: v1
9
+ Contact: info@signedly.com
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+ import warnings
16
+ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
17
+ from typing import Any, Dict, List, Optional, Tuple, Union
18
+ from typing_extensions import Annotated
19
+
20
+ from signedly.models.get_access_token_request import GetAccessTokenRequest
21
+ from signedly.models.refresh_access_token200_response import RefreshAccessToken200Response
22
+ from signedly.models.refresh_access_token_request import RefreshAccessTokenRequest
23
+
24
+ from signedly.api_client import ApiClient, RequestSerialized
25
+ from signedly.api_response import ApiResponse
26
+ from signedly.rest import RESTResponseType
27
+
28
+
29
+ class AuthenticationApi:
30
+ """NOTE: This class is auto generated by OpenAPI Generator
31
+ Ref: https://openapi-generator.tech
32
+
33
+ Do not edit the class manually.
34
+ """
35
+
36
+ def __init__(self, api_client=None) -> None:
37
+ if api_client is None:
38
+ api_client = ApiClient.get_default()
39
+ self.api_client = api_client
40
+
41
+
42
+ @validate_call
43
+ def get_access_token(
44
+ self,
45
+ data: GetAccessTokenRequest,
46
+ _request_timeout: Union[
47
+ None,
48
+ Annotated[StrictFloat, Field(gt=0)],
49
+ Tuple[
50
+ Annotated[StrictFloat, Field(gt=0)],
51
+ Annotated[StrictFloat, Field(gt=0)]
52
+ ]
53
+ ] = None,
54
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
55
+ _content_type: Optional[StrictStr] = None,
56
+ _headers: Optional[Dict[StrictStr, Any]] = None,
57
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
58
+ ) -> RefreshAccessToken200Response:
59
+ """Get an access token
60
+
61
+ Exchanges your client ID and secret (Account & Settings → API in the web app) for an access token, valid 2 hours, and a refresh token, valid 7 days. While both are still valid, the same pair is returned again; once either has expired, a new pair is made. Your test keys get a test token of their own (see Sandbox).
62
+
63
+ :param data: (required)
64
+ :type data: GetAccessTokenRequest
65
+ :param _request_timeout: timeout setting for this request. If one
66
+ number provided, it will be total request
67
+ timeout. It can also be a pair (tuple) of
68
+ (connection, read) timeouts.
69
+ :type _request_timeout: int, tuple(int, int), optional
70
+ :param _request_auth: set to override the auth_settings for an a single
71
+ request; this effectively ignores the
72
+ authentication in the spec for a single request.
73
+ :type _request_auth: dict, optional
74
+ :param _content_type: force content-type for the request.
75
+ :type _content_type: str, Optional
76
+ :param _headers: set to override the headers for a single
77
+ request; this effectively ignores the headers
78
+ in the spec for a single request.
79
+ :type _headers: dict, optional
80
+ :param _host_index: set to override the host_index for a single
81
+ request; this effectively ignores the host_index
82
+ in the spec for a single request.
83
+ :type _host_index: int, optional
84
+ :return: Returns the result object.
85
+ """ # noqa: E501
86
+
87
+ _param = self._get_access_token_serialize(
88
+ data=data,
89
+ _request_auth=_request_auth,
90
+ _content_type=_content_type,
91
+ _headers=_headers,
92
+ _host_index=_host_index
93
+ )
94
+
95
+ _response_types_map: Dict[str, Optional[str]] = {
96
+ '200': "RefreshAccessToken200Response",
97
+ '400': "Dict[str, object]",
98
+ '403': "Dict[str, object]",
99
+ '429': "Dict[str, object]",
100
+ }
101
+ response_data = self.api_client.call_api(
102
+ *_param,
103
+ _request_timeout=_request_timeout
104
+ )
105
+ response_data.read()
106
+ return self.api_client.response_deserialize(
107
+ response_data=response_data,
108
+ response_types_map=_response_types_map,
109
+ ).data
110
+
111
+
112
+ @validate_call
113
+ def get_access_token_with_http_info(
114
+ self,
115
+ data: GetAccessTokenRequest,
116
+ _request_timeout: Union[
117
+ None,
118
+ Annotated[StrictFloat, Field(gt=0)],
119
+ Tuple[
120
+ Annotated[StrictFloat, Field(gt=0)],
121
+ Annotated[StrictFloat, Field(gt=0)]
122
+ ]
123
+ ] = None,
124
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
125
+ _content_type: Optional[StrictStr] = None,
126
+ _headers: Optional[Dict[StrictStr, Any]] = None,
127
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
128
+ ) -> ApiResponse[RefreshAccessToken200Response]:
129
+ """Get an access token
130
+
131
+ Exchanges your client ID and secret (Account & Settings → API in the web app) for an access token, valid 2 hours, and a refresh token, valid 7 days. While both are still valid, the same pair is returned again; once either has expired, a new pair is made. Your test keys get a test token of their own (see Sandbox).
132
+
133
+ :param data: (required)
134
+ :type data: GetAccessTokenRequest
135
+ :param _request_timeout: timeout setting for this request. If one
136
+ number provided, it will be total request
137
+ timeout. It can also be a pair (tuple) of
138
+ (connection, read) timeouts.
139
+ :type _request_timeout: int, tuple(int, int), optional
140
+ :param _request_auth: set to override the auth_settings for an a single
141
+ request; this effectively ignores the
142
+ authentication in the spec for a single request.
143
+ :type _request_auth: dict, optional
144
+ :param _content_type: force content-type for the request.
145
+ :type _content_type: str, Optional
146
+ :param _headers: set to override the headers for a single
147
+ request; this effectively ignores the headers
148
+ in the spec for a single request.
149
+ :type _headers: dict, optional
150
+ :param _host_index: set to override the host_index for a single
151
+ request; this effectively ignores the host_index
152
+ in the spec for a single request.
153
+ :type _host_index: int, optional
154
+ :return: Returns the result object.
155
+ """ # noqa: E501
156
+
157
+ _param = self._get_access_token_serialize(
158
+ data=data,
159
+ _request_auth=_request_auth,
160
+ _content_type=_content_type,
161
+ _headers=_headers,
162
+ _host_index=_host_index
163
+ )
164
+
165
+ _response_types_map: Dict[str, Optional[str]] = {
166
+ '200': "RefreshAccessToken200Response",
167
+ '400': "Dict[str, object]",
168
+ '403': "Dict[str, object]",
169
+ '429': "Dict[str, object]",
170
+ }
171
+ response_data = self.api_client.call_api(
172
+ *_param,
173
+ _request_timeout=_request_timeout
174
+ )
175
+ response_data.read()
176
+ return self.api_client.response_deserialize(
177
+ response_data=response_data,
178
+ response_types_map=_response_types_map,
179
+ )
180
+
181
+
182
+ @validate_call
183
+ def get_access_token_without_preload_content(
184
+ self,
185
+ data: GetAccessTokenRequest,
186
+ _request_timeout: Union[
187
+ None,
188
+ Annotated[StrictFloat, Field(gt=0)],
189
+ Tuple[
190
+ Annotated[StrictFloat, Field(gt=0)],
191
+ Annotated[StrictFloat, Field(gt=0)]
192
+ ]
193
+ ] = None,
194
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
195
+ _content_type: Optional[StrictStr] = None,
196
+ _headers: Optional[Dict[StrictStr, Any]] = None,
197
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
198
+ ) -> RESTResponseType:
199
+ """Get an access token
200
+
201
+ Exchanges your client ID and secret (Account & Settings → API in the web app) for an access token, valid 2 hours, and a refresh token, valid 7 days. While both are still valid, the same pair is returned again; once either has expired, a new pair is made. Your test keys get a test token of their own (see Sandbox).
202
+
203
+ :param data: (required)
204
+ :type data: GetAccessTokenRequest
205
+ :param _request_timeout: timeout setting for this request. If one
206
+ number provided, it will be total request
207
+ timeout. It can also be a pair (tuple) of
208
+ (connection, read) timeouts.
209
+ :type _request_timeout: int, tuple(int, int), optional
210
+ :param _request_auth: set to override the auth_settings for an a single
211
+ request; this effectively ignores the
212
+ authentication in the spec for a single request.
213
+ :type _request_auth: dict, optional
214
+ :param _content_type: force content-type for the request.
215
+ :type _content_type: str, Optional
216
+ :param _headers: set to override the headers for a single
217
+ request; this effectively ignores the headers
218
+ in the spec for a single request.
219
+ :type _headers: dict, optional
220
+ :param _host_index: set to override the host_index for a single
221
+ request; this effectively ignores the host_index
222
+ in the spec for a single request.
223
+ :type _host_index: int, optional
224
+ :return: Returns the result object.
225
+ """ # noqa: E501
226
+
227
+ _param = self._get_access_token_serialize(
228
+ data=data,
229
+ _request_auth=_request_auth,
230
+ _content_type=_content_type,
231
+ _headers=_headers,
232
+ _host_index=_host_index
233
+ )
234
+
235
+ _response_types_map: Dict[str, Optional[str]] = {
236
+ '200': "RefreshAccessToken200Response",
237
+ '400': "Dict[str, object]",
238
+ '403': "Dict[str, object]",
239
+ '429': "Dict[str, object]",
240
+ }
241
+ response_data = self.api_client.call_api(
242
+ *_param,
243
+ _request_timeout=_request_timeout
244
+ )
245
+ return response_data.response
246
+
247
+
248
+ def _get_access_token_serialize(
249
+ self,
250
+ data,
251
+ _request_auth,
252
+ _content_type,
253
+ _headers,
254
+ _host_index,
255
+ ) -> RequestSerialized:
256
+
257
+ _host = None
258
+
259
+ _collection_formats: Dict[str, str] = {
260
+ }
261
+
262
+ _path_params: Dict[str, str] = {}
263
+ _query_params: List[Tuple[str, str]] = []
264
+ _header_params: Dict[str, Optional[str]] = _headers or {}
265
+ _form_params: List[Tuple[str, str]] = []
266
+ _files: Dict[
267
+ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
268
+ ] = {}
269
+ _body_params: Optional[bytes] = None
270
+
271
+ # process the path parameters
272
+ # process the query parameters
273
+ # process the header parameters
274
+ # process the form parameters
275
+ # process the body parameter
276
+ if data is not None:
277
+ _body_params = data
278
+
279
+
280
+ # set the HTTP header `Accept`
281
+ if 'Accept' not in _header_params:
282
+ _header_params['Accept'] = self.api_client.select_header_accept(
283
+ [
284
+ 'application/json'
285
+ ]
286
+ )
287
+
288
+ # set the HTTP header `Content-Type`
289
+ if _content_type:
290
+ _header_params['Content-Type'] = _content_type
291
+ else:
292
+ _default_content_type = (
293
+ self.api_client.select_header_content_type(
294
+ [
295
+ 'application/json'
296
+ ]
297
+ )
298
+ )
299
+ if _default_content_type is not None:
300
+ _header_params['Content-Type'] = _default_content_type
301
+
302
+ # authentication setting
303
+ _auth_settings: List[str] = [
304
+ ]
305
+
306
+ return self.api_client.param_serialize(
307
+ method='POST',
308
+ resource_path='/ap1/token/',
309
+ path_params=_path_params,
310
+ query_params=_query_params,
311
+ header_params=_header_params,
312
+ body=_body_params,
313
+ post_params=_form_params,
314
+ files=_files,
315
+ auth_settings=_auth_settings,
316
+ collection_formats=_collection_formats,
317
+ _host=_host,
318
+ _request_auth=_request_auth
319
+ )
320
+
321
+
322
+
323
+
324
+ @validate_call
325
+ def refresh_access_token(
326
+ self,
327
+ data: RefreshAccessTokenRequest,
328
+ _request_timeout: Union[
329
+ None,
330
+ Annotated[StrictFloat, Field(gt=0)],
331
+ Tuple[
332
+ Annotated[StrictFloat, Field(gt=0)],
333
+ Annotated[StrictFloat, Field(gt=0)]
334
+ ]
335
+ ] = None,
336
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
337
+ _content_type: Optional[StrictStr] = None,
338
+ _headers: Optional[Dict[StrictStr, Any]] = None,
339
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
340
+ ) -> RefreshAccessToken200Response:
341
+ """Refresh the access token
342
+
343
+ Makes a new access token, valid 2 hours, with the refresh token. The refresh token itself isn't renewed: when it expires (7 days after /ap1/token/ made it), call /ap1/token/ again.
344
+
345
+ :param data: (required)
346
+ :type data: RefreshAccessTokenRequest
347
+ :param _request_timeout: timeout setting for this request. If one
348
+ number provided, it will be total request
349
+ timeout. It can also be a pair (tuple) of
350
+ (connection, read) timeouts.
351
+ :type _request_timeout: int, tuple(int, int), optional
352
+ :param _request_auth: set to override the auth_settings for an a single
353
+ request; this effectively ignores the
354
+ authentication in the spec for a single request.
355
+ :type _request_auth: dict, optional
356
+ :param _content_type: force content-type for the request.
357
+ :type _content_type: str, Optional
358
+ :param _headers: set to override the headers for a single
359
+ request; this effectively ignores the headers
360
+ in the spec for a single request.
361
+ :type _headers: dict, optional
362
+ :param _host_index: set to override the host_index for a single
363
+ request; this effectively ignores the host_index
364
+ in the spec for a single request.
365
+ :type _host_index: int, optional
366
+ :return: Returns the result object.
367
+ """ # noqa: E501
368
+
369
+ _param = self._refresh_access_token_serialize(
370
+ data=data,
371
+ _request_auth=_request_auth,
372
+ _content_type=_content_type,
373
+ _headers=_headers,
374
+ _host_index=_host_index
375
+ )
376
+
377
+ _response_types_map: Dict[str, Optional[str]] = {
378
+ '200': "RefreshAccessToken200Response",
379
+ '400': "Dict[str, object]",
380
+ '403': "Dict[str, object]",
381
+ '429': "Dict[str, object]",
382
+ }
383
+ response_data = self.api_client.call_api(
384
+ *_param,
385
+ _request_timeout=_request_timeout
386
+ )
387
+ response_data.read()
388
+ return self.api_client.response_deserialize(
389
+ response_data=response_data,
390
+ response_types_map=_response_types_map,
391
+ ).data
392
+
393
+
394
+ @validate_call
395
+ def refresh_access_token_with_http_info(
396
+ self,
397
+ data: RefreshAccessTokenRequest,
398
+ _request_timeout: Union[
399
+ None,
400
+ Annotated[StrictFloat, Field(gt=0)],
401
+ Tuple[
402
+ Annotated[StrictFloat, Field(gt=0)],
403
+ Annotated[StrictFloat, Field(gt=0)]
404
+ ]
405
+ ] = None,
406
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
407
+ _content_type: Optional[StrictStr] = None,
408
+ _headers: Optional[Dict[StrictStr, Any]] = None,
409
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
410
+ ) -> ApiResponse[RefreshAccessToken200Response]:
411
+ """Refresh the access token
412
+
413
+ Makes a new access token, valid 2 hours, with the refresh token. The refresh token itself isn't renewed: when it expires (7 days after /ap1/token/ made it), call /ap1/token/ again.
414
+
415
+ :param data: (required)
416
+ :type data: RefreshAccessTokenRequest
417
+ :param _request_timeout: timeout setting for this request. If one
418
+ number provided, it will be total request
419
+ timeout. It can also be a pair (tuple) of
420
+ (connection, read) timeouts.
421
+ :type _request_timeout: int, tuple(int, int), optional
422
+ :param _request_auth: set to override the auth_settings for an a single
423
+ request; this effectively ignores the
424
+ authentication in the spec for a single request.
425
+ :type _request_auth: dict, optional
426
+ :param _content_type: force content-type for the request.
427
+ :type _content_type: str, Optional
428
+ :param _headers: set to override the headers for a single
429
+ request; this effectively ignores the headers
430
+ in the spec for a single request.
431
+ :type _headers: dict, optional
432
+ :param _host_index: set to override the host_index for a single
433
+ request; this effectively ignores the host_index
434
+ in the spec for a single request.
435
+ :type _host_index: int, optional
436
+ :return: Returns the result object.
437
+ """ # noqa: E501
438
+
439
+ _param = self._refresh_access_token_serialize(
440
+ data=data,
441
+ _request_auth=_request_auth,
442
+ _content_type=_content_type,
443
+ _headers=_headers,
444
+ _host_index=_host_index
445
+ )
446
+
447
+ _response_types_map: Dict[str, Optional[str]] = {
448
+ '200': "RefreshAccessToken200Response",
449
+ '400': "Dict[str, object]",
450
+ '403': "Dict[str, object]",
451
+ '429': "Dict[str, object]",
452
+ }
453
+ response_data = self.api_client.call_api(
454
+ *_param,
455
+ _request_timeout=_request_timeout
456
+ )
457
+ response_data.read()
458
+ return self.api_client.response_deserialize(
459
+ response_data=response_data,
460
+ response_types_map=_response_types_map,
461
+ )
462
+
463
+
464
+ @validate_call
465
+ def refresh_access_token_without_preload_content(
466
+ self,
467
+ data: RefreshAccessTokenRequest,
468
+ _request_timeout: Union[
469
+ None,
470
+ Annotated[StrictFloat, Field(gt=0)],
471
+ Tuple[
472
+ Annotated[StrictFloat, Field(gt=0)],
473
+ Annotated[StrictFloat, Field(gt=0)]
474
+ ]
475
+ ] = None,
476
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
477
+ _content_type: Optional[StrictStr] = None,
478
+ _headers: Optional[Dict[StrictStr, Any]] = None,
479
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
480
+ ) -> RESTResponseType:
481
+ """Refresh the access token
482
+
483
+ Makes a new access token, valid 2 hours, with the refresh token. The refresh token itself isn't renewed: when it expires (7 days after /ap1/token/ made it), call /ap1/token/ again.
484
+
485
+ :param data: (required)
486
+ :type data: RefreshAccessTokenRequest
487
+ :param _request_timeout: timeout setting for this request. If one
488
+ number provided, it will be total request
489
+ timeout. It can also be a pair (tuple) of
490
+ (connection, read) timeouts.
491
+ :type _request_timeout: int, tuple(int, int), optional
492
+ :param _request_auth: set to override the auth_settings for an a single
493
+ request; this effectively ignores the
494
+ authentication in the spec for a single request.
495
+ :type _request_auth: dict, optional
496
+ :param _content_type: force content-type for the request.
497
+ :type _content_type: str, Optional
498
+ :param _headers: set to override the headers for a single
499
+ request; this effectively ignores the headers
500
+ in the spec for a single request.
501
+ :type _headers: dict, optional
502
+ :param _host_index: set to override the host_index for a single
503
+ request; this effectively ignores the host_index
504
+ in the spec for a single request.
505
+ :type _host_index: int, optional
506
+ :return: Returns the result object.
507
+ """ # noqa: E501
508
+
509
+ _param = self._refresh_access_token_serialize(
510
+ data=data,
511
+ _request_auth=_request_auth,
512
+ _content_type=_content_type,
513
+ _headers=_headers,
514
+ _host_index=_host_index
515
+ )
516
+
517
+ _response_types_map: Dict[str, Optional[str]] = {
518
+ '200': "RefreshAccessToken200Response",
519
+ '400': "Dict[str, object]",
520
+ '403': "Dict[str, object]",
521
+ '429': "Dict[str, object]",
522
+ }
523
+ response_data = self.api_client.call_api(
524
+ *_param,
525
+ _request_timeout=_request_timeout
526
+ )
527
+ return response_data.response
528
+
529
+
530
+ def _refresh_access_token_serialize(
531
+ self,
532
+ data,
533
+ _request_auth,
534
+ _content_type,
535
+ _headers,
536
+ _host_index,
537
+ ) -> RequestSerialized:
538
+
539
+ _host = None
540
+
541
+ _collection_formats: Dict[str, str] = {
542
+ }
543
+
544
+ _path_params: Dict[str, str] = {}
545
+ _query_params: List[Tuple[str, str]] = []
546
+ _header_params: Dict[str, Optional[str]] = _headers or {}
547
+ _form_params: List[Tuple[str, str]] = []
548
+ _files: Dict[
549
+ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
550
+ ] = {}
551
+ _body_params: Optional[bytes] = None
552
+
553
+ # process the path parameters
554
+ # process the query parameters
555
+ # process the header parameters
556
+ # process the form parameters
557
+ # process the body parameter
558
+ if data is not None:
559
+ _body_params = data
560
+
561
+
562
+ # set the HTTP header `Accept`
563
+ if 'Accept' not in _header_params:
564
+ _header_params['Accept'] = self.api_client.select_header_accept(
565
+ [
566
+ 'application/json'
567
+ ]
568
+ )
569
+
570
+ # set the HTTP header `Content-Type`
571
+ if _content_type:
572
+ _header_params['Content-Type'] = _content_type
573
+ else:
574
+ _default_content_type = (
575
+ self.api_client.select_header_content_type(
576
+ [
577
+ 'application/json'
578
+ ]
579
+ )
580
+ )
581
+ if _default_content_type is not None:
582
+ _header_params['Content-Type'] = _default_content_type
583
+
584
+ # authentication setting
585
+ _auth_settings: List[str] = [
586
+ ]
587
+
588
+ return self.api_client.param_serialize(
589
+ method='POST',
590
+ resource_path='/ap1/refreshtoken/',
591
+ path_params=_path_params,
592
+ query_params=_query_params,
593
+ header_params=_header_params,
594
+ body=_body_params,
595
+ post_params=_form_params,
596
+ files=_files,
597
+ auth_settings=_auth_settings,
598
+ collection_formats=_collection_formats,
599
+ _host=_host,
600
+ _request_auth=_request_auth
601
+ )
602
+
603
+