maytes-api-client-py 0.1.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 (65) hide show
  1. maytes_api_client/__init__.py +150 -0
  2. maytes_api_client/api/__init__.py +5 -0
  3. maytes_api_client/api/default_api.py +2661 -0
  4. maytes_api_client/api_client.py +804 -0
  5. maytes_api_client/api_response.py +21 -0
  6. maytes_api_client/configuration.py +630 -0
  7. maytes_api_client/exceptions.py +218 -0
  8. maytes_api_client/managed_client.py +199 -0
  9. maytes_api_client/models/__init__.py +64 -0
  10. maytes_api_client/models/cancel_checkout409_response.py +101 -0
  11. maytes_api_client/models/cancel_checkout_request.py +88 -0
  12. maytes_api_client/models/cancel_checkout_response.py +92 -0
  13. maytes_api_client/models/capture_checkout409_response.py +101 -0
  14. maytes_api_client/models/capture_checkout422_response.py +101 -0
  15. maytes_api_client/models/capture_checkout_request.py +118 -0
  16. maytes_api_client/models/capture_checkout_response.py +92 -0
  17. maytes_api_client/models/checkout.py +159 -0
  18. maytes_api_client/models/checkout_cancelled.py +97 -0
  19. maytes_api_client/models/checkout_captured.py +109 -0
  20. maytes_api_client/models/checkout_created.py +95 -0
  21. maytes_api_client/models/checkout_discount.py +133 -0
  22. maytes_api_client/models/checkout_fee.py +150 -0
  23. maytes_api_client/models/create_checkout401_response.py +101 -0
  24. maytes_api_client/models/create_checkout409_response.py +101 -0
  25. maytes_api_client/models/create_checkout422_response.py +101 -0
  26. maytes_api_client/models/create_checkout_request.py +213 -0
  27. maytes_api_client/models/create_checkout_response.py +92 -0
  28. maytes_api_client/models/create_refund_request.py +91 -0
  29. maytes_api_client/models/customer_data.py +107 -0
  30. maytes_api_client/models/digital_goods_custom_data.py +93 -0
  31. maytes_api_client/models/digital_goods_line_item.py +150 -0
  32. maytes_api_client/models/donation_line_item.py +144 -0
  33. maytes_api_client/models/error_response_dto.py +94 -0
  34. maytes_api_client/models/fee.py +103 -0
  35. maytes_api_client/models/fee_breakdown_line.py +101 -0
  36. maytes_api_client/models/food_beverage_line_item.py +144 -0
  37. maytes_api_client/models/get_checkout404_response.py +101 -0
  38. maytes_api_client/models/get_checkout422_response.py +101 -0
  39. maytes_api_client/models/get_checkout_response.py +92 -0
  40. maytes_api_client/models/get_settlement_response.py +92 -0
  41. maytes_api_client/models/health_response.py +88 -0
  42. maytes_api_client/models/line_item.py +210 -0
  43. maytes_api_client/models/list_settlements_response.py +96 -0
  44. maytes_api_client/models/o_auth_token_request.py +102 -0
  45. maytes_api_client/models/o_auth_token_response.py +96 -0
  46. maytes_api_client/models/other_line_item.py +144 -0
  47. maytes_api_client/models/physical_goods_custom_data.py +90 -0
  48. maytes_api_client/models/physical_goods_line_item.py +150 -0
  49. maytes_api_client/models/refund_checkout402_response.py +101 -0
  50. maytes_api_client/models/refund_checkout409_response.py +101 -0
  51. maytes_api_client/models/service_custom_data.py +93 -0
  52. maytes_api_client/models/service_line_item.py +150 -0
  53. maytes_api_client/models/settlement.py +160 -0
  54. maytes_api_client/models/tax.py +111 -0
  55. maytes_api_client/models/ticket_custom_data.py +125 -0
  56. maytes_api_client/models/ticket_line_item.py +150 -0
  57. maytes_api_client/models/ticket_seating.py +94 -0
  58. maytes_api_client/py.typed +0 -0
  59. maytes_api_client/rest.py +263 -0
  60. maytes_api_client/webhook_verifier.py +197 -0
  61. maytes_api_client_py-0.1.1.dist-info/METADATA +70 -0
  62. maytes_api_client_py-0.1.1.dist-info/RECORD +65 -0
  63. maytes_api_client_py-0.1.1.dist-info/WHEEL +5 -0
  64. maytes_api_client_py-0.1.1.dist-info/licenses/LICENSE +21 -0
  65. maytes_api_client_py-0.1.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,218 @@
1
+ """
2
+ Maytes API
3
+
4
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
8
+
9
+ Do not edit the class manually.
10
+ """ # noqa: E501
11
+
12
+
13
+ from typing import Any, Optional
14
+ from typing_extensions import Self
15
+
16
+ class OpenApiException(Exception):
17
+ """The base exception class for all OpenAPIExceptions"""
18
+
19
+
20
+ class ApiTypeError(OpenApiException, TypeError):
21
+ def __init__(self, msg, path_to_item=None, valid_classes=None,
22
+ key_type=None) -> None:
23
+ """ Raises an exception for TypeErrors
24
+
25
+ Args:
26
+ msg (str): the exception message
27
+
28
+ Keyword Args:
29
+ path_to_item (list): a list of keys an indices to get to the
30
+ current_item
31
+ None if unset
32
+ valid_classes (tuple): the primitive classes that current item
33
+ should be an instance of
34
+ None if unset
35
+ key_type (bool): False if our value is a value in a dict
36
+ True if it is a key in a dict
37
+ False if our item is an item in a list
38
+ None if unset
39
+ """
40
+ self.path_to_item = path_to_item
41
+ self.valid_classes = valid_classes
42
+ self.key_type = key_type
43
+ full_msg = msg
44
+ if path_to_item:
45
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
46
+ super(ApiTypeError, self).__init__(full_msg)
47
+
48
+
49
+ class ApiValueError(OpenApiException, ValueError):
50
+ def __init__(self, msg, path_to_item=None) -> None:
51
+ """
52
+ Args:
53
+ msg (str): the exception message
54
+
55
+ Keyword Args:
56
+ path_to_item (list) the path to the exception in the
57
+ received_data dict. None if unset
58
+ """
59
+
60
+ self.path_to_item = path_to_item
61
+ full_msg = msg
62
+ if path_to_item:
63
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
64
+ super(ApiValueError, self).__init__(full_msg)
65
+
66
+
67
+ class ApiAttributeError(OpenApiException, AttributeError):
68
+ def __init__(self, msg, path_to_item=None) -> None:
69
+ """
70
+ Raised when an attribute reference or assignment fails.
71
+
72
+ Args:
73
+ msg (str): the exception message
74
+
75
+ Keyword Args:
76
+ path_to_item (None/list) the path to the exception in the
77
+ received_data dict
78
+ """
79
+ self.path_to_item = path_to_item
80
+ full_msg = msg
81
+ if path_to_item:
82
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
83
+ super(ApiAttributeError, self).__init__(full_msg)
84
+
85
+
86
+ class ApiKeyError(OpenApiException, KeyError):
87
+ def __init__(self, msg, path_to_item=None) -> None:
88
+ """
89
+ Args:
90
+ msg (str): the exception message
91
+
92
+ Keyword Args:
93
+ path_to_item (None/list) the path to the exception in the
94
+ received_data dict
95
+ """
96
+ self.path_to_item = path_to_item
97
+ full_msg = msg
98
+ if path_to_item:
99
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
100
+ super(ApiKeyError, self).__init__(full_msg)
101
+
102
+
103
+ class ApiException(OpenApiException):
104
+
105
+ def __init__(
106
+ self,
107
+ status=None,
108
+ reason=None,
109
+ http_resp=None,
110
+ *,
111
+ body: Optional[str] = None,
112
+ data: Optional[Any] = None,
113
+ ) -> None:
114
+ self.status = status
115
+ self.reason = reason
116
+ self.body = body
117
+ self.data = data
118
+ self.headers = None
119
+
120
+ if http_resp:
121
+ if self.status is None:
122
+ self.status = http_resp.status
123
+ if self.reason is None:
124
+ self.reason = http_resp.reason
125
+ if self.body is None:
126
+ try:
127
+ self.body = http_resp.data.decode('utf-8')
128
+ except Exception:
129
+ pass
130
+ self.headers = http_resp.headers
131
+
132
+ @classmethod
133
+ def from_response(
134
+ cls,
135
+ *,
136
+ http_resp,
137
+ body: Optional[str],
138
+ data: Optional[Any],
139
+ ) -> Self:
140
+ if http_resp.status == 400:
141
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
142
+
143
+ if http_resp.status == 401:
144
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
145
+
146
+ if http_resp.status == 403:
147
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
148
+
149
+ if http_resp.status == 404:
150
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
151
+
152
+ # Added new conditions for 409 and 422
153
+ if http_resp.status == 409:
154
+ raise ConflictException(http_resp=http_resp, body=body, data=data)
155
+
156
+ if http_resp.status == 422:
157
+ raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
158
+
159
+ if 500 <= http_resp.status <= 599:
160
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
161
+ raise ApiException(http_resp=http_resp, body=body, data=data)
162
+
163
+ def __str__(self):
164
+ """Custom error messages for exception"""
165
+ error_message = "({0})\n"\
166
+ "Reason: {1}\n".format(self.status, self.reason)
167
+ if self.headers:
168
+ error_message += "HTTP response headers: {0}\n".format(
169
+ self.headers)
170
+
171
+ if self.body:
172
+ error_message += "HTTP response body: {0}\n".format(self.body)
173
+
174
+ if self.data:
175
+ error_message += "HTTP response data: {0}\n".format(self.data)
176
+
177
+ return error_message
178
+
179
+
180
+ class BadRequestException(ApiException):
181
+ pass
182
+
183
+
184
+ class NotFoundException(ApiException):
185
+ pass
186
+
187
+
188
+ class UnauthorizedException(ApiException):
189
+ pass
190
+
191
+
192
+ class ForbiddenException(ApiException):
193
+ pass
194
+
195
+
196
+ class ServiceException(ApiException):
197
+ pass
198
+
199
+
200
+ class ConflictException(ApiException):
201
+ """Exception for HTTP 409 Conflict."""
202
+ pass
203
+
204
+
205
+ class UnprocessableEntityException(ApiException):
206
+ """Exception for HTTP 422 Unprocessable Entity."""
207
+ pass
208
+
209
+
210
+ def render_path(path_to_item):
211
+ """Returns a string representation of a path"""
212
+ result = ""
213
+ for pth in path_to_item:
214
+ if isinstance(pth, int):
215
+ result += "[{0}]".format(pth)
216
+ else:
217
+ result += "['{0}']".format(pth)
218
+ return result
@@ -0,0 +1,199 @@
1
+ """Bundled with the generated SDK via bin/postprocess-python.sh.
2
+
3
+ Lives at build/python-client/maytes_api_client/managed_client.py after a
4
+ `make generate-python`. Exported from maytes_api_client/__init__.py.
5
+
6
+ Adds OAuth2 client_credentials credential management on top of the raw
7
+ DefaultApi using a **reactive 401-retry** pattern:
8
+
9
+ 1. First authed call mints a token via GetOAuthToken (a @auth([]) op) and
10
+ caches it.
11
+ 2. Subsequent calls send the cached token as-is — no client-side expiry
12
+ math, no proactive refresh.
13
+ 3. If the server returns 401, _ManagedApiClient catches the ApiException,
14
+ refreshes the token, and retries the call once. If the retry also 401s,
15
+ the error propagates.
16
+
17
+ Concurrent 401s deduplicate via `refresh_if_stale(stale_token)`: only the
18
+ first caller to acquire the lock mints; others see the cache already updated
19
+ and use that token instead.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import threading
25
+ from typing import Any, Optional
26
+
27
+ from uuid import UUID
28
+
29
+ from .api.default_api import DefaultApi
30
+ from .api_client import ApiClient
31
+ from .configuration import Configuration
32
+ from .exceptions import ApiException
33
+ from .models.o_auth_token_request import (
34
+ OAuthTokenRequest,
35
+ )
36
+
37
+
38
+ class OAuthTokenProvider:
39
+ """Caches an OAuth2 client_credentials token; refreshes only on demand.
40
+
41
+ Threadsafe — concurrent refreshes serialize behind a lock and dedup
42
+ via the `stale_token` snapshot.
43
+ """
44
+
45
+ def __init__(
46
+ self,
47
+ endpoint: str,
48
+ client_id: str,
49
+ client_secret: str,
50
+ initial_token: Optional[str] = None,
51
+ ) -> None:
52
+ self._endpoint = endpoint
53
+ self._client_id = client_id
54
+ self._client_secret = client_secret
55
+ self._token: Optional[str] = initial_token
56
+ self._lock = threading.Lock()
57
+ self._unauthed_api = DefaultApi(ApiClient(Configuration(host=endpoint)))
58
+
59
+ def get(self) -> str:
60
+ if self._token is not None:
61
+ return self._token
62
+ with self._lock:
63
+ if self._token is not None:
64
+ return self._token
65
+ return self._mint_unlocked()
66
+
67
+ def refresh_if_stale(self, stale_token: Optional[str]) -> str:
68
+ """Mint a new token only if the cache still holds the stale one the
69
+ caller observed. If another concurrent caller already refreshed,
70
+ return that newer token instead — no second mint.
71
+ """
72
+ with self._lock:
73
+ if self._token is not None and self._token != stale_token:
74
+ return self._token
75
+ return self._mint_unlocked()
76
+
77
+ def _mint_unlocked(self) -> str:
78
+ response = self._unauthed_api.get_o_auth_token(
79
+ OAuthTokenRequest(
80
+ grant_type="client_credentials",
81
+ client_id=UUID(self._client_id),
82
+ client_secret=self._client_secret,
83
+ )
84
+ )
85
+ assert response.access_token is not None
86
+ self._token = response.access_token
87
+ return self._token
88
+
89
+
90
+ class _ManagedConfiguration(Configuration):
91
+ """Configuration whose access_token always delegates to the provider.
92
+
93
+ Property + setter combo so Configuration.__init__'s `self.access_token =
94
+ access_token` doesn't blow up — the setter just no-ops.
95
+ """
96
+
97
+ def __init__(self, provider: OAuthTokenProvider, *, host: str) -> None:
98
+ super().__init__(host=host)
99
+ object.__setattr__(self, "_provider", provider)
100
+
101
+ @property # type: ignore[override]
102
+ def access_token(self) -> str:
103
+ return self._provider.get()
104
+
105
+ @access_token.setter
106
+ def access_token(self, value: Optional[str]) -> None:
107
+ # Configuration.__init__ sets self.access_token = None — accept + ignore.
108
+ pass
109
+
110
+
111
+ class _ManagedApiClient(ApiClient):
112
+ """ApiClient that intercepts 401 *responses* (status code, not exception)
113
+ inside call_api, refreshes the token, and replays the request once with
114
+ the new Authorization header.
115
+
116
+ Recent openapi-generator-cli Python templates split the HTTP layer in two:
117
+ `call_api` performs the request and returns a raw RESTResponse (status +
118
+ headers + body); the downstream `response_deserialize` is what turns a
119
+ non-2xx status into an ApiException. So the retry has to live inside
120
+ `call_api` — by the time `response_deserialize` raises, we no longer have
121
+ the request parameters needed to replay.
122
+ """
123
+
124
+ def __init__(self, configuration: Configuration, provider: OAuthTokenProvider) -> None:
125
+ super().__init__(configuration)
126
+ self._provider = provider
127
+
128
+ def call_api(
129
+ self,
130
+ method: str,
131
+ url: str,
132
+ header_params: Optional[dict] = None,
133
+ body: Any = None,
134
+ post_params: Any = None,
135
+ _request_timeout: Any = None,
136
+ ) -> Any:
137
+ # Snapshot the token actually used on the wire so refresh_if_stale can
138
+ # dedup against concurrent refreshes. Parsed from the Authorization
139
+ # header rather than re-asking the provider, because by the time we
140
+ # get here the header has already been built upstream.
141
+ stale_token: Optional[str] = None
142
+ if header_params and isinstance(header_params.get("Authorization"), str):
143
+ auth = header_params["Authorization"]
144
+ if auth.startswith("Bearer "):
145
+ stale_token = auth[len("Bearer "):]
146
+
147
+ response = super().call_api(
148
+ method, url,
149
+ header_params=header_params,
150
+ body=body,
151
+ post_params=post_params,
152
+ _request_timeout=_request_timeout,
153
+ )
154
+
155
+ if response.status != 401 or stale_token is None:
156
+ return response
157
+
158
+ # 401 — refresh, rebuild auth header, retry once. If the retry also
159
+ # 401s, return that response and let response_deserialize raise.
160
+ new_token = self._provider.refresh_if_stale(stale_token)
161
+ retry_headers = dict(header_params) if header_params else {}
162
+ retry_headers["Authorization"] = "Bearer " + new_token
163
+ return super().call_api(
164
+ method, url,
165
+ header_params=retry_headers,
166
+ body=body,
167
+ post_params=post_params,
168
+ _request_timeout=_request_timeout,
169
+ )
170
+
171
+
172
+ def create_maytes_api_client(
173
+ endpoint: str,
174
+ client_id: str,
175
+ client_secret: str,
176
+ initial_token: Optional[str] = None,
177
+ ) -> DefaultApi:
178
+ """Returns a fully managed DefaultApi.
179
+
180
+ Tokens are minted on first authed call, cached, and refreshed reactively
181
+ when the server returns 401. Operations declared @auth([]) in the Smithy
182
+ (getHealth, getOAuthToken) carry no security requirement and skip the Authorization header.
183
+
184
+ from maytes_api_client import create_maytes_api_client
185
+ api = create_maytes_api_client(
186
+ endpoint="https://api.maytes.co",
187
+ client_id="...",
188
+ client_secret="...",
189
+ )
190
+ result = api.create_checkout(CreateCheckoutRequest(...))
191
+
192
+ `initial_token` is an SDK-test-only escape hatch — seeds the cache with a
193
+ pre-minted JWT. Used by the E2E test path to verify the wrapper's reactive
194
+ 401-retry behavior when the seeded token expires. Production callers omit
195
+ this; the first authed call will mint via /oauth/token.
196
+ """
197
+ provider = OAuthTokenProvider(endpoint, client_id, client_secret, initial_token)
198
+ config = _ManagedConfiguration(provider, host=endpoint)
199
+ return DefaultApi(_ManagedApiClient(config, provider))
@@ -0,0 +1,64 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ Maytes API
6
+
7
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
8
+
9
+ The version of the OpenAPI document: 1.0.0
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+ # import models into model package
16
+ from maytes_api_client.models.cancel_checkout409_response import CancelCheckout409Response
17
+ from maytes_api_client.models.cancel_checkout_request import CancelCheckoutRequest
18
+ from maytes_api_client.models.cancel_checkout_response import CancelCheckoutResponse
19
+ from maytes_api_client.models.capture_checkout409_response import CaptureCheckout409Response
20
+ from maytes_api_client.models.capture_checkout422_response import CaptureCheckout422Response
21
+ from maytes_api_client.models.capture_checkout_request import CaptureCheckoutRequest
22
+ from maytes_api_client.models.capture_checkout_response import CaptureCheckoutResponse
23
+ from maytes_api_client.models.checkout import Checkout
24
+ from maytes_api_client.models.checkout_cancelled import CheckoutCancelled
25
+ from maytes_api_client.models.checkout_captured import CheckoutCaptured
26
+ from maytes_api_client.models.checkout_created import CheckoutCreated
27
+ from maytes_api_client.models.checkout_discount import CheckoutDiscount
28
+ from maytes_api_client.models.checkout_fee import CheckoutFee
29
+ from maytes_api_client.models.create_checkout401_response import CreateCheckout401Response
30
+ from maytes_api_client.models.create_checkout409_response import CreateCheckout409Response
31
+ from maytes_api_client.models.create_checkout422_response import CreateCheckout422Response
32
+ from maytes_api_client.models.create_checkout_request import CreateCheckoutRequest
33
+ from maytes_api_client.models.create_checkout_response import CreateCheckoutResponse
34
+ from maytes_api_client.models.create_refund_request import CreateRefundRequest
35
+ from maytes_api_client.models.customer_data import CustomerData
36
+ from maytes_api_client.models.digital_goods_custom_data import DigitalGoodsCustomData
37
+ from maytes_api_client.models.digital_goods_line_item import DigitalGoodsLineItem
38
+ from maytes_api_client.models.donation_line_item import DonationLineItem
39
+ from maytes_api_client.models.error_response_dto import ErrorResponseDto
40
+ from maytes_api_client.models.fee import Fee
41
+ from maytes_api_client.models.fee_breakdown_line import FeeBreakdownLine
42
+ from maytes_api_client.models.food_beverage_line_item import FoodBeverageLineItem
43
+ from maytes_api_client.models.get_checkout404_response import GetCheckout404Response
44
+ from maytes_api_client.models.get_checkout422_response import GetCheckout422Response
45
+ from maytes_api_client.models.get_checkout_response import GetCheckoutResponse
46
+ from maytes_api_client.models.get_settlement_response import GetSettlementResponse
47
+ from maytes_api_client.models.health_response import HealthResponse
48
+ from maytes_api_client.models.line_item import LineItem
49
+ from maytes_api_client.models.list_settlements_response import ListSettlementsResponse
50
+ from maytes_api_client.models.o_auth_token_request import OAuthTokenRequest
51
+ from maytes_api_client.models.o_auth_token_response import OAuthTokenResponse
52
+ from maytes_api_client.models.other_line_item import OtherLineItem
53
+ from maytes_api_client.models.physical_goods_custom_data import PhysicalGoodsCustomData
54
+ from maytes_api_client.models.physical_goods_line_item import PhysicalGoodsLineItem
55
+ from maytes_api_client.models.refund_checkout402_response import RefundCheckout402Response
56
+ from maytes_api_client.models.refund_checkout409_response import RefundCheckout409Response
57
+ from maytes_api_client.models.service_custom_data import ServiceCustomData
58
+ from maytes_api_client.models.service_line_item import ServiceLineItem
59
+ from maytes_api_client.models.settlement import Settlement
60
+ from maytes_api_client.models.tax import Tax
61
+ from maytes_api_client.models.ticket_custom_data import TicketCustomData
62
+ from maytes_api_client.models.ticket_line_item import TicketLineItem
63
+ from maytes_api_client.models.ticket_seating import TicketSeating
64
+
@@ -0,0 +1,101 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Maytes API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+ from pydantic_core import to_jsonable_python
25
+
26
+ class CancelCheckout409Response(BaseModel):
27
+ """
28
+ CancelCheckout409Response
29
+ """ # noqa: E501
30
+ message: StrictStr
31
+ error: StrictStr
32
+ code: StrictStr
33
+ metadata: Optional[Dict[str, Any]] = None
34
+ __properties: ClassVar[List[str]] = ["message", "error", "code", "metadata"]
35
+
36
+ @field_validator('code')
37
+ def code_validate_enum(cls, value):
38
+ """Validates the enum"""
39
+ if value not in set(['session_not_voidable']):
40
+ raise ValueError("must be one of enum values ('session_not_voidable')")
41
+ return value
42
+
43
+ model_config = ConfigDict(
44
+ validate_by_name=True,
45
+ validate_by_alias=True,
46
+ validate_assignment=True,
47
+ protected_namespaces=(),
48
+ )
49
+
50
+
51
+ def to_str(self) -> str:
52
+ """Returns the string representation of the model using alias"""
53
+ return pprint.pformat(self.model_dump(by_alias=True))
54
+
55
+ def to_json(self) -> str:
56
+ """Returns the JSON representation of the model using alias"""
57
+ return json.dumps(to_jsonable_python(self.to_dict()))
58
+
59
+ @classmethod
60
+ def from_json(cls, json_str: str) -> Optional[Self]:
61
+ """Create an instance of CancelCheckout409Response from a JSON string"""
62
+ return cls.from_dict(json.loads(json_str))
63
+
64
+ def to_dict(self) -> Dict[str, Any]:
65
+ """Return the dictionary representation of the model using alias.
66
+
67
+ This has the following differences from calling pydantic's
68
+ `self.model_dump(by_alias=True)`:
69
+
70
+ * `None` is only added to the output dict for nullable fields that
71
+ were set at model initialization. Other fields with value `None`
72
+ are ignored.
73
+ """
74
+ excluded_fields: Set[str] = set([
75
+ ])
76
+
77
+ _dict = self.model_dump(
78
+ by_alias=True,
79
+ exclude=excluded_fields,
80
+ exclude_none=True,
81
+ )
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of CancelCheckout409Response from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "message": obj.get("message"),
95
+ "error": obj.get("error"),
96
+ "code": obj.get("code"),
97
+ "metadata": obj.get("metadata")
98
+ })
99
+ return _obj
100
+
101
+
@@ -0,0 +1,88 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Maytes API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+ from pydantic_core import to_jsonable_python
25
+
26
+ class CancelCheckoutRequest(BaseModel):
27
+ """
28
+ CancelCheckoutRequest
29
+ """ # noqa: E501
30
+ merchant_order_id: Optional[StrictStr] = None
31
+ __properties: ClassVar[List[str]] = ["merchant_order_id"]
32
+
33
+ model_config = ConfigDict(
34
+ validate_by_name=True,
35
+ validate_by_alias=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ return json.dumps(to_jsonable_python(self.to_dict()))
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of CancelCheckoutRequest from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ return _dict
73
+
74
+ @classmethod
75
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
76
+ """Create an instance of CancelCheckoutRequest from a dict"""
77
+ if obj is None:
78
+ return None
79
+
80
+ if not isinstance(obj, dict):
81
+ return cls.model_validate(obj)
82
+
83
+ _obj = cls.model_validate({
84
+ "merchant_order_id": obj.get("merchant_order_id")
85
+ })
86
+ return _obj
87
+
88
+