daichodo 0.1.0__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.
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.1
2
+ Name: daichodo
3
+ Version: 0.1.0
4
+ Summary: A client library for accessing Daichodo
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: httpx<0.29.0,>=0.23.1
7
+ Requires-Dist: attrs>=22.2.0
8
+ Description-Content-Type: text/markdown
9
+
10
+ # daichodo
11
+
12
+ Daichodo API の Python クライアント。適格請求書発行事業者(インボイス)登録番号と
13
+ 法人番号を照会します。
14
+
15
+ Python client for the [Daichodo](https://daichodo.com) API — Japanese qualified
16
+ invoice issuer (適格請求書発行事業者) and corporate number (法人番号) lookup,
17
+ validation, and point-in-time validity.
18
+
19
+ > **⚠️ API はまだ一般公開されていません。**
20
+ > このパッケージは API の公開前に名前を確保するために公開されています。現時点では
21
+ > 呼び出しても接続できません。公開時期は [daichodo.com](https://daichodo.com) を
22
+ > ご確認ください。
23
+ >
24
+ > **⚠️ The API is not publicly available yet.**
25
+ > This package is published ahead of the service to reserve the name. Calls will
26
+ > not connect until the API launches — see
27
+ > [daichodo.com](https://daichodo.com) for availability.
28
+ >
29
+ > **APIキーが不要な検証だけであれば
30
+ > [`daichodo-validate`](https://pypi.org/project/daichodo-validate/)
31
+ > が今すぐ利用できます。**
32
+ > If you only need format and check-digit validation,
33
+ > [`daichodo-validate`](https://pypi.org/project/daichodo-validate/) works today
34
+ > with no API key.
35
+
36
+ ```bash
37
+ pip install daichodo
38
+ ```
39
+
40
+ ```python
41
+ from daichodo import AuthenticatedClient
42
+ from daichodo.api.registry import get_invoice_issuer
43
+
44
+ client = AuthenticatedClient(
45
+ base_url="https://api.daichodo.com",
46
+ token="dc_live_...",
47
+ )
48
+
49
+ issuer = get_invoice_issuer.sync(client=client, registration_number="T1010001153225")
50
+ ```
51
+
52
+ ## `name` が None でもエラーではありません / `name` is None for sole traders
53
+
54
+ 国税庁は個人事業主の氏名・住所を公表データから除外しています。個人事業主のレコードは
55
+ 日付を保持したまま**氏名が None** で返ります。`name is None` を「該当なし」と解釈する
56
+ のが最も多い誤りで、登録簿の約半数を無言で切り捨てることになります。
57
+
58
+ The NTA strips identity fields for individuals at source, so a sole trader
59
+ returns their dates with **no name**. Treating `name is None` as "not found" is
60
+ the most common way to get this wrong, and it silently discards about half the
61
+ register.
62
+
63
+ ## 生成コードです / This code is generated
64
+
65
+ API の OpenAPI スキーマから自動生成され、リリースごとに上書きされます。
66
+ プルリクエストは受け付けられません。不具合は
67
+ [Issue](https://github.com/daichodo/daichodo-python/issues) でご報告ください。
68
+
69
+ Generated from the API's OpenAPI schema and overwritten on every release.
70
+
71
+ ## ライセンス / Licence
72
+
73
+ MIT.
@@ -0,0 +1,64 @@
1
+ # daichodo
2
+
3
+ Daichodo API の Python クライアント。適格請求書発行事業者(インボイス)登録番号と
4
+ 法人番号を照会します。
5
+
6
+ Python client for the [Daichodo](https://daichodo.com) API — Japanese qualified
7
+ invoice issuer (適格請求書発行事業者) and corporate number (法人番号) lookup,
8
+ validation, and point-in-time validity.
9
+
10
+ > **⚠️ API はまだ一般公開されていません。**
11
+ > このパッケージは API の公開前に名前を確保するために公開されています。現時点では
12
+ > 呼び出しても接続できません。公開時期は [daichodo.com](https://daichodo.com) を
13
+ > ご確認ください。
14
+ >
15
+ > **⚠️ The API is not publicly available yet.**
16
+ > This package is published ahead of the service to reserve the name. Calls will
17
+ > not connect until the API launches — see
18
+ > [daichodo.com](https://daichodo.com) for availability.
19
+ >
20
+ > **APIキーが不要な検証だけであれば
21
+ > [`daichodo-validate`](https://pypi.org/project/daichodo-validate/)
22
+ > が今すぐ利用できます。**
23
+ > If you only need format and check-digit validation,
24
+ > [`daichodo-validate`](https://pypi.org/project/daichodo-validate/) works today
25
+ > with no API key.
26
+
27
+ ```bash
28
+ pip install daichodo
29
+ ```
30
+
31
+ ```python
32
+ from daichodo import AuthenticatedClient
33
+ from daichodo.api.registry import get_invoice_issuer
34
+
35
+ client = AuthenticatedClient(
36
+ base_url="https://api.daichodo.com",
37
+ token="dc_live_...",
38
+ )
39
+
40
+ issuer = get_invoice_issuer.sync(client=client, registration_number="T1010001153225")
41
+ ```
42
+
43
+ ## `name` が None でもエラーではありません / `name` is None for sole traders
44
+
45
+ 国税庁は個人事業主の氏名・住所を公表データから除外しています。個人事業主のレコードは
46
+ 日付を保持したまま**氏名が None** で返ります。`name is None` を「該当なし」と解釈する
47
+ のが最も多い誤りで、登録簿の約半数を無言で切り捨てることになります。
48
+
49
+ The NTA strips identity fields for individuals at source, so a sole trader
50
+ returns their dates with **no name**. Treating `name is None` as "not found" is
51
+ the most common way to get this wrong, and it silently discards about half the
52
+ register.
53
+
54
+ ## 生成コードです / This code is generated
55
+
56
+ API の OpenAPI スキーマから自動生成され、リリースごとに上書きされます。
57
+ プルリクエストは受け付けられません。不具合は
58
+ [Issue](https://github.com/daichodo/daichodo-python/issues) でご報告ください。
59
+
60
+ Generated from the API's OpenAPI schema and overwritten on every release.
61
+
62
+ ## ライセンス / Licence
63
+
64
+ MIT.
@@ -0,0 +1,8 @@
1
+ """A client library for accessing Daichodo"""
2
+
3
+ from .client import AuthenticatedClient, Client
4
+
5
+ __all__ = (
6
+ "AuthenticatedClient",
7
+ "Client",
8
+ )
@@ -0,0 +1 @@
1
+ """Contains methods for accessing the API"""
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,124 @@
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.health import Health
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs() -> dict[str, Any]:
13
+
14
+ _kwargs: dict[str, Any] = {
15
+ "method": "get",
16
+ "url": "/v1/health",
17
+ }
18
+
19
+ return _kwargs
20
+
21
+
22
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Health | None:
23
+ if response.status_code == 200:
24
+ response_200 = Health.from_dict(response.json())
25
+
26
+ return response_200
27
+
28
+ if client.raise_on_unexpected_status:
29
+ raise errors.UnexpectedStatus(response.status_code, response.content)
30
+ else:
31
+ return None
32
+
33
+
34
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Health]:
35
+ return Response(
36
+ status_code=HTTPStatus(response.status_code),
37
+ content=response.content,
38
+ headers=response.headers,
39
+ parsed=_parse_response(client=client, response=response),
40
+ )
41
+
42
+
43
+ def sync_detailed(
44
+ *,
45
+ client: AuthenticatedClient | Client,
46
+ ) -> Response[Health]:
47
+ """Liveness check
48
+
49
+ Raises:
50
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
51
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
52
+
53
+ Returns:
54
+ Response[Health]
55
+ """
56
+
57
+ kwargs = _get_kwargs()
58
+
59
+ response = client.get_httpx_client().request(
60
+ **kwargs,
61
+ )
62
+
63
+ return _build_response(client=client, response=response)
64
+
65
+
66
+ def sync(
67
+ *,
68
+ client: AuthenticatedClient | Client,
69
+ ) -> Health | None:
70
+ """Liveness check
71
+
72
+ Raises:
73
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
74
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
75
+
76
+ Returns:
77
+ Health
78
+ """
79
+
80
+ return sync_detailed(
81
+ client=client,
82
+ ).parsed
83
+
84
+
85
+ async def asyncio_detailed(
86
+ *,
87
+ client: AuthenticatedClient | Client,
88
+ ) -> Response[Health]:
89
+ """Liveness check
90
+
91
+ Raises:
92
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
93
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
94
+
95
+ Returns:
96
+ Response[Health]
97
+ """
98
+
99
+ kwargs = _get_kwargs()
100
+
101
+ response = await client.get_async_httpx_client().request(**kwargs)
102
+
103
+ return _build_response(client=client, response=response)
104
+
105
+
106
+ async def asyncio(
107
+ *,
108
+ client: AuthenticatedClient | Client,
109
+ ) -> Health | None:
110
+ """Liveness check
111
+
112
+ Raises:
113
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
114
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
115
+
116
+ Returns:
117
+ Health
118
+ """
119
+
120
+ return (
121
+ await asyncio_detailed(
122
+ client=client,
123
+ )
124
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,169 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.corporation import Corporation
10
+ from ...models.http_validation_error import HTTPValidationError
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ corporate_number: str,
16
+ ) -> dict[str, Any]:
17
+
18
+ _kwargs: dict[str, Any] = {
19
+ "method": "get",
20
+ "url": "/v1/corporations/{corporate_number}".format(
21
+ corporate_number=quote(str(corporate_number), safe=""),
22
+ ),
23
+ }
24
+
25
+ return _kwargs
26
+
27
+
28
+ def _parse_response(
29
+ *, client: AuthenticatedClient | Client, response: httpx.Response
30
+ ) -> Corporation | HTTPValidationError | None:
31
+ if response.status_code == 200:
32
+ response_200 = Corporation.from_dict(response.json())
33
+
34
+ return response_200
35
+
36
+ if response.status_code == 422:
37
+ response_422 = HTTPValidationError.from_dict(response.json())
38
+
39
+ return response_422
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[Corporation | HTTPValidationError]:
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
+ corporate_number: str,
60
+ *,
61
+ client: AuthenticatedClient | Client,
62
+ ) -> Response[Corporation | HTTPValidationError]:
63
+ """Look up a corporate number
64
+
65
+ Current published information for a 法人番号. Counts against your quota.
66
+
67
+ Args:
68
+ corporate_number (str):
69
+
70
+ Raises:
71
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
72
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
73
+
74
+ Returns:
75
+ Response[Corporation | HTTPValidationError]
76
+ """
77
+
78
+ kwargs = _get_kwargs(
79
+ corporate_number=corporate_number,
80
+ )
81
+
82
+ response = client.get_httpx_client().request(
83
+ **kwargs,
84
+ )
85
+
86
+ return _build_response(client=client, response=response)
87
+
88
+
89
+ def sync(
90
+ corporate_number: str,
91
+ *,
92
+ client: AuthenticatedClient | Client,
93
+ ) -> Corporation | HTTPValidationError | None:
94
+ """Look up a corporate number
95
+
96
+ Current published information for a 法人番号. Counts against your quota.
97
+
98
+ Args:
99
+ corporate_number (str):
100
+
101
+ Raises:
102
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
103
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
104
+
105
+ Returns:
106
+ Corporation | HTTPValidationError
107
+ """
108
+
109
+ return sync_detailed(
110
+ corporate_number=corporate_number,
111
+ client=client,
112
+ ).parsed
113
+
114
+
115
+ async def asyncio_detailed(
116
+ corporate_number: str,
117
+ *,
118
+ client: AuthenticatedClient | Client,
119
+ ) -> Response[Corporation | HTTPValidationError]:
120
+ """Look up a corporate number
121
+
122
+ Current published information for a 法人番号. Counts against your quota.
123
+
124
+ Args:
125
+ corporate_number (str):
126
+
127
+ Raises:
128
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
129
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
130
+
131
+ Returns:
132
+ Response[Corporation | HTTPValidationError]
133
+ """
134
+
135
+ kwargs = _get_kwargs(
136
+ corporate_number=corporate_number,
137
+ )
138
+
139
+ response = await client.get_async_httpx_client().request(**kwargs)
140
+
141
+ return _build_response(client=client, response=response)
142
+
143
+
144
+ async def asyncio(
145
+ corporate_number: str,
146
+ *,
147
+ client: AuthenticatedClient | Client,
148
+ ) -> Corporation | HTTPValidationError | None:
149
+ """Look up a corporate number
150
+
151
+ Current published information for a 法人番号. Counts against your quota.
152
+
153
+ Args:
154
+ corporate_number (str):
155
+
156
+ Raises:
157
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
158
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
159
+
160
+ Returns:
161
+ Corporation | HTTPValidationError
162
+ """
163
+
164
+ return (
165
+ await asyncio_detailed(
166
+ corporate_number=corporate_number,
167
+ client=client,
168
+ )
169
+ ).parsed
@@ -0,0 +1,177 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.http_validation_error import HTTPValidationError
10
+ from ...models.invoice_issuer import InvoiceIssuer
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ registration_number: str,
16
+ ) -> dict[str, Any]:
17
+
18
+ _kwargs: dict[str, Any] = {
19
+ "method": "get",
20
+ "url": "/v1/invoice-issuers/{registration_number}".format(
21
+ registration_number=quote(str(registration_number), safe=""),
22
+ ),
23
+ }
24
+
25
+ return _kwargs
26
+
27
+
28
+ def _parse_response(
29
+ *, client: AuthenticatedClient | Client, response: httpx.Response
30
+ ) -> HTTPValidationError | InvoiceIssuer | None:
31
+ if response.status_code == 200:
32
+ response_200 = InvoiceIssuer.from_dict(response.json())
33
+
34
+ return response_200
35
+
36
+ if response.status_code == 422:
37
+ response_422 = HTTPValidationError.from_dict(response.json())
38
+
39
+ return response_422
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[HTTPValidationError | InvoiceIssuer]:
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
+ registration_number: str,
60
+ *,
61
+ client: AuthenticatedClient | Client,
62
+ ) -> Response[HTTPValidationError | InvoiceIssuer]:
63
+ """Look up a qualified invoice issuer
64
+
65
+ Current published information for a 登録番号. Counts against your monthly quota.
66
+
67
+ Sole traders return dates with a null `name` - that is a valid record, not a miss.
68
+
69
+ Args:
70
+ registration_number (str):
71
+
72
+ Raises:
73
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
74
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
75
+
76
+ Returns:
77
+ Response[HTTPValidationError | InvoiceIssuer]
78
+ """
79
+
80
+ kwargs = _get_kwargs(
81
+ registration_number=registration_number,
82
+ )
83
+
84
+ response = client.get_httpx_client().request(
85
+ **kwargs,
86
+ )
87
+
88
+ return _build_response(client=client, response=response)
89
+
90
+
91
+ def sync(
92
+ registration_number: str,
93
+ *,
94
+ client: AuthenticatedClient | Client,
95
+ ) -> HTTPValidationError | InvoiceIssuer | None:
96
+ """Look up a qualified invoice issuer
97
+
98
+ Current published information for a 登録番号. Counts against your monthly quota.
99
+
100
+ Sole traders return dates with a null `name` - that is a valid record, not a miss.
101
+
102
+ Args:
103
+ registration_number (str):
104
+
105
+ Raises:
106
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
107
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
108
+
109
+ Returns:
110
+ HTTPValidationError | InvoiceIssuer
111
+ """
112
+
113
+ return sync_detailed(
114
+ registration_number=registration_number,
115
+ client=client,
116
+ ).parsed
117
+
118
+
119
+ async def asyncio_detailed(
120
+ registration_number: str,
121
+ *,
122
+ client: AuthenticatedClient | Client,
123
+ ) -> Response[HTTPValidationError | InvoiceIssuer]:
124
+ """Look up a qualified invoice issuer
125
+
126
+ Current published information for a 登録番号. Counts against your monthly quota.
127
+
128
+ Sole traders return dates with a null `name` - that is a valid record, not a miss.
129
+
130
+ Args:
131
+ registration_number (str):
132
+
133
+ Raises:
134
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
135
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
136
+
137
+ Returns:
138
+ Response[HTTPValidationError | InvoiceIssuer]
139
+ """
140
+
141
+ kwargs = _get_kwargs(
142
+ registration_number=registration_number,
143
+ )
144
+
145
+ response = await client.get_async_httpx_client().request(**kwargs)
146
+
147
+ return _build_response(client=client, response=response)
148
+
149
+
150
+ async def asyncio(
151
+ registration_number: str,
152
+ *,
153
+ client: AuthenticatedClient | Client,
154
+ ) -> HTTPValidationError | InvoiceIssuer | None:
155
+ """Look up a qualified invoice issuer
156
+
157
+ Current published information for a 登録番号. Counts against your monthly quota.
158
+
159
+ Sole traders return dates with a null `name` - that is a valid record, not a miss.
160
+
161
+ Args:
162
+ registration_number (str):
163
+
164
+ Raises:
165
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
166
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
167
+
168
+ Returns:
169
+ HTTPValidationError | InvoiceIssuer
170
+ """
171
+
172
+ return (
173
+ await asyncio_detailed(
174
+ registration_number=registration_number,
175
+ client=client,
176
+ )
177
+ ).parsed