fragment-python 1.4.0__tar.gz → 1.4.2__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 (127) hide show
  1. {fragment_python-1.4.0 → fragment_python-1.4.2}/PKG-INFO +3 -4
  2. {fragment_python-1.4.0 → fragment_python-1.4.2}/README.md +2 -2
  3. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/client/async_client.py +7 -7
  4. fragment_python-1.4.2/fragment/client/oauth.py +75 -0
  5. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/client/sync_client.py +7 -5
  6. fragment_python-1.4.2/fragment/exceptions.py +24 -0
  7. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/__init__.py +110 -0
  8. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/async_client.py +7 -7
  9. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/client.py +308 -2
  10. fragment_python-1.4.2/fragment/sdk/create_payment_method_setup.py +93 -0
  11. fragment_python-1.4.2/fragment/sdk/delete_payment_method.py +38 -0
  12. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/enums.py +8 -0
  13. fragment_python-1.4.2/fragment/sdk/get_payment_method.py +39 -0
  14. fragment_python-1.4.2/fragment/sdk/get_payment_method_setup.py +58 -0
  15. {fragment_python-1.4.0/fragment/sync_sdk → fragment_python-1.4.2/fragment/sdk}/input_types.py +117 -18
  16. fragment_python-1.4.2/fragment/sdk/list_payment_methods.py +52 -0
  17. fragment_python-1.4.2/fragment/sdk/sync_custom_accounts_by_link_ik.py +61 -0
  18. fragment_python-1.4.2/fragment/sdk/sync_custom_txs_by_link_ik.py +50 -0
  19. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/std_queries/queries.graphql +209 -1
  20. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/__init__.py +110 -0
  21. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/async_client.py +7 -7
  22. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/client.py +306 -2
  23. fragment_python-1.4.2/fragment/sync_sdk/create_payment_method_setup.py +93 -0
  24. fragment_python-1.4.2/fragment/sync_sdk/delete_payment_method.py +38 -0
  25. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/enums.py +8 -0
  26. fragment_python-1.4.2/fragment/sync_sdk/get_payment_method.py +39 -0
  27. fragment_python-1.4.2/fragment/sync_sdk/get_payment_method_setup.py +58 -0
  28. {fragment_python-1.4.0/fragment/sdk → fragment_python-1.4.2/fragment/sync_sdk}/input_types.py +117 -18
  29. fragment_python-1.4.2/fragment/sync_sdk/list_payment_methods.py +52 -0
  30. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/sync_client.py +7 -5
  31. fragment_python-1.4.2/fragment/sync_sdk/sync_custom_accounts_by_link_ik.py +61 -0
  32. fragment_python-1.4.2/fragment/sync_sdk/sync_custom_txs_by_link_ik.py +50 -0
  33. {fragment_python-1.4.0 → fragment_python-1.4.2}/pyproject.toml +1 -2
  34. fragment_python-1.4.0/fragment/exceptions.py +0 -12
  35. {fragment_python-1.4.0 → fragment_python-1.4.2}/LICENSE +0 -0
  36. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/__init__.py +0 -0
  37. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/client/__init__.py +0 -0
  38. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/codegen/__init__.py +0 -0
  39. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/codegen/helpers.py +0 -0
  40. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/codegen/main.py +0 -0
  41. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/codegen/plugins/__init__.py +0 -0
  42. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/codegen/plugins/generate_client_method.py +0 -0
  43. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/codegen/plugins/generate_typed_entries.py +0 -0
  44. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/codegen/plugins/get_file_comment.py +0 -0
  45. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/codegen/typed_entries.py +0 -0
  46. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/logger.py +0 -0
  47. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/py.typed +0 -0
  48. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/add_ledger_entries.py +0 -0
  49. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/add_ledger_entry.py +0 -0
  50. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/add_ledger_entry_runtime.py +0 -0
  51. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/base_model.py +0 -0
  52. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/create_custom_currency.py +0 -0
  53. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/create_custom_link.py +0 -0
  54. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/create_ledger.py +0 -0
  55. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/create_payment.py +0 -0
  56. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/delete_custom_txs.py +0 -0
  57. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/delete_ledger.py +0 -0
  58. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/delete_schema.py +0 -0
  59. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_account_data_migrations.py +0 -0
  60. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_entries_to_migrate_for_ledger_account_data_migration.py +0 -0
  61. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_entries_to_migrate_for_ledger_entry_data_migration.py +0 -0
  62. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_entry_data_migrations.py +0 -0
  63. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_ledger.py +0 -0
  64. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_ledger_account_balance.py +0 -0
  65. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_ledger_account_balance_with_child_rollup.py +0 -0
  66. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_ledger_account_lines.py +0 -0
  67. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_ledger_entry.py +0 -0
  68. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_payment.py +0 -0
  69. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_schema.py +0 -0
  70. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/get_workspace.py +0 -0
  71. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/instantiate_ledger_account.py +0 -0
  72. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/list_ledger_account_balances.py +0 -0
  73. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/list_ledger_accounts.py +0 -0
  74. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/list_ledger_entries.py +0 -0
  75. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/list_ledger_entry_group_balances.py +0 -0
  76. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/list_multi_currency_ledger_account_balances.py +0 -0
  77. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/list_payments.py +0 -0
  78. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/migrate_ledger_entry.py +0 -0
  79. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/reconcile_tx.py +0 -0
  80. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/reconcile_tx_runtime.py +0 -0
  81. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/reverse_ledger_entry.py +0 -0
  82. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/store_schema.py +0 -0
  83. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/sync_custom_accounts.py +0 -0
  84. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/sync_custom_txs.py +0 -0
  85. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/typed_entries.py +0 -0
  86. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/update_ledger.py +0 -0
  87. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sdk/update_ledger_entry.py +0 -0
  88. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/add_ledger_entries.py +0 -0
  89. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/add_ledger_entry.py +0 -0
  90. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/add_ledger_entry_runtime.py +0 -0
  91. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/base_model.py +0 -0
  92. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/create_custom_currency.py +0 -0
  93. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/create_custom_link.py +0 -0
  94. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/create_ledger.py +0 -0
  95. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/create_payment.py +0 -0
  96. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/delete_custom_txs.py +0 -0
  97. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/delete_ledger.py +0 -0
  98. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/delete_schema.py +0 -0
  99. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_account_data_migrations.py +0 -0
  100. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_entries_to_migrate_for_ledger_account_data_migration.py +0 -0
  101. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_entries_to_migrate_for_ledger_entry_data_migration.py +0 -0
  102. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_entry_data_migrations.py +0 -0
  103. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_ledger.py +0 -0
  104. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_ledger_account_balance.py +0 -0
  105. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_ledger_account_balance_with_child_rollup.py +0 -0
  106. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_ledger_account_lines.py +0 -0
  107. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_ledger_entry.py +0 -0
  108. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_payment.py +0 -0
  109. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_schema.py +0 -0
  110. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/get_workspace.py +0 -0
  111. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/instantiate_ledger_account.py +0 -0
  112. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/list_ledger_account_balances.py +0 -0
  113. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/list_ledger_accounts.py +0 -0
  114. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/list_ledger_entries.py +0 -0
  115. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/list_ledger_entry_group_balances.py +0 -0
  116. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/list_multi_currency_ledger_account_balances.py +0 -0
  117. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/list_payments.py +0 -0
  118. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/migrate_ledger_entry.py +0 -0
  119. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/reconcile_tx.py +0 -0
  120. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/reconcile_tx_runtime.py +0 -0
  121. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/reverse_ledger_entry.py +0 -0
  122. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/store_schema.py +0 -0
  123. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/sync_custom_accounts.py +0 -0
  124. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/sync_custom_txs.py +0 -0
  125. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/typed_entries.py +0 -0
  126. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/update_ledger.py +0 -0
  127. {fragment_python-1.4.0 → fragment_python-1.4.2}/fragment/sync_sdk/update_ledger_entry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fragment-python
3
- Version: 1.4.0
3
+ Version: 1.4.2
4
4
  Summary: Python SDK for https://fragment.dev/
5
5
  License: Apache 2.0
6
6
  License-File: LICENSE
@@ -15,7 +15,6 @@ Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Programming Language :: Python :: 3.14
16
16
  Classifier: Programming Language :: Python :: 3.15
17
17
  Requires-Dist: ariadne-codegen (>=0.17.2,<0.18.0)
18
- Requires-Dist: authlib (>=1.6.12,<2.0.0)
19
18
  Requires-Dist: click (>=8.1.7,<9.0.0)
20
19
  Requires-Dist: graphql-core (>=3.2.3,<4.0.0)
21
20
  Requires-Dist: httpx (>=0.28.1,<0.29.0)
@@ -99,7 +98,7 @@ To [post](https://fragment.dev/guides/post-ledger-entries#post-to-the-api) a Led
99
98
  await graphql_client.add_ledger_entry(
100
99
  ik="some-ik",
101
100
  ledger_ik="your-ledger-ik",
102
- type="user_funds_account",
101
+ type_="user_funds_account",
103
102
  posted="1968-01-01T16:45:00Z",
104
103
  parameters=dict(
105
104
  user_id="user-1",
@@ -192,6 +191,6 @@ async def print_schema_name():
192
191
 
193
192
  import asyncio
194
193
  loop = asyncio.get_event_loop()
195
- loop.run_until_complete(print_schema())
194
+ loop.run_until_complete(print_schema_name())
196
195
  ```
197
196
 
@@ -74,7 +74,7 @@ To [post](https://fragment.dev/guides/post-ledger-entries#post-to-the-api) a Led
74
74
  await graphql_client.add_ledger_entry(
75
75
  ik="some-ik",
76
76
  ledger_ik="your-ledger-ik",
77
- type="user_funds_account",
77
+ type_="user_funds_account",
78
78
  posted="1968-01-01T16:45:00Z",
79
79
  parameters=dict(
80
80
  user_id="user-1",
@@ -167,5 +167,5 @@ async def print_schema_name():
167
167
 
168
168
  import asyncio
169
169
  loop = asyncio.get_event_loop()
170
- loop.run_until_complete(print_schema())
170
+ loop.run_until_complete(print_schema_name())
171
171
  ```
@@ -1,5 +1,3 @@
1
- # Ignore untyped authlib
2
- # mypy: disable-error-code="import-untyped"
3
1
  import time
4
2
  from typing import Any, Dict, Optional
5
3
 
@@ -7,8 +5,8 @@ import httpx
7
5
  from ariadne_codegen.client_generators.dependencies.async_base_client import (
8
6
  AsyncBaseClient,
9
7
  )
10
- from authlib.integrations.httpx_client import AsyncOAuth2Client
11
8
 
9
+ from fragment.client.oauth import fetch_token_async
12
10
  from fragment.exceptions import MissingArgumentException, MissingTokenException
13
11
 
14
12
 
@@ -37,16 +35,18 @@ class AsyncFragmentClient(AsyncBaseClient):
37
35
  self.auth_url = auth_url
38
36
  self.expiration_time: Optional[float] = None
39
37
  self.token: Optional[Dict[str, Any]] = None
40
- self.oauth2_client = AsyncOAuth2Client(
41
- client_id, client_secret, scope=auth_scope
42
- )
38
+ self.client_id = client_id
39
+ self.client_secret = client_secret
40
+ self.auth_scope = auth_scope
43
41
 
44
42
  async def refresh_token(self) -> None:
45
43
  now = time.time()
46
44
  if self.expiration_time is None or self.expiration_time <= now:
47
45
  # Held in a local because `self.token` is declared `dict | None`,
48
46
  # so reading the attribute back is not narrowed by the assignment.
49
- token = await self.oauth2_client.fetch_token(self.auth_url)
47
+ token = await fetch_token_async(
48
+ self.auth_url, self.client_id, self.client_secret, self.auth_scope
49
+ )
50
50
  self.token = token
51
51
  self.expiration_time = now + token["expires_in"]
52
52
 
@@ -0,0 +1,75 @@
1
+ """OAuth2 client-credentials token request against the Fragment auth endpoint.
2
+
3
+ The SDK needs exactly one OAuth2 call: exchange a client ID and secret for an
4
+ access token. That is a single form POST, so it is made with httpx directly
5
+ rather than through an OAuth library, whose much larger surface (JOSE, OIDC,
6
+ server-side grants) customers would otherwise inherit, along with its
7
+ advisories.
8
+
9
+ The request matches what authlib's httpx `OAuth2Client.fetch_token` sent:
10
+ HTTP Basic client authentication (`client_secret_basic`) and a form body of
11
+ `grant_type=client_credentials` and `scope`.
12
+ """
13
+
14
+ from typing import Any, Dict
15
+
16
+ import httpx
17
+
18
+ from fragment.exceptions import TokenRequestException
19
+
20
+ _HEADERS = {
21
+ "Accept": "application/json",
22
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
23
+ }
24
+
25
+
26
+ def _token_request_kwargs(
27
+ client_id: str, client_secret: str, scope: str
28
+ ) -> Dict[str, Any]:
29
+ return dict(
30
+ data={"grant_type": "client_credentials", "scope": scope},
31
+ auth=httpx.BasicAuth(client_id, client_secret),
32
+ headers=_HEADERS,
33
+ )
34
+
35
+
36
+ def _parse_token_response(response: httpx.Response) -> Dict[str, Any]:
37
+ if response.status_code >= 500:
38
+ response.raise_for_status()
39
+ try:
40
+ token = response.json()
41
+ except ValueError as e:
42
+ raise TokenRequestException(
43
+ f"token endpoint returned a non-JSON response "
44
+ f"(HTTP {response.status_code})"
45
+ ) from e
46
+ if not isinstance(token, dict):
47
+ raise TokenRequestException("token endpoint returned a non-object response")
48
+ if "error" in token:
49
+ raise TokenRequestException(token["error"], token.get("error_description"))
50
+ if "access_token" not in token or "expires_in" not in token:
51
+ raise TokenRequestException(
52
+ f"token endpoint response is missing access_token or expires_in "
53
+ f"(HTTP {response.status_code})"
54
+ )
55
+ return token
56
+
57
+
58
+ def fetch_token(
59
+ auth_url: str, client_id: str, client_secret: str, scope: str
60
+ ) -> Dict[str, Any]:
61
+ with httpx.Client() as client:
62
+ response = client.post(
63
+ auth_url, **_token_request_kwargs(client_id, client_secret, scope)
64
+ )
65
+ return _parse_token_response(response)
66
+
67
+
68
+ async def fetch_token_async(
69
+ auth_url: str, client_id: str, client_secret: str, scope: str
70
+ ) -> Dict[str, Any]:
71
+ async with httpx.AsyncClient() as client:
72
+ response = await client.post(
73
+ auth_url, **_token_request_kwargs(client_id, client_secret, scope)
74
+ )
75
+ return _parse_token_response(response)
@@ -1,12 +1,10 @@
1
- # Ignore untyped authlib
2
- # mypy: disable-error-code="import-untyped"
3
1
  import time
4
2
  from typing import Any, Dict, Optional
5
3
 
6
4
  import httpx
7
5
  from ariadne_codegen.client_generators.dependencies.base_client import BaseClient
8
- from authlib.integrations.httpx_client import OAuth2Client
9
6
 
7
+ from fragment.client.oauth import fetch_token
10
8
  from fragment.exceptions import MissingArgumentException, MissingTokenException
11
9
 
12
10
 
@@ -35,14 +33,18 @@ class SyncFragmentClient(BaseClient):
35
33
  self.auth_url = auth_url
36
34
  self.expiration_time: Optional[float] = None
37
35
  self.token: Optional[Dict[str, Any]] = None
38
- self.oauth2_client = OAuth2Client(client_id, client_secret, scope=auth_scope)
36
+ self.client_id = client_id
37
+ self.client_secret = client_secret
38
+ self.auth_scope = auth_scope
39
39
 
40
40
  def refresh_token(self) -> None:
41
41
  now = time.time()
42
42
  if self.expiration_time is None or self.expiration_time <= now:
43
43
  # Held in a local because `self.token` is declared `dict | None`,
44
44
  # so reading the attribute back is not narrowed by the assignment.
45
- token = self.oauth2_client.fetch_token(self.auth_url)
45
+ token = fetch_token(
46
+ self.auth_url, self.client_id, self.client_secret, self.auth_scope
47
+ )
46
48
  self.token = token
47
49
  self.expiration_time = now + token["expires_in"]
48
50
 
@@ -0,0 +1,24 @@
1
+ from typing import Optional
2
+
3
+
4
+ class MissingTokenException(ValueError):
5
+ """Token not found."""
6
+
7
+ def __init__(self) -> None:
8
+ super().__init__("Token is None")
9
+
10
+
11
+ class MissingArgumentException(ValueError):
12
+ """Argument not present."""
13
+
14
+ def __init__(self, argument: str) -> None:
15
+ super().__init__(f"{argument} must be provided")
16
+
17
+
18
+ class TokenRequestException(Exception):
19
+ """The auth endpoint did not return an access token."""
20
+
21
+ def __init__(self, error: str, description: Optional[str] = None) -> None:
22
+ self.error = error
23
+ self.description = description
24
+ super().__init__(f"{error}: {description}" if description else error)
@@ -63,6 +63,16 @@ from .create_payment import (
63
63
  CreatePaymentCreatePaymentCreatePaymentResultPaymentCurrency,
64
64
  CreatePaymentCreatePaymentInternalError,
65
65
  )
66
+ from .create_payment_method_setup import (
67
+ CreatePaymentMethodSetup,
68
+ CreatePaymentMethodSetupCreatePaymentMethodSetupBadRequestError,
69
+ CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResult,
70
+ CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResultPaymentMethodSetup,
71
+ CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResultPaymentMethodSetupCurrency,
72
+ CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResultPaymentMethodSetupPaymentMethodCardPaymentMethod,
73
+ CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResultPaymentMethodSetupPaymentMethodPaymentMethod,
74
+ CreatePaymentMethodSetupCreatePaymentMethodSetupInternalError,
75
+ )
66
76
  from .delete_custom_txs import (
67
77
  DeleteCustomTxs,
68
78
  DeleteCustomTxsDeleteCustomTxsBadRequestError,
@@ -77,6 +87,12 @@ from .delete_ledger import (
77
87
  DeleteLedgerDeleteLedgerDeleteLedgerResult,
78
88
  DeleteLedgerDeleteLedgerInternalError,
79
89
  )
90
+ from .delete_payment_method import (
91
+ DeletePaymentMethod,
92
+ DeletePaymentMethodDeletePaymentMethodBadRequestError,
93
+ DeletePaymentMethodDeletePaymentMethodDeletePaymentMethodResult,
94
+ DeletePaymentMethodDeletePaymentMethodInternalError,
95
+ )
80
96
  from .delete_schema import (
81
97
  DeleteSchema,
82
98
  DeleteSchemaDeleteSchemaBadRequestError,
@@ -99,6 +115,7 @@ from .enums import (
99
115
  LedgerTypes,
100
116
  LinkType,
101
117
  PaymentCurrencyCode,
118
+ PaymentMethodSetupStatus,
102
119
  PaymentMode,
103
120
  PaymentStatus,
104
121
  PostLinesAs,
@@ -187,10 +204,25 @@ from .get_ledger_entry import (
187
204
  GetLedgerEntryLedgerEntryLinesNodesAccount,
188
205
  )
189
206
  from .get_payment import GetPayment, GetPaymentPayment, GetPaymentPaymentCurrency
207
+ from .get_payment_method import (
208
+ GetPaymentMethod,
209
+ GetPaymentMethodPaymentMethodCardPaymentMethod,
210
+ GetPaymentMethodPaymentMethodPaymentMethod,
211
+ )
212
+ from .get_payment_method_setup import (
213
+ GetPaymentMethodSetup,
214
+ GetPaymentMethodSetupPaymentMethodSetup,
215
+ GetPaymentMethodSetupPaymentMethodSetupCurrency,
216
+ GetPaymentMethodSetupPaymentMethodSetupPaymentMethodCardPaymentMethod,
217
+ GetPaymentMethodSetupPaymentMethodSetupPaymentMethodPaymentMethod,
218
+ )
190
219
  from .get_schema import GetSchema, GetSchemaSchema, GetSchemaSchemaVersion
191
220
  from .get_workspace import GetWorkspace, GetWorkspaceWorkspace
192
221
  from .input_types import (
193
222
  AddLedgerEntryInput,
223
+ AgingClearingAccountsFilterSet,
224
+ AgingClearingAccountsInput,
225
+ AgingUnreconciledTxsInput,
194
226
  ChartOfAccountsInput,
195
227
  CreateCustomCurrencyInput,
196
228
  CreateLedgerAccountInput,
@@ -203,6 +235,7 @@ from .input_types import (
203
235
  CustomTxInput,
204
236
  DateFilter,
205
237
  DateTimeFilter,
238
+ EmailFilter,
206
239
  EntryGroupMatchInput,
207
240
  ExternalAccountFilter,
208
241
  ExternalAccountMatchInput,
@@ -223,6 +256,7 @@ from .input_types import (
223
256
  LedgerAccountMatchInput,
224
257
  LedgerAccountsFilterSet,
225
258
  LedgerAccountTypeFilter,
259
+ LedgerAccountUnreconciledTxsFilterSet,
226
260
  LedgerEntriesFilterSet,
227
261
  LedgerEntryConditionInput,
228
262
  LedgerEntryDataMigrationsFilterSet,
@@ -242,9 +276,13 @@ from .input_types import (
242
276
  LedgerMatchInput,
243
277
  LedgersFilterSet,
244
278
  LedgerTypeFilter,
279
+ LedgerUnreconciledTxsFilterSet,
245
280
  LinkMatchInput,
246
281
  MigrateLedgerEntryInput,
247
282
  PaymentMatchInput,
283
+ PaymentMethodMatchInput,
284
+ PaymentMethodSetupMatchInput,
285
+ PaymentMethodsFilterSet,
248
286
  PaymentsFilterSet,
249
287
  PaymentStatusFilter,
250
288
  SceneEntryInput,
@@ -286,6 +324,8 @@ from .input_types import (
286
324
  UpdateLedgerEntryInput,
287
325
  UpdateLedgerInput,
288
326
  UpdateLedgerLineInput,
327
+ UserFilter,
328
+ UserMatchInput,
289
329
  )
290
330
  from .instantiate_ledger_account import (
291
331
  InstantiateLedgerAccount,
@@ -343,6 +383,13 @@ from .list_multi_currency_ledger_account_balances import (
343
383
  ListMultiCurrencyLedgerAccountBalancesLedgerLedgerAccountsNodesOwnBalancesNodesCurrency,
344
384
  ListMultiCurrencyLedgerAccountBalancesLedgerLedgerAccountsPageInfo,
345
385
  )
386
+ from .list_payment_methods import (
387
+ ListPaymentMethods,
388
+ ListPaymentMethodsPaymentMethods,
389
+ ListPaymentMethodsPaymentMethodsNodesCardPaymentMethod,
390
+ ListPaymentMethodsPaymentMethodsNodesPaymentMethod,
391
+ ListPaymentMethodsPaymentMethodsPageInfo,
392
+ )
346
393
  from .list_payments import (
347
394
  ListPayments,
348
395
  ListPaymentsLedger,
@@ -417,6 +464,14 @@ from .sync_custom_accounts import (
417
464
  SyncCustomAccountsSyncCustomAccountsSyncCustomAccountsResultAccounts,
418
465
  SyncCustomAccountsSyncCustomAccountsSyncCustomAccountsResultAccountsCurrency,
419
466
  )
467
+ from .sync_custom_accounts_by_link_ik import (
468
+ SyncCustomAccountsByLinkIk,
469
+ SyncCustomAccountsByLinkIkSyncCustomAccountsBadRequestError,
470
+ SyncCustomAccountsByLinkIkSyncCustomAccountsInternalError,
471
+ SyncCustomAccountsByLinkIkSyncCustomAccountsSyncCustomAccountsResult,
472
+ SyncCustomAccountsByLinkIkSyncCustomAccountsSyncCustomAccountsResultAccounts,
473
+ SyncCustomAccountsByLinkIkSyncCustomAccountsSyncCustomAccountsResultAccountsCurrency,
474
+ )
420
475
  from .sync_custom_txs import (
421
476
  SyncCustomTxs,
422
477
  SyncCustomTxsSyncCustomTxsBadRequestError,
@@ -424,6 +479,13 @@ from .sync_custom_txs import (
424
479
  SyncCustomTxsSyncCustomTxsSyncCustomTxsResult,
425
480
  SyncCustomTxsSyncCustomTxsSyncCustomTxsResultTxs,
426
481
  )
482
+ from .sync_custom_txs_by_link_ik import (
483
+ SyncCustomTxsByLinkIk,
484
+ SyncCustomTxsByLinkIkSyncCustomTxsBadRequestError,
485
+ SyncCustomTxsByLinkIkSyncCustomTxsInternalError,
486
+ SyncCustomTxsByLinkIkSyncCustomTxsSyncCustomTxsResult,
487
+ SyncCustomTxsByLinkIkSyncCustomTxsSyncCustomTxsResultTxs,
488
+ )
427
489
  from .update_ledger import (
428
490
  UpdateLedger,
429
491
  UpdateLedgerUpdateLedgerBadRequestError,
@@ -470,6 +532,9 @@ __all__ = [
470
532
  "AddLedgerEntryRuntimeAddLedgerEntryAddLedgerEntryResultLinesAccount",
471
533
  "AddLedgerEntryRuntimeAddLedgerEntryBadRequestError",
472
534
  "AddLedgerEntryRuntimeAddLedgerEntryInternalError",
535
+ "AgingClearingAccountsFilterSet",
536
+ "AgingClearingAccountsInput",
537
+ "AgingUnreconciledTxsInput",
473
538
  "AsyncFragmentClient",
474
539
  "BalanceUpdateConsistencyMode",
475
540
  "BaseModel",
@@ -502,6 +567,14 @@ __all__ = [
502
567
  "CreatePaymentCreatePaymentCreatePaymentResultPaymentCurrency",
503
568
  "CreatePaymentCreatePaymentInternalError",
504
569
  "CreatePaymentInput",
570
+ "CreatePaymentMethodSetup",
571
+ "CreatePaymentMethodSetupCreatePaymentMethodSetupBadRequestError",
572
+ "CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResult",
573
+ "CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResultPaymentMethodSetup",
574
+ "CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResultPaymentMethodSetupCurrency",
575
+ "CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResultPaymentMethodSetupPaymentMethodCardPaymentMethod",
576
+ "CreatePaymentMethodSetupCreatePaymentMethodSetupCreatePaymentMethodSetupResultPaymentMethodSetupPaymentMethodPaymentMethod",
577
+ "CreatePaymentMethodSetupCreatePaymentMethodSetupInternalError",
505
578
  "CurrencyCode",
506
579
  "CurrencyFilter",
507
580
  "CurrencyMatchInput",
@@ -520,10 +593,15 @@ __all__ = [
520
593
  "DeleteLedgerDeleteLedgerBadRequestError",
521
594
  "DeleteLedgerDeleteLedgerDeleteLedgerResult",
522
595
  "DeleteLedgerDeleteLedgerInternalError",
596
+ "DeletePaymentMethod",
597
+ "DeletePaymentMethodDeletePaymentMethodBadRequestError",
598
+ "DeletePaymentMethodDeletePaymentMethodDeletePaymentMethodResult",
599
+ "DeletePaymentMethodDeletePaymentMethodInternalError",
523
600
  "DeleteSchema",
524
601
  "DeleteSchemaDeleteSchemaBadRequestError",
525
602
  "DeleteSchemaDeleteSchemaDeleteSchemaResult",
526
603
  "DeleteSchemaDeleteSchemaInternalError",
604
+ "EmailFilter",
527
605
  "EntryGroupMatchInput",
528
606
  "ExternalAccountFilter",
529
607
  "ExternalAccountMatchInput",
@@ -588,6 +666,14 @@ __all__ = [
588
666
  "GetLedgerEntryLedgerEntryLinesNodesAccount",
589
667
  "GetLedgerLedger",
590
668
  "GetPayment",
669
+ "GetPaymentMethod",
670
+ "GetPaymentMethodPaymentMethodCardPaymentMethod",
671
+ "GetPaymentMethodPaymentMethodPaymentMethod",
672
+ "GetPaymentMethodSetup",
673
+ "GetPaymentMethodSetupPaymentMethodSetup",
674
+ "GetPaymentMethodSetupPaymentMethodSetupCurrency",
675
+ "GetPaymentMethodSetupPaymentMethodSetupPaymentMethodCardPaymentMethod",
676
+ "GetPaymentMethodSetupPaymentMethodSetupPaymentMethodPaymentMethod",
591
677
  "GetPaymentPayment",
592
678
  "GetPaymentPaymentCurrency",
593
679
  "GetSchema",
@@ -620,6 +706,7 @@ __all__ = [
620
706
  "LedgerAccountMatchInput",
621
707
  "LedgerAccountTypeFilter",
622
708
  "LedgerAccountTypes",
709
+ "LedgerAccountUnreconciledTxsFilterSet",
623
710
  "LedgerAccountsFilterSet",
624
711
  "LedgerDataMigrationStatus",
625
712
  "LedgerEntriesFilterSet",
@@ -643,6 +730,7 @@ __all__ = [
643
730
  "LedgerMigrationStatus",
644
731
  "LedgerTypeFilter",
645
732
  "LedgerTypes",
733
+ "LedgerUnreconciledTxsFilterSet",
646
734
  "LedgersFilterSet",
647
735
  "LinkMatchInput",
648
736
  "LinkType",
@@ -685,6 +773,11 @@ __all__ = [
685
773
  "ListMultiCurrencyLedgerAccountBalancesLedgerLedgerAccountsNodesOwnBalancesNodes",
686
774
  "ListMultiCurrencyLedgerAccountBalancesLedgerLedgerAccountsNodesOwnBalancesNodesCurrency",
687
775
  "ListMultiCurrencyLedgerAccountBalancesLedgerLedgerAccountsPageInfo",
776
+ "ListPaymentMethods",
777
+ "ListPaymentMethodsPaymentMethods",
778
+ "ListPaymentMethodsPaymentMethodsNodesCardPaymentMethod",
779
+ "ListPaymentMethodsPaymentMethodsNodesPaymentMethod",
780
+ "ListPaymentMethodsPaymentMethodsPageInfo",
688
781
  "ListPayments",
689
782
  "ListPaymentsLedger",
690
783
  "ListPaymentsLedgerPayments",
@@ -710,6 +803,10 @@ __all__ = [
710
803
  "MigrateLedgerEntryMigrateLedgerEntryMigrateLedgerEntryResultReversingLedgerEntryLinesNodesAccount",
711
804
  "PaymentCurrencyCode",
712
805
  "PaymentMatchInput",
806
+ "PaymentMethodMatchInput",
807
+ "PaymentMethodSetupMatchInput",
808
+ "PaymentMethodSetupStatus",
809
+ "PaymentMethodsFilterSet",
713
810
  "PaymentMode",
714
811
  "PaymentStatus",
715
812
  "PaymentStatusFilter",
@@ -789,12 +886,23 @@ __all__ = [
789
886
  "StringMatchFilter",
790
887
  "StripeEnv",
791
888
  "SyncCustomAccounts",
889
+ "SyncCustomAccountsByLinkIk",
890
+ "SyncCustomAccountsByLinkIkSyncCustomAccountsBadRequestError",
891
+ "SyncCustomAccountsByLinkIkSyncCustomAccountsInternalError",
892
+ "SyncCustomAccountsByLinkIkSyncCustomAccountsSyncCustomAccountsResult",
893
+ "SyncCustomAccountsByLinkIkSyncCustomAccountsSyncCustomAccountsResultAccounts",
894
+ "SyncCustomAccountsByLinkIkSyncCustomAccountsSyncCustomAccountsResultAccountsCurrency",
792
895
  "SyncCustomAccountsSyncCustomAccountsBadRequestError",
793
896
  "SyncCustomAccountsSyncCustomAccountsInternalError",
794
897
  "SyncCustomAccountsSyncCustomAccountsSyncCustomAccountsResult",
795
898
  "SyncCustomAccountsSyncCustomAccountsSyncCustomAccountsResultAccounts",
796
899
  "SyncCustomAccountsSyncCustomAccountsSyncCustomAccountsResultAccountsCurrency",
797
900
  "SyncCustomTxs",
901
+ "SyncCustomTxsByLinkIk",
902
+ "SyncCustomTxsByLinkIkSyncCustomTxsBadRequestError",
903
+ "SyncCustomTxsByLinkIkSyncCustomTxsInternalError",
904
+ "SyncCustomTxsByLinkIkSyncCustomTxsSyncCustomTxsResult",
905
+ "SyncCustomTxsByLinkIkSyncCustomTxsSyncCustomTxsResultTxs",
798
906
  "SyncCustomTxsSyncCustomTxsBadRequestError",
799
907
  "SyncCustomTxsSyncCustomTxsInternalError",
800
908
  "SyncCustomTxsSyncCustomTxsSyncCustomTxsResult",
@@ -825,6 +933,8 @@ __all__ = [
825
933
  "UpdateLedgerUpdateLedgerUpdateLedgerResult",
826
934
  "UpdateLedgerUpdateLedgerUpdateLedgerResultLedger",
827
935
  "Upload",
936
+ "UserFilter",
937
+ "UserMatchInput",
828
938
  ]
829
939
 
830
940
  from .typed_entries import TypedLedgerEntry, to_entry_inputs
@@ -1,7 +1,5 @@
1
1
  # Generated by fragment (with the help of ariadne-codegen)
2
2
 
3
- # Ignore untyped authlib
4
- # mypy: disable-error-code="import-untyped"
5
3
  import time
6
4
  from typing import Any, Dict, Optional
7
5
 
@@ -9,8 +7,8 @@ import httpx
9
7
  from ariadne_codegen.client_generators.dependencies.async_base_client import (
10
8
  AsyncBaseClient,
11
9
  )
12
- from authlib.integrations.httpx_client import AsyncOAuth2Client
13
10
 
11
+ from fragment.client.oauth import fetch_token_async
14
12
  from fragment.exceptions import MissingArgumentException, MissingTokenException
15
13
 
16
14
 
@@ -39,16 +37,18 @@ class AsyncFragmentClient(AsyncBaseClient):
39
37
  self.auth_url = auth_url
40
38
  self.expiration_time: Optional[float] = None
41
39
  self.token: Optional[Dict[str, Any]] = None
42
- self.oauth2_client = AsyncOAuth2Client(
43
- client_id, client_secret, scope=auth_scope
44
- )
40
+ self.client_id = client_id
41
+ self.client_secret = client_secret
42
+ self.auth_scope = auth_scope
45
43
 
46
44
  async def refresh_token(self) -> None:
47
45
  now = time.time()
48
46
  if self.expiration_time is None or self.expiration_time <= now:
49
47
  # Held in a local because `self.token` is declared `dict | None`,
50
48
  # so reading the attribute back is not narrowed by the assignment.
51
- token = await self.oauth2_client.fetch_token(self.auth_url)
49
+ token = await fetch_token_async(
50
+ self.auth_url, self.client_id, self.client_secret, self.auth_scope
51
+ )
52
52
  self.token = token
53
53
  self.expiration_time = now + token["expires_in"]
54
54