hexpay 0.0.1__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 (40) hide show
  1. hexpay/__init__.py +8 -0
  2. hexpay/api/__init__.py +1 -0
  3. hexpay/api/payment_methods/__init__.py +1 -0
  4. hexpay/api/payment_methods/list_payment_methods.py +166 -0
  5. hexpay/api/payments/__init__.py +1 -0
  6. hexpay/api/payments/cancel_payment.py +222 -0
  7. hexpay/api/payments/create_payment.py +338 -0
  8. hexpay/api/payments/get_payment.py +235 -0
  9. hexpay/api/payments/get_payment_status.py +195 -0
  10. hexpay/api/payments/list_payments.py +258 -0
  11. hexpay/client.py +268 -0
  12. hexpay/errors.py +16 -0
  13. hexpay/models/__init__.py +49 -0
  14. hexpay/models/chain_response.py +85 -0
  15. hexpay/models/chain_response_symbol.py +8 -0
  16. hexpay/models/coin_response.py +85 -0
  17. hexpay/models/coin_response_symbol.py +17 -0
  18. hexpay/models/create_payment_request.py +197 -0
  19. hexpay/models/create_payment_request_metadata.py +57 -0
  20. hexpay/models/error.py +105 -0
  21. hexpay/models/error_response.py +79 -0
  22. hexpay/models/error_type.py +12 -0
  23. hexpay/models/method_filter.py +80 -0
  24. hexpay/models/method_filter_chain.py +8 -0
  25. hexpay/models/method_filter_coin.py +17 -0
  26. hexpay/models/payment_cancel_response.py +77 -0
  27. hexpay/models/payment_details.py +122 -0
  28. hexpay/models/payment_list_response.py +95 -0
  29. hexpay/models/payment_method_list_response.py +84 -0
  30. hexpay/models/payment_method_response.py +97 -0
  31. hexpay/models/payment_options.py +92 -0
  32. hexpay/models/payment_response.py +177 -0
  33. hexpay/models/payment_status.py +12 -0
  34. hexpay/models/payment_status_response.py +80 -0
  35. hexpay/models/payment_timer_response.py +98 -0
  36. hexpay/py.typed +0 -0
  37. hexpay/types.py +54 -0
  38. hexpay-0.0.1.dist-info/METADATA +161 -0
  39. hexpay-0.0.1.dist-info/RECORD +40 -0
  40. hexpay-0.0.1.dist-info/WHEEL +4 -0
hexpay/__init__.py ADDED
@@ -0,0 +1,8 @@
1
+ """A client library for accessing HexPay Merchant API"""
2
+
3
+ from .client import AuthenticatedClient, Client
4
+
5
+ __all__ = (
6
+ "AuthenticatedClient",
7
+ "Client",
8
+ )
hexpay/api/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """Contains methods for accessing the API"""
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,166 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...types import Response, UNSET
9
+ from ... import errors
10
+
11
+ from ...models.error_response import ErrorResponse
12
+ from ...models.payment_method_list_response import PaymentMethodListResponse
13
+ from typing import cast
14
+
15
+
16
+ def _get_kwargs() -> dict[str, Any]:
17
+
18
+ _kwargs: dict[str, Any] = {
19
+ "method": "get",
20
+ "url": "/v1/payment-methods",
21
+ }
22
+
23
+ return _kwargs
24
+
25
+
26
+ def _parse_response(
27
+ *, client: AuthenticatedClient | Client, response: httpx.Response
28
+ ) -> ErrorResponse | PaymentMethodListResponse | None:
29
+ if response.status_code == 200:
30
+ response_200 = PaymentMethodListResponse.from_dict(response.json())
31
+
32
+ return response_200
33
+
34
+ if response.status_code == 401:
35
+ response_401 = ErrorResponse.from_dict(response.json())
36
+
37
+ return response_401
38
+
39
+ if response.status_code == 500:
40
+ response_500 = ErrorResponse.from_dict(response.json())
41
+
42
+ return response_500
43
+
44
+ if client.raise_on_unexpected_status:
45
+ raise errors.UnexpectedStatus(response.status_code, response.content)
46
+ else:
47
+ return None
48
+
49
+
50
+ def _build_response(
51
+ *, client: AuthenticatedClient | Client, response: httpx.Response
52
+ ) -> Response[ErrorResponse | PaymentMethodListResponse]:
53
+ return Response(
54
+ status_code=HTTPStatus(response.status_code),
55
+ content=response.content,
56
+ headers=response.headers,
57
+ parsed=_parse_response(client=client, response=response),
58
+ )
59
+
60
+
61
+ def sync_detailed(
62
+ *,
63
+ client: AuthenticatedClient | Client,
64
+ ) -> Response[ErrorResponse | PaymentMethodListResponse]:
65
+ """List payment methods
66
+
67
+ Retrieves all payment methods enabled for your store. Each entry represents
68
+ a unique coin + chain combination that your store accepts.
69
+
70
+ Use `coin.symbol` and `chain.symbol` values from this response as inputs for
71
+ the `coin` and `chain` fields in `payment_options.methods` when creating a payment.
72
+
73
+ Raises:
74
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
75
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
76
+
77
+ Returns:
78
+ Response[ErrorResponse | PaymentMethodListResponse]
79
+ """
80
+
81
+ kwargs = _get_kwargs()
82
+
83
+ response = client.get_httpx_client().request(
84
+ **kwargs,
85
+ )
86
+
87
+ return _build_response(client=client, response=response)
88
+
89
+
90
+ def sync(
91
+ *,
92
+ client: AuthenticatedClient | Client,
93
+ ) -> ErrorResponse | PaymentMethodListResponse | None:
94
+ """List payment methods
95
+
96
+ Retrieves all payment methods enabled for your store. Each entry represents
97
+ a unique coin + chain combination that your store accepts.
98
+
99
+ Use `coin.symbol` and `chain.symbol` values from this response as inputs for
100
+ the `coin` and `chain` fields in `payment_options.methods` when creating a payment.
101
+
102
+ Raises:
103
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
104
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
105
+
106
+ Returns:
107
+ ErrorResponse | PaymentMethodListResponse
108
+ """
109
+
110
+ return sync_detailed(
111
+ client=client,
112
+ ).parsed
113
+
114
+
115
+ async def asyncio_detailed(
116
+ *,
117
+ client: AuthenticatedClient | Client,
118
+ ) -> Response[ErrorResponse | PaymentMethodListResponse]:
119
+ """List payment methods
120
+
121
+ Retrieves all payment methods enabled for your store. Each entry represents
122
+ a unique coin + chain combination that your store accepts.
123
+
124
+ Use `coin.symbol` and `chain.symbol` values from this response as inputs for
125
+ the `coin` and `chain` fields in `payment_options.methods` when creating a payment.
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[ErrorResponse | PaymentMethodListResponse]
133
+ """
134
+
135
+ kwargs = _get_kwargs()
136
+
137
+ response = await client.get_async_httpx_client().request(**kwargs)
138
+
139
+ return _build_response(client=client, response=response)
140
+
141
+
142
+ async def asyncio(
143
+ *,
144
+ client: AuthenticatedClient | Client,
145
+ ) -> ErrorResponse | PaymentMethodListResponse | None:
146
+ """List payment methods
147
+
148
+ Retrieves all payment methods enabled for your store. Each entry represents
149
+ a unique coin + chain combination that your store accepts.
150
+
151
+ Use `coin.symbol` and `chain.symbol` values from this response as inputs for
152
+ the `coin` and `chain` fields in `payment_options.methods` when creating a payment.
153
+
154
+ Raises:
155
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
156
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
157
+
158
+ Returns:
159
+ ErrorResponse | PaymentMethodListResponse
160
+ """
161
+
162
+ return (
163
+ await asyncio_detailed(
164
+ client=client,
165
+ )
166
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,222 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...types import Response, UNSET
9
+ from ... import errors
10
+
11
+ from ...models.error_response import ErrorResponse
12
+ from ...models.payment_cancel_response import PaymentCancelResponse
13
+ from ...types import UNSET, Unset
14
+ from typing import cast
15
+ from uuid import UUID
16
+
17
+
18
+ def _get_kwargs(
19
+ payment_id: UUID,
20
+ *,
21
+ x_idempotency_key: UUID | Unset = UNSET,
22
+ ) -> dict[str, Any]:
23
+ headers: dict[str, Any] = {}
24
+ if not isinstance(x_idempotency_key, Unset):
25
+ headers["X-Idempotency-Key"] = x_idempotency_key
26
+
27
+ _kwargs: dict[str, Any] = {
28
+ "method": "post",
29
+ "url": "/v1/payments/{payment_id}/cancel".format(
30
+ payment_id=quote(str(payment_id), safe=""),
31
+ ),
32
+ }
33
+
34
+ _kwargs["headers"] = headers
35
+ return _kwargs
36
+
37
+
38
+ def _parse_response(
39
+ *, client: AuthenticatedClient | Client, response: httpx.Response
40
+ ) -> ErrorResponse | PaymentCancelResponse | None:
41
+ if response.status_code == 200:
42
+ response_200 = PaymentCancelResponse.from_dict(response.json())
43
+
44
+ return response_200
45
+
46
+ if response.status_code == 400:
47
+ response_400 = ErrorResponse.from_dict(response.json())
48
+
49
+ return response_400
50
+
51
+ if response.status_code == 401:
52
+ response_401 = ErrorResponse.from_dict(response.json())
53
+
54
+ return response_401
55
+
56
+ if response.status_code == 404:
57
+ response_404 = ErrorResponse.from_dict(response.json())
58
+
59
+ return response_404
60
+
61
+ if response.status_code == 500:
62
+ response_500 = ErrorResponse.from_dict(response.json())
63
+
64
+ return response_500
65
+
66
+ if client.raise_on_unexpected_status:
67
+ raise errors.UnexpectedStatus(response.status_code, response.content)
68
+ else:
69
+ return None
70
+
71
+
72
+ def _build_response(
73
+ *, client: AuthenticatedClient | Client, response: httpx.Response
74
+ ) -> Response[ErrorResponse | PaymentCancelResponse]:
75
+ return Response(
76
+ status_code=HTTPStatus(response.status_code),
77
+ content=response.content,
78
+ headers=response.headers,
79
+ parsed=_parse_response(client=client, response=response),
80
+ )
81
+
82
+
83
+ def sync_detailed(
84
+ payment_id: UUID,
85
+ *,
86
+ client: AuthenticatedClient | Client,
87
+ x_idempotency_key: UUID | Unset = UNSET,
88
+ ) -> Response[ErrorResponse | PaymentCancelResponse]:
89
+ """Cancel a payment
90
+
91
+ Cancels a payment and returns the updated status `cancelled`.
92
+
93
+ Cancellation is permitted from `created` or `pending` status only. Payments
94
+ already in a terminal state (`completed`, `expired`, or `cancelled`) cannot
95
+ be cancelled.
96
+
97
+ Args:
98
+ payment_id (UUID): Example: 019327c6-2058-7901-b234-56789abcdeff.
99
+ x_idempotency_key (UUID | Unset): Example: a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d.
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
+ Response[ErrorResponse | PaymentCancelResponse]
107
+ """
108
+
109
+ kwargs = _get_kwargs(
110
+ payment_id=payment_id,
111
+ x_idempotency_key=x_idempotency_key,
112
+ )
113
+
114
+ response = client.get_httpx_client().request(
115
+ **kwargs,
116
+ )
117
+
118
+ return _build_response(client=client, response=response)
119
+
120
+
121
+ def sync(
122
+ payment_id: UUID,
123
+ *,
124
+ client: AuthenticatedClient | Client,
125
+ x_idempotency_key: UUID | Unset = UNSET,
126
+ ) -> ErrorResponse | PaymentCancelResponse | None:
127
+ """Cancel a payment
128
+
129
+ Cancels a payment and returns the updated status `cancelled`.
130
+
131
+ Cancellation is permitted from `created` or `pending` status only. Payments
132
+ already in a terminal state (`completed`, `expired`, or `cancelled`) cannot
133
+ be cancelled.
134
+
135
+ Args:
136
+ payment_id (UUID): Example: 019327c6-2058-7901-b234-56789abcdeff.
137
+ x_idempotency_key (UUID | Unset): Example: a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d.
138
+
139
+ Raises:
140
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
141
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
142
+
143
+ Returns:
144
+ ErrorResponse | PaymentCancelResponse
145
+ """
146
+
147
+ return sync_detailed(
148
+ payment_id=payment_id,
149
+ client=client,
150
+ x_idempotency_key=x_idempotency_key,
151
+ ).parsed
152
+
153
+
154
+ async def asyncio_detailed(
155
+ payment_id: UUID,
156
+ *,
157
+ client: AuthenticatedClient | Client,
158
+ x_idempotency_key: UUID | Unset = UNSET,
159
+ ) -> Response[ErrorResponse | PaymentCancelResponse]:
160
+ """Cancel a payment
161
+
162
+ Cancels a payment and returns the updated status `cancelled`.
163
+
164
+ Cancellation is permitted from `created` or `pending` status only. Payments
165
+ already in a terminal state (`completed`, `expired`, or `cancelled`) cannot
166
+ be cancelled.
167
+
168
+ Args:
169
+ payment_id (UUID): Example: 019327c6-2058-7901-b234-56789abcdeff.
170
+ x_idempotency_key (UUID | Unset): Example: a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d.
171
+
172
+ Raises:
173
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
174
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
175
+
176
+ Returns:
177
+ Response[ErrorResponse | PaymentCancelResponse]
178
+ """
179
+
180
+ kwargs = _get_kwargs(
181
+ payment_id=payment_id,
182
+ x_idempotency_key=x_idempotency_key,
183
+ )
184
+
185
+ response = await client.get_async_httpx_client().request(**kwargs)
186
+
187
+ return _build_response(client=client, response=response)
188
+
189
+
190
+ async def asyncio(
191
+ payment_id: UUID,
192
+ *,
193
+ client: AuthenticatedClient | Client,
194
+ x_idempotency_key: UUID | Unset = UNSET,
195
+ ) -> ErrorResponse | PaymentCancelResponse | None:
196
+ """Cancel a payment
197
+
198
+ Cancels a payment and returns the updated status `cancelled`.
199
+
200
+ Cancellation is permitted from `created` or `pending` status only. Payments
201
+ already in a terminal state (`completed`, `expired`, or `cancelled`) cannot
202
+ be cancelled.
203
+
204
+ Args:
205
+ payment_id (UUID): Example: 019327c6-2058-7901-b234-56789abcdeff.
206
+ x_idempotency_key (UUID | Unset): Example: a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d.
207
+
208
+ Raises:
209
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
210
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
211
+
212
+ Returns:
213
+ ErrorResponse | PaymentCancelResponse
214
+ """
215
+
216
+ return (
217
+ await asyncio_detailed(
218
+ payment_id=payment_id,
219
+ client=client,
220
+ x_idempotency_key=x_idempotency_key,
221
+ )
222
+ ).parsed