flatmark 1.0.6__tar.gz → 1.0.8__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.
Files changed (44) hide show
  1. {flatmark-1.0.6 → flatmark-1.0.8}/PKG-INFO +1 -1
  2. flatmark-1.0.8/flatmark/api/webhooks/__init__.py +1 -0
  3. flatmark-1.0.8/flatmark/api/webhooks/create_webhook_endpoint.py +205 -0
  4. flatmark-1.0.8/flatmark/api/webhooks/delete_webhook_endpoint.py +191 -0
  5. flatmark-1.0.8/flatmark/api/webhooks/list_webhook_endpoints.py +159 -0
  6. flatmark-1.0.8/flatmark/api/webhooks/send_webhook_test_event.py +202 -0
  7. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/__init__.py +10 -0
  8. flatmark-1.0.8/flatmark/models/webhook_endpoint_created.py +144 -0
  9. flatmark-1.0.8/flatmark/models/webhook_endpoint_request.py +84 -0
  10. flatmark-1.0.8/flatmark/models/webhook_endpoint_response.py +136 -0
  11. flatmark-1.0.8/flatmark/models/webhook_endpoint_response_page.py +97 -0
  12. flatmark-1.0.8/flatmark/models/webhook_test_queued.py +62 -0
  13. {flatmark-1.0.6 → flatmark-1.0.8}/pyproject.toml +1 -1
  14. {flatmark-1.0.6 → flatmark-1.0.8}/pyproject.toml.orig +1 -1
  15. {flatmark-1.0.6 → flatmark-1.0.8}/README.md +0 -0
  16. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/__init__.py +0 -0
  17. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/__init__.py +0 -0
  18. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/account/__init__.py +0 -0
  19. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/account/get_me.py +0 -0
  20. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/convert/__init__.py +0 -0
  21. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/convert/convert_document.py +0 -0
  22. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/convert/get_conversion_result.py +0 -0
  23. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/convert/submit_conversion_job.py +0 -0
  24. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/jobs/__init__.py +0 -0
  25. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/jobs/get_job.py +0 -0
  26. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/api/jobs/list_jobs.py +0 -0
  27. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/client.py +0 -0
  28. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/errors.py +0 -0
  29. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/body_convert_document.py +0 -0
  30. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/body_submit_conversion_job.py +0 -0
  31. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/credits_info.py +0 -0
  32. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/get_conversion_result_format.py +0 -0
  33. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/job_response.py +0 -0
  34. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/job_response_page.py +0 -0
  35. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/job_response_result_type_0.py +0 -0
  36. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/job_submit_response.py +0 -0
  37. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/me_response.py +0 -0
  38. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/problem.py +0 -0
  39. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/problem_errors_type_0_item.py +0 -0
  40. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/rate_limit_info.py +0 -0
  41. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/sync_convert_response.py +0 -0
  42. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/models/sync_convert_response_meta.py +0 -0
  43. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/py.typed +0 -0
  44. {flatmark-1.0.6 → flatmark-1.0.8}/flatmark/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: flatmark
3
- Version: 1.0.6
3
+ Version: 1.0.8
4
4
  Summary: A client library for accessing flatmark
5
5
  Requires-Dist: httpx>=0.23.1,<0.29.0
6
6
  Requires-Dist: attrs>=22.2.0
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,205 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.problem import Problem
9
+ from ...models.webhook_endpoint_created import WebhookEndpointCreated
10
+ from ...models.webhook_endpoint_request import WebhookEndpointRequest
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ body: WebhookEndpointRequest,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "post",
22
+ "url": "/v1/webhooks",
23
+ }
24
+
25
+ _kwargs["json"] = body.to_dict()
26
+
27
+ headers["Content-Type"] = "application/json"
28
+
29
+ _kwargs["headers"] = headers
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: AuthenticatedClient | Client, response: httpx.Response
35
+ ) -> Problem | WebhookEndpointCreated | None:
36
+ if response.status_code == 201:
37
+ response_201 = WebhookEndpointCreated.from_dict(response.json())
38
+
39
+ return response_201
40
+
41
+ if response.status_code == 401:
42
+ response_401 = Problem.from_dict(response.json())
43
+
44
+ return response_401
45
+
46
+ if response.status_code == 409:
47
+ response_409 = Problem.from_dict(response.json())
48
+
49
+ return response_409
50
+
51
+ if response.status_code == 422:
52
+ response_422 = Problem.from_dict(response.json())
53
+
54
+ return response_422
55
+
56
+ if response.status_code == 429:
57
+ response_429 = Problem.from_dict(response.json())
58
+
59
+ return response_429
60
+
61
+ if client.raise_on_unexpected_status:
62
+ raise errors.UnexpectedStatus(response.status_code, response.content)
63
+ else:
64
+ return None
65
+
66
+
67
+ def _build_response(
68
+ *, client: AuthenticatedClient | Client, response: httpx.Response
69
+ ) -> Response[Problem | WebhookEndpointCreated]:
70
+ return Response(
71
+ status_code=HTTPStatus(response.status_code),
72
+ content=response.content,
73
+ headers=response.headers,
74
+ parsed=_parse_response(client=client, response=response),
75
+ )
76
+
77
+
78
+ def sync_detailed(
79
+ *,
80
+ client: AuthenticatedClient,
81
+ body: WebhookEndpointRequest,
82
+ ) -> Response[Problem | WebhookEndpointCreated]:
83
+ """Create a webhook endpoint
84
+
85
+ Subscribes a URL to events. The response carries the signing secret,
86
+ the only time it is shown. Every delivery is a POST signed per Standard
87
+ Webhooks (`webhook-id`, `webhook-timestamp`, `webhook-signature`).
88
+
89
+ **Credits:** free. This endpoint is not metered.
90
+
91
+ Args:
92
+ body (WebhookEndpointRequest): A new endpoint.
93
+
94
+ Raises:
95
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
96
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
97
+
98
+ Returns:
99
+ Response[Problem | WebhookEndpointCreated]
100
+ """
101
+
102
+ kwargs = _get_kwargs(
103
+ body=body,
104
+ )
105
+
106
+ response = client.get_httpx_client().request(
107
+ **kwargs,
108
+ )
109
+
110
+ return _build_response(client=client, response=response)
111
+
112
+
113
+ def sync(
114
+ *,
115
+ client: AuthenticatedClient,
116
+ body: WebhookEndpointRequest,
117
+ ) -> Problem | WebhookEndpointCreated | None:
118
+ """Create a webhook endpoint
119
+
120
+ Subscribes a URL to events. The response carries the signing secret,
121
+ the only time it is shown. Every delivery is a POST signed per Standard
122
+ Webhooks (`webhook-id`, `webhook-timestamp`, `webhook-signature`).
123
+
124
+ **Credits:** free. This endpoint is not metered.
125
+
126
+ Args:
127
+ body (WebhookEndpointRequest): A new endpoint.
128
+
129
+ Raises:
130
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
131
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
132
+
133
+ Returns:
134
+ Problem | WebhookEndpointCreated
135
+ """
136
+
137
+ return sync_detailed(
138
+ client=client,
139
+ body=body,
140
+ ).parsed
141
+
142
+
143
+ async def asyncio_detailed(
144
+ *,
145
+ client: AuthenticatedClient,
146
+ body: WebhookEndpointRequest,
147
+ ) -> Response[Problem | WebhookEndpointCreated]:
148
+ """Create a webhook endpoint
149
+
150
+ Subscribes a URL to events. The response carries the signing secret,
151
+ the only time it is shown. Every delivery is a POST signed per Standard
152
+ Webhooks (`webhook-id`, `webhook-timestamp`, `webhook-signature`).
153
+
154
+ **Credits:** free. This endpoint is not metered.
155
+
156
+ Args:
157
+ body (WebhookEndpointRequest): A new endpoint.
158
+
159
+ Raises:
160
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
162
+
163
+ Returns:
164
+ Response[Problem | WebhookEndpointCreated]
165
+ """
166
+
167
+ kwargs = _get_kwargs(
168
+ body=body,
169
+ )
170
+
171
+ response = await client.get_async_httpx_client().request(**kwargs)
172
+
173
+ return _build_response(client=client, response=response)
174
+
175
+
176
+ async def asyncio(
177
+ *,
178
+ client: AuthenticatedClient,
179
+ body: WebhookEndpointRequest,
180
+ ) -> Problem | WebhookEndpointCreated | None:
181
+ """Create a webhook endpoint
182
+
183
+ Subscribes a URL to events. The response carries the signing secret,
184
+ the only time it is shown. Every delivery is a POST signed per Standard
185
+ Webhooks (`webhook-id`, `webhook-timestamp`, `webhook-signature`).
186
+
187
+ **Credits:** free. This endpoint is not metered.
188
+
189
+ Args:
190
+ body (WebhookEndpointRequest): A new endpoint.
191
+
192
+ Raises:
193
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
194
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
195
+
196
+ Returns:
197
+ Problem | WebhookEndpointCreated
198
+ """
199
+
200
+ return (
201
+ await asyncio_detailed(
202
+ client=client,
203
+ body=body,
204
+ )
205
+ ).parsed
@@ -0,0 +1,191 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+ from uuid import UUID
5
+
6
+ import httpx
7
+
8
+ from ... import errors
9
+ from ...client import AuthenticatedClient, Client
10
+ from ...models.problem import Problem
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ endpoint_id: UUID,
16
+ ) -> dict[str, Any]:
17
+
18
+ _kwargs: dict[str, Any] = {
19
+ "method": "delete",
20
+ "url": "/v1/webhooks/{endpoint_id}".format(
21
+ endpoint_id=quote(str(endpoint_id), safe=""),
22
+ ),
23
+ }
24
+
25
+ return _kwargs
26
+
27
+
28
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Problem | None:
29
+ if response.status_code == 204:
30
+ response_204 = cast(Any, None)
31
+ return response_204
32
+
33
+ if response.status_code == 401:
34
+ response_401 = Problem.from_dict(response.json())
35
+
36
+ return response_401
37
+
38
+ if response.status_code == 404:
39
+ response_404 = Problem.from_dict(response.json())
40
+
41
+ return response_404
42
+
43
+ if response.status_code == 422:
44
+ response_422 = Problem.from_dict(response.json())
45
+
46
+ return response_422
47
+
48
+ if response.status_code == 429:
49
+ response_429 = Problem.from_dict(response.json())
50
+
51
+ return response_429
52
+
53
+ if client.raise_on_unexpected_status:
54
+ raise errors.UnexpectedStatus(response.status_code, response.content)
55
+ else:
56
+ return None
57
+
58
+
59
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Problem]:
60
+ return Response(
61
+ status_code=HTTPStatus(response.status_code),
62
+ content=response.content,
63
+ headers=response.headers,
64
+ parsed=_parse_response(client=client, response=response),
65
+ )
66
+
67
+
68
+ def sync_detailed(
69
+ endpoint_id: UUID,
70
+ *,
71
+ client: AuthenticatedClient,
72
+ ) -> Response[Any | Problem]:
73
+ """Delete a webhook endpoint
74
+
75
+ Deletes an endpoint and its delivery history. Pending deliveries are
76
+ not sent.
77
+
78
+ **Credits:** free. This endpoint is not metered.
79
+
80
+ Args:
81
+ endpoint_id (UUID): The endpoint's `id`.
82
+
83
+ Raises:
84
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
85
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
86
+
87
+ Returns:
88
+ Response[Any | Problem]
89
+ """
90
+
91
+ kwargs = _get_kwargs(
92
+ endpoint_id=endpoint_id,
93
+ )
94
+
95
+ response = client.get_httpx_client().request(
96
+ **kwargs,
97
+ )
98
+
99
+ return _build_response(client=client, response=response)
100
+
101
+
102
+ def sync(
103
+ endpoint_id: UUID,
104
+ *,
105
+ client: AuthenticatedClient,
106
+ ) -> Any | Problem | None:
107
+ """Delete a webhook endpoint
108
+
109
+ Deletes an endpoint and its delivery history. Pending deliveries are
110
+ not sent.
111
+
112
+ **Credits:** free. This endpoint is not metered.
113
+
114
+ Args:
115
+ endpoint_id (UUID): The endpoint's `id`.
116
+
117
+ Raises:
118
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
119
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
120
+
121
+ Returns:
122
+ Any | Problem
123
+ """
124
+
125
+ return sync_detailed(
126
+ endpoint_id=endpoint_id,
127
+ client=client,
128
+ ).parsed
129
+
130
+
131
+ async def asyncio_detailed(
132
+ endpoint_id: UUID,
133
+ *,
134
+ client: AuthenticatedClient,
135
+ ) -> Response[Any | Problem]:
136
+ """Delete a webhook endpoint
137
+
138
+ Deletes an endpoint and its delivery history. Pending deliveries are
139
+ not sent.
140
+
141
+ **Credits:** free. This endpoint is not metered.
142
+
143
+ Args:
144
+ endpoint_id (UUID): The endpoint's `id`.
145
+
146
+ Raises:
147
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
148
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
149
+
150
+ Returns:
151
+ Response[Any | Problem]
152
+ """
153
+
154
+ kwargs = _get_kwargs(
155
+ endpoint_id=endpoint_id,
156
+ )
157
+
158
+ response = await client.get_async_httpx_client().request(**kwargs)
159
+
160
+ return _build_response(client=client, response=response)
161
+
162
+
163
+ async def asyncio(
164
+ endpoint_id: UUID,
165
+ *,
166
+ client: AuthenticatedClient,
167
+ ) -> Any | Problem | None:
168
+ """Delete a webhook endpoint
169
+
170
+ Deletes an endpoint and its delivery history. Pending deliveries are
171
+ not sent.
172
+
173
+ **Credits:** free. This endpoint is not metered.
174
+
175
+ Args:
176
+ endpoint_id (UUID): The endpoint's `id`.
177
+
178
+ Raises:
179
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
180
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
181
+
182
+ Returns:
183
+ Any | Problem
184
+ """
185
+
186
+ return (
187
+ await asyncio_detailed(
188
+ endpoint_id=endpoint_id,
189
+ client=client,
190
+ )
191
+ ).parsed
@@ -0,0 +1,159 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.problem import Problem
9
+ from ...models.webhook_endpoint_response_page import WebhookEndpointResponsePage
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs() -> dict[str, Any]:
14
+
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "get",
17
+ "url": "/v1/webhooks",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: AuthenticatedClient | Client, response: httpx.Response
25
+ ) -> Problem | WebhookEndpointResponsePage | None:
26
+ if response.status_code == 200:
27
+ response_200 = WebhookEndpointResponsePage.from_dict(response.json())
28
+
29
+ return response_200
30
+
31
+ if response.status_code == 401:
32
+ response_401 = Problem.from_dict(response.json())
33
+
34
+ return response_401
35
+
36
+ if response.status_code == 429:
37
+ response_429 = Problem.from_dict(response.json())
38
+
39
+ return response_429
40
+
41
+ if client.raise_on_unexpected_status:
42
+ raise errors.UnexpectedStatus(response.status_code, response.content)
43
+ else:
44
+ return None
45
+
46
+
47
+ def _build_response(
48
+ *, client: AuthenticatedClient | Client, response: httpx.Response
49
+ ) -> Response[Problem | WebhookEndpointResponsePage]:
50
+ return Response(
51
+ status_code=HTTPStatus(response.status_code),
52
+ content=response.content,
53
+ headers=response.headers,
54
+ parsed=_parse_response(client=client, response=response),
55
+ )
56
+
57
+
58
+ def sync_detailed(
59
+ *,
60
+ client: AuthenticatedClient,
61
+ ) -> Response[Problem | WebhookEndpointResponsePage]:
62
+ """List your webhook endpoints
63
+
64
+ Lists your webhook endpoints, oldest first. There are at most 10, so
65
+ `next_cursor` is always null.
66
+
67
+ **Credits:** free. This endpoint is not metered.
68
+
69
+ Raises:
70
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
71
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
72
+
73
+ Returns:
74
+ Response[Problem | WebhookEndpointResponsePage]
75
+ """
76
+
77
+ kwargs = _get_kwargs()
78
+
79
+ response = client.get_httpx_client().request(
80
+ **kwargs,
81
+ )
82
+
83
+ return _build_response(client=client, response=response)
84
+
85
+
86
+ def sync(
87
+ *,
88
+ client: AuthenticatedClient,
89
+ ) -> Problem | WebhookEndpointResponsePage | None:
90
+ """List your webhook endpoints
91
+
92
+ Lists your webhook endpoints, oldest first. There are at most 10, so
93
+ `next_cursor` is always null.
94
+
95
+ **Credits:** free. This endpoint is not metered.
96
+
97
+ Raises:
98
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
99
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
100
+
101
+ Returns:
102
+ Problem | WebhookEndpointResponsePage
103
+ """
104
+
105
+ return sync_detailed(
106
+ client=client,
107
+ ).parsed
108
+
109
+
110
+ async def asyncio_detailed(
111
+ *,
112
+ client: AuthenticatedClient,
113
+ ) -> Response[Problem | WebhookEndpointResponsePage]:
114
+ """List your webhook endpoints
115
+
116
+ Lists your webhook endpoints, oldest first. There are at most 10, so
117
+ `next_cursor` is always null.
118
+
119
+ **Credits:** free. This endpoint is not metered.
120
+
121
+ Raises:
122
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
123
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
124
+
125
+ Returns:
126
+ Response[Problem | WebhookEndpointResponsePage]
127
+ """
128
+
129
+ kwargs = _get_kwargs()
130
+
131
+ response = await client.get_async_httpx_client().request(**kwargs)
132
+
133
+ return _build_response(client=client, response=response)
134
+
135
+
136
+ async def asyncio(
137
+ *,
138
+ client: AuthenticatedClient,
139
+ ) -> Problem | WebhookEndpointResponsePage | None:
140
+ """List your webhook endpoints
141
+
142
+ Lists your webhook endpoints, oldest first. There are at most 10, so
143
+ `next_cursor` is always null.
144
+
145
+ **Credits:** free. This endpoint is not metered.
146
+
147
+ Raises:
148
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
149
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
150
+
151
+ Returns:
152
+ Problem | WebhookEndpointResponsePage
153
+ """
154
+
155
+ return (
156
+ await asyncio_detailed(
157
+ client=client,
158
+ )
159
+ ).parsed