vortex-sdk 0.2.0__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 (123) hide show
  1. vortex/__init__.py +265 -0
  2. vortex/api/__init__.py +24 -0
  3. vortex/api/billing_api.py +34608 -0
  4. vortex/api/catalog_api.py +708 -0
  5. vortex/api/checkout_api.py +372 -0
  6. vortex/api/credit_notes_api.py +1688 -0
  7. vortex/api/customer_balance_api.py +1747 -0
  8. vortex/api/customers_api.py +387 -0
  9. vortex/api/discounts_api.py +2623 -0
  10. vortex/api/entitlements_api.py +1646 -0
  11. vortex/api/hosted_api.py +2855 -0
  12. vortex/api/invoices_api.py +2402 -0
  13. vortex/api/payables_api.py +1380 -0
  14. vortex/api/payment_methods_api.py +2069 -0
  15. vortex/api/payment_requests_api.py +1877 -0
  16. vortex/api/payments_api.py +694 -0
  17. vortex/api/payments_readiness_api.py +2311 -0
  18. vortex/api/public_api.py +6931 -0
  19. vortex/api/quotes_api.py +6817 -0
  20. vortex/api/receipts_api.py +1111 -0
  21. vortex/api/subscriptions_api.py +1059 -0
  22. vortex/api/tax_api.py +1397 -0
  23. vortex/api/webhooks_api.py +4931 -0
  24. vortex/api_client.py +804 -0
  25. vortex/api_response.py +21 -0
  26. vortex/configuration.py +658 -0
  27. vortex/exceptions.py +218 -0
  28. vortex/models/__init__.py +104 -0
  29. vortex/models/api_error.py +103 -0
  30. vortex/models/api_error_error.py +114 -0
  31. vortex/models/api_write_envelope.py +101 -0
  32. vortex/models/apply_coupon_request.py +97 -0
  33. vortex/models/billing_order_form_sign_request.py +103 -0
  34. vortex/models/billing_order_form_signature_request_request.py +86 -0
  35. vortex/models/billing_order_form_void_request.py +86 -0
  36. vortex/models/billing_order_forms_expire_due_request.py +90 -0
  37. vortex/models/billing_order_update_request.py +99 -0
  38. vortex/models/billing_orders_execute_due_request.py +90 -0
  39. vortex/models/billing_quote_create_request.py +119 -0
  40. vortex/models/billing_quote_line_input.py +93 -0
  41. vortex/models/billing_quote_version_approve_request.py +87 -0
  42. vortex/models/billing_quote_version_create_request.py +103 -0
  43. vortex/models/billing_quote_version_update_request.py +102 -0
  44. vortex/models/billing_quote_version_void_request.py +96 -0
  45. vortex/models/checkout_session_line_item_request.py +91 -0
  46. vortex/models/coupon_targets.py +89 -0
  47. vortex/models/create_checkout_session_request.py +140 -0
  48. vortex/models/create_coupon_request.py +132 -0
  49. vortex/models/create_deposit_balance_payable_request.py +172 -0
  50. vortex/models/create_installment_payable_request.py +170 -0
  51. vortex/models/create_payable_request.py +158 -0
  52. vortex/models/create_recurring_payable_request.py +181 -0
  53. vortex/models/create_recurring_payable_request_cadence.py +96 -0
  54. vortex/models/credit_note_create_line.py +105 -0
  55. vortex/models/credit_note_create_request.py +112 -0
  56. vortex/models/credit_note_reason.py +39 -0
  57. vortex/models/credit_note_refund_reconcile_request.py +86 -0
  58. vortex/models/credit_note_refund_request.py +94 -0
  59. vortex/models/customer_balance_targets.py +102 -0
  60. vortex/models/customer_default_payment_method_request.py +88 -0
  61. vortex/models/customer_payment_method_archive_request.py +88 -0
  62. vortex/models/customer_payment_method_attach_request.py +94 -0
  63. vortex/models/customer_payment_method_setup_request.py +100 -0
  64. vortex/models/customer_upsert_request.py +96 -0
  65. vortex/models/expire_customer_balance_request.py +98 -0
  66. vortex/models/grant_customer_balance_from_payment_request.py +103 -0
  67. vortex/models/grant_customer_balance_request.py +106 -0
  68. vortex/models/grant_entitlement_request.py +106 -0
  69. vortex/models/invoice_collect_request.py +86 -0
  70. vortex/models/invoice_create_request.py +92 -0
  71. vortex/models/invoice_finalize_request.py +86 -0
  72. vortex/models/invoice_mark_uncollectible_request.py +90 -0
  73. vortex/models/invoice_tax.py +142 -0
  74. vortex/models/invoice_void_request.py +88 -0
  75. vortex/models/merchant_account_create_request.py +183 -0
  76. vortex/models/merchant_address.py +96 -0
  77. vortex/models/merchant_associated_identity.py +114 -0
  78. vortex/models/merchant_onboarding_link_request.py +95 -0
  79. vortex/models/merchant_profile_date.py +90 -0
  80. vortex/models/merchant_settlement_bank_account.py +94 -0
  81. vortex/models/merchant_tax_profile_request.py +125 -0
  82. vortex/models/merchant_tax_profile_request_registrations_inner.py +88 -0
  83. vortex/models/merchant_underwriting_data.py +127 -0
  84. vortex/models/merchant_underwriting_data_card_volume_distribution.py +90 -0
  85. vortex/models/merchant_underwriting_data_volume_distribution_by_business_type.py +90 -0
  86. vortex/models/open_api_invoice_tax_response.py +92 -0
  87. vortex/models/open_api_invoice_tax_response_all_of_data.py +92 -0
  88. vortex/models/payment_request_collect_request.py +86 -0
  89. vortex/models/payment_request_create_request.py +100 -0
  90. vortex/models/payment_request_link_create_request.py +89 -0
  91. vortex/models/price_create_request.py +122 -0
  92. vortex/models/product_create_request.py +92 -0
  93. vortex/models/reverse_customer_balance_request.py +98 -0
  94. vortex/models/revoke_entitlement_request.py +106 -0
  95. vortex/models/subscription_change_request.py +111 -0
  96. vortex/models/subscription_create_request.py +122 -0
  97. vortex/models/subscription_item_change_preview_request.py +100 -0
  98. vortex/models/subscription_item_change_request_item.py +91 -0
  99. vortex/models/tax_address.py +96 -0
  100. vortex/models/tax_behavior.py +36 -0
  101. vortex/models/tax_behavior_policy.py +100 -0
  102. vortex/models/tax_behavior_policy_request.py +89 -0
  103. vortex/models/tax_failure.py +104 -0
  104. vortex/models/tax_finalize_request.py +98 -0
  105. vortex/models/tax_jurisdiction_evidence.py +94 -0
  106. vortex/models/tax_line_evidence.py +103 -0
  107. vortex/models/tax_quote_request.py +98 -0
  108. vortex/models/terminate_applied_coupon_request.py +87 -0
  109. vortex/models/terminate_coupon_request.py +87 -0
  110. vortex/models/webhook_deliveries_dispatch_request.py +91 -0
  111. vortex/models/webhook_deliveries_redrive_request.py +107 -0
  112. vortex/models/webhook_delivery_replay_request.py +88 -0
  113. vortex/models/webhook_endpoint_create_request.py +91 -0
  114. vortex/models/webhook_endpoint_secret_rotate_request.py +87 -0
  115. vortex/models/webhook_endpoint_test_request.py +88 -0
  116. vortex/models/webhook_endpoint_update_request.py +103 -0
  117. vortex/models/webhook_event_resend_request.py +86 -0
  118. vortex/rest.py +263 -0
  119. vortex_sdk-0.2.0.dist-info/METADATA +34 -0
  120. vortex_sdk-0.2.0.dist-info/RECORD +123 -0
  121. vortex_sdk-0.2.0.dist-info/WHEEL +5 -0
  122. vortex_sdk-0.2.0.dist-info/licenses/LICENSE +21 -0
  123. vortex_sdk-0.2.0.dist-info/top_level.txt +1 -0
vortex/api_response.py ADDED
@@ -0,0 +1,21 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Optional, Generic, Mapping, TypeVar
5
+ from pydantic import Field, StrictInt, StrictBytes, BaseModel
6
+
7
+ T = TypeVar("T")
8
+
9
+ class ApiResponse(BaseModel, Generic[T]):
10
+ """
11
+ API response object
12
+ """
13
+
14
+ status_code: StrictInt = Field(description="HTTP status code")
15
+ headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
16
+ data: T = Field(description="Deserialized data given the data type")
17
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
18
+
19
+ model_config = {
20
+ "arbitrary_types_allowed": True
21
+ }
@@ -0,0 +1,658 @@
1
+ """
2
+ Vortex Payments API
3
+
4
+ Public Vortex Payments API for customers, subscriptions, invoices, payment requests, checkout, receipts, webhooks, tax.
5
+
6
+ The version of the OpenAPI document: 2026-08
7
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
8
+
9
+ Do not edit the class manually.
10
+ """ # noqa: E501
11
+
12
+
13
+ import copy
14
+ import http.client as httplib
15
+ import logging
16
+ from logging import FileHandler
17
+ import multiprocessing
18
+ import sys
19
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
20
+ from typing_extensions import NotRequired, Self
21
+
22
+ import urllib3
23
+
24
+
25
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
26
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
27
+ 'minimum', 'exclusiveMinimum', 'maxLength',
28
+ 'minLength', 'pattern', 'maxItems', 'minItems'
29
+ }
30
+
31
+ ServerVariablesT = Dict[str, str]
32
+
33
+ GenericAuthSetting = TypedDict(
34
+ "GenericAuthSetting",
35
+ {
36
+ "type": str,
37
+ "in": str,
38
+ "key": str,
39
+ "value": str,
40
+ },
41
+ )
42
+
43
+
44
+ OAuth2AuthSetting = TypedDict(
45
+ "OAuth2AuthSetting",
46
+ {
47
+ "type": Literal["oauth2"],
48
+ "in": Literal["header"],
49
+ "key": Literal["Authorization"],
50
+ "value": str,
51
+ },
52
+ )
53
+
54
+
55
+ APIKeyAuthSetting = TypedDict(
56
+ "APIKeyAuthSetting",
57
+ {
58
+ "type": Literal["api_key"],
59
+ "in": str,
60
+ "key": str,
61
+ "value": Optional[str],
62
+ },
63
+ )
64
+
65
+
66
+ BasicAuthSetting = TypedDict(
67
+ "BasicAuthSetting",
68
+ {
69
+ "type": Literal["basic"],
70
+ "in": Literal["header"],
71
+ "key": Literal["Authorization"],
72
+ "value": Optional[str],
73
+ },
74
+ )
75
+
76
+
77
+ BearerFormatAuthSetting = TypedDict(
78
+ "BearerFormatAuthSetting",
79
+ {
80
+ "type": Literal["bearer"],
81
+ "in": Literal["header"],
82
+ "format": Literal["JWT"],
83
+ "key": Literal["Authorization"],
84
+ "value": str,
85
+ },
86
+ )
87
+
88
+
89
+ BearerAuthSetting = TypedDict(
90
+ "BearerAuthSetting",
91
+ {
92
+ "type": Literal["bearer"],
93
+ "in": Literal["header"],
94
+ "key": Literal["Authorization"],
95
+ "value": str,
96
+ },
97
+ )
98
+
99
+
100
+ HTTPSignatureAuthSetting = TypedDict(
101
+ "HTTPSignatureAuthSetting",
102
+ {
103
+ "type": Literal["http-signature"],
104
+ "in": Literal["header"],
105
+ "key": Literal["Authorization"],
106
+ "value": None,
107
+ },
108
+ )
109
+
110
+
111
+ AuthSettings = TypedDict(
112
+ "AuthSettings",
113
+ {
114
+ "api-key": BearerAuthSetting,
115
+ "checkout-token": APIKeyAuthSetting,
116
+ "session-cookie": APIKeyAuthSetting,
117
+ "provider-signature": APIKeyAuthSetting,
118
+ },
119
+ total=False,
120
+ )
121
+
122
+
123
+ class HostSettingVariable(TypedDict):
124
+ description: str
125
+ default_value: str
126
+ enum_values: List[str]
127
+
128
+
129
+ class HostSetting(TypedDict):
130
+ url: str
131
+ description: str
132
+ variables: NotRequired[Dict[str, HostSettingVariable]]
133
+
134
+
135
+ class Configuration:
136
+ """This class contains various settings of the API client.
137
+
138
+ :param host: Base url.
139
+ :param ignore_operation_servers
140
+ Boolean to ignore operation servers for the API client.
141
+ Config will use `host` as the base url regardless of the operation servers.
142
+ :param api_key: Dict to store API key(s).
143
+ Each entry in the dict specifies an API key.
144
+ The dict key is the name of the security scheme in the OAS specification.
145
+ The dict value is the API key secret.
146
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
147
+ The dict key is the name of the security scheme in the OAS specification.
148
+ The dict value is an API key prefix when generating the auth data.
149
+ :param username: Username for HTTP basic authentication.
150
+ :param password: Password for HTTP basic authentication.
151
+ :param access_token: Access token.
152
+ :param server_index: Index to servers configuration.
153
+ :param server_variables: Mapping with string values to replace variables in
154
+ templated server configuration. The validation of enums is performed for
155
+ variables with defined enum values before.
156
+ :param server_operation_index: Mapping from operation ID to an index to server
157
+ configuration.
158
+ :param server_operation_variables: Mapping from operation ID to a mapping with
159
+ string values to replace variables in templated server configuration.
160
+ The validation of enums is performed for variables with defined enum
161
+ values before.
162
+ :param verify_ssl: bool - Set this to false to skip verifying SSL certificate
163
+ when calling API from https server.
164
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
165
+ in PEM format.
166
+ :param retries: int | urllib3.util.retry.Retry - Retry configuration.
167
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
168
+ in PEM (str) or DER (bytes) format.
169
+ :param cert_file: the path to a client certificate file, for mTLS.
170
+ :param key_file: the path to a client key file, for mTLS.
171
+ :param assert_hostname: Set this to True/False to enable/disable SSL hostname verification.
172
+ :param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server.
173
+ :param connection_pool_maxsize: Connection pool max size. None in the constructor is coerced to 100 for async and cpu_count * 5 for sync.
174
+ :param proxy: Proxy URL.
175
+ :param proxy_headers: Proxy headers.
176
+ :param safe_chars_for_path_param: Safe characters for path parameter encoding.
177
+ :param client_side_validation: Enable client-side validation. Default True.
178
+ :param socket_options: Options to pass down to the underlying urllib3 socket.
179
+ :param datetime_format: Datetime format string for serialization.
180
+ :param date_format: Date format string for serialization.
181
+
182
+ :Example:
183
+
184
+ API Key Authentication Example.
185
+ Given the following security scheme in the OpenAPI specification:
186
+ components:
187
+ securitySchemes:
188
+ cookieAuth: # name for the security scheme
189
+ type: apiKey
190
+ in: cookie
191
+ name: JSESSIONID # cookie name
192
+
193
+ You can programmatically set the cookie:
194
+
195
+ conf = vortex.Configuration(
196
+ api_key={'cookieAuth': 'abc123'}
197
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
198
+ )
199
+
200
+ The following cookie will be added to the HTTP request:
201
+ Cookie: JSESSIONID abc123
202
+ """
203
+
204
+ _default: ClassVar[Optional[Self]] = None
205
+
206
+ def __init__(
207
+ self,
208
+ host: Optional[str]=None,
209
+ api_key: Optional[Dict[str, str]]=None,
210
+ api_key_prefix: Optional[Dict[str, str]]=None,
211
+ username: Optional[str]=None,
212
+ password: Optional[str]=None,
213
+ access_token: Optional[str]=None,
214
+ server_index: Optional[int]=None,
215
+ server_variables: Optional[ServerVariablesT]=None,
216
+ server_operation_index: Optional[Dict[int, int]]=None,
217
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
218
+ ignore_operation_servers: bool=False,
219
+ ssl_ca_cert: Optional[str]=None,
220
+ retries: Optional[Union[int, urllib3.util.retry.Retry]] = None,
221
+ ca_cert_data: Optional[Union[str, bytes]] = None,
222
+ cert_file: Optional[str]=None,
223
+ key_file: Optional[str]=None,
224
+ verify_ssl: bool=True,
225
+ assert_hostname: Optional[bool]=None,
226
+ tls_server_name: Optional[str]=None,
227
+ connection_pool_maxsize: Optional[int]=None,
228
+ proxy: Optional[str]=None,
229
+ proxy_headers: Optional[Any]=None,
230
+ safe_chars_for_path_param: str='',
231
+ client_side_validation: bool=True,
232
+ socket_options: Optional[Any]=None,
233
+ datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
234
+ date_format: str="%Y-%m-%d",
235
+ *,
236
+ debug: Optional[bool] = None,
237
+ ) -> None:
238
+ """Constructor
239
+ """
240
+ self._base_path = "https://api.vortex.nyc" if host is None else host
241
+ """Default Base url
242
+ """
243
+ self.server_index = 0 if server_index is None and host is None else server_index
244
+ self.server_operation_index = server_operation_index or {}
245
+ """Default server index
246
+ """
247
+ self.server_variables = server_variables or {}
248
+ self.server_operation_variables = server_operation_variables or {}
249
+ """Default server variables
250
+ """
251
+ self.ignore_operation_servers = ignore_operation_servers
252
+ """Ignore operation servers
253
+ """
254
+ self.temp_folder_path = None
255
+ """Temp file folder for downloading files
256
+ """
257
+ # Authentication Settings
258
+ self.api_key = {}
259
+ if api_key:
260
+ self.api_key = api_key
261
+ """dict to store API key(s)
262
+ """
263
+ self.api_key_prefix = {}
264
+ if api_key_prefix:
265
+ self.api_key_prefix = api_key_prefix
266
+ """dict to store API prefix (e.g. Bearer)
267
+ """
268
+ self.refresh_api_key_hook = None
269
+ """function hook to refresh API key if expired
270
+ """
271
+ self.username = username
272
+ """Username for HTTP basic authentication
273
+ """
274
+ self.password = password
275
+ """Password for HTTP basic authentication
276
+ """
277
+ self.access_token = access_token
278
+ """Access token
279
+ """
280
+ self.logger = {}
281
+ """Logging Settings
282
+ """
283
+ self.logger["package_logger"] = logging.getLogger("vortex")
284
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
285
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
286
+ """Log format
287
+ """
288
+ self.logger_stream_handler = None
289
+ """Log stream handler
290
+ """
291
+ self.logger_file_handler: Optional[FileHandler] = None
292
+ """Log file handler
293
+ """
294
+ self.logger_file = None
295
+ """Debug file location
296
+ """
297
+ if debug is not None:
298
+ self.debug = debug
299
+ else:
300
+ self.__debug = False
301
+ """Debug switch
302
+ """
303
+
304
+ self.verify_ssl = verify_ssl
305
+ """SSL/TLS verification
306
+ Set this to false to skip verifying SSL certificate when calling API
307
+ from https server.
308
+ """
309
+ self.ssl_ca_cert = ssl_ca_cert
310
+ """Set this to customize the certificate file to verify the peer.
311
+ """
312
+ self.ca_cert_data = ca_cert_data
313
+ """Set this to verify the peer using PEM (str) or DER (bytes)
314
+ certificate data.
315
+ """
316
+ self.cert_file = cert_file
317
+ """client certificate file
318
+ """
319
+ self.key_file = key_file
320
+ """client key file
321
+ """
322
+ self.assert_hostname = assert_hostname
323
+ """Set this to True/False to enable/disable SSL hostname verification.
324
+ """
325
+ self.tls_server_name = tls_server_name
326
+ """SSL/TLS Server Name Indication (SNI)
327
+ Set this to the SNI value expected by the server.
328
+ """
329
+
330
+ self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else multiprocessing.cpu_count() * 5
331
+ """urllib3 connection pool's maximum number of connections saved
332
+ per pool. None in the constructor is coerced to cpu_count * 5.
333
+ """
334
+
335
+ self.proxy = proxy
336
+ """Proxy URL
337
+ """
338
+ self.proxy_headers = proxy_headers
339
+ """Proxy headers
340
+ """
341
+ self.safe_chars_for_path_param = safe_chars_for_path_param
342
+ """Safe chars for path_param
343
+ """
344
+ self.retries = retries
345
+ """Retry configuration
346
+ """
347
+ # Enable client side validation
348
+ self.client_side_validation = client_side_validation
349
+
350
+ self.socket_options = socket_options
351
+ """Options to pass down to the underlying urllib3 socket
352
+ """
353
+
354
+ self.datetime_format = datetime_format
355
+ """datetime format
356
+ """
357
+
358
+ self.date_format = date_format
359
+ """date format
360
+ """
361
+
362
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
363
+ cls = self.__class__
364
+ result = cls.__new__(cls)
365
+ memo[id(self)] = result
366
+ for k, v in self.__dict__.items():
367
+ if k not in ('logger', 'logger_file_handler'):
368
+ setattr(result, k, copy.deepcopy(v, memo))
369
+ # shallow copy of loggers
370
+ result.logger = copy.copy(self.logger)
371
+ # use setters to configure loggers
372
+ result.logger_file = self.logger_file
373
+ result.debug = self.debug
374
+ return result
375
+
376
+ def __setattr__(self, name: str, value: Any) -> None:
377
+ object.__setattr__(self, name, value)
378
+
379
+ @classmethod
380
+ def set_default(cls, default: Optional[Self]) -> None:
381
+ """Set default instance of configuration.
382
+
383
+ It stores default configuration, which can be
384
+ returned by get_default_copy method.
385
+
386
+ :param default: object of Configuration
387
+ """
388
+ cls._default = default
389
+
390
+ @classmethod
391
+ def get_default_copy(cls) -> Self:
392
+ """Deprecated. Please use `get_default` instead.
393
+
394
+ Deprecated. Please use `get_default` instead.
395
+
396
+ :return: The configuration object.
397
+ """
398
+ return cls.get_default()
399
+
400
+ @classmethod
401
+ def get_default(cls) -> Self:
402
+ """Return the default configuration.
403
+
404
+ This method returns newly created, based on default constructor,
405
+ object of Configuration class or returns a copy of default
406
+ configuration.
407
+
408
+ :return: The configuration object.
409
+ """
410
+ if cls._default is None:
411
+ cls._default = cls()
412
+ return cls._default
413
+
414
+ @property
415
+ def logger_file(self) -> Optional[str]:
416
+ """The logger file.
417
+
418
+ If the logger_file is None, then add stream handler and remove file
419
+ handler. Otherwise, add file handler and remove stream handler.
420
+
421
+ :param value: The logger_file path.
422
+ :type: str
423
+ """
424
+ return self.__logger_file
425
+
426
+ @logger_file.setter
427
+ def logger_file(self, value: Optional[str]) -> None:
428
+ """The logger file.
429
+
430
+ If the logger_file is None, then add stream handler and remove file
431
+ handler. Otherwise, add file handler and remove stream handler.
432
+
433
+ :param value: The logger_file path.
434
+ :type: str
435
+ """
436
+ self.__logger_file = value
437
+ if self.__logger_file:
438
+ # If set logging file,
439
+ # then add file handler and remove stream handler.
440
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
441
+ self.logger_file_handler.setFormatter(self.logger_formatter)
442
+ for _, logger in self.logger.items():
443
+ logger.addHandler(self.logger_file_handler)
444
+
445
+ @property
446
+ def debug(self) -> bool:
447
+ """Debug status
448
+
449
+ :param value: The debug status, True or False.
450
+ :type: bool
451
+ """
452
+ return self.__debug
453
+
454
+ @debug.setter
455
+ def debug(self, value: bool) -> None:
456
+ """Debug status
457
+
458
+ :param value: The debug status, True or False.
459
+ :type: bool
460
+ """
461
+ self.__debug = value
462
+ if self.__debug:
463
+ # if debug status is True, turn on debug logging
464
+ for _, logger in self.logger.items():
465
+ logger.setLevel(logging.DEBUG)
466
+ # turn on httplib debug
467
+ httplib.HTTPConnection.debuglevel = 1
468
+ else:
469
+ # if debug status is False, turn off debug logging,
470
+ # setting log level to default `logging.WARNING`
471
+ for _, logger in self.logger.items():
472
+ logger.setLevel(logging.WARNING)
473
+ # turn off httplib debug
474
+ httplib.HTTPConnection.debuglevel = 0
475
+
476
+ @property
477
+ def logger_format(self) -> str:
478
+ """The logger format.
479
+
480
+ The logger_formatter will be updated when sets logger_format.
481
+
482
+ :param value: The format string.
483
+ :type: str
484
+ """
485
+ return self.__logger_format
486
+
487
+ @logger_format.setter
488
+ def logger_format(self, value: str) -> None:
489
+ """The logger format.
490
+
491
+ The logger_formatter will be updated when sets logger_format.
492
+
493
+ :param value: The format string.
494
+ :type: str
495
+ """
496
+ self.__logger_format = value
497
+ self.logger_formatter = logging.Formatter(self.__logger_format)
498
+
499
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
500
+ """Gets API key (with prefix if set).
501
+
502
+ :param identifier: The identifier of apiKey.
503
+ :param alias: The alternative identifier of apiKey.
504
+ :return: The token for api key authentication.
505
+ """
506
+ if self.refresh_api_key_hook is not None:
507
+ self.refresh_api_key_hook(self)
508
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
509
+ if key:
510
+ prefix = self.api_key_prefix.get(identifier)
511
+ if prefix:
512
+ return "%s %s" % (prefix, key)
513
+ else:
514
+ return key
515
+
516
+ return None
517
+
518
+ def get_basic_auth_token(self) -> Optional[str]:
519
+ """Gets HTTP basic authentication header (string).
520
+
521
+ :return: The token for basic HTTP authentication.
522
+ """
523
+ username = ""
524
+ if self.username is not None:
525
+ username = self.username
526
+ password = ""
527
+ if self.password is not None:
528
+ password = self.password
529
+
530
+ return urllib3.util.make_headers(
531
+ basic_auth=username + ':' + password
532
+ ).get('authorization')
533
+
534
+ def auth_settings(self)-> AuthSettings:
535
+ """Gets Auth Settings dict for api client.
536
+
537
+ :return: The Auth Settings information dict.
538
+ """
539
+ auth: AuthSettings = {}
540
+ if self.access_token is not None:
541
+ auth['api-key'] = {
542
+ 'type': 'bearer',
543
+ 'in': 'header',
544
+ 'key': 'Authorization',
545
+ 'value': 'Bearer ' + self.access_token
546
+ }
547
+ if 'checkout-token' in self.api_key:
548
+ auth['checkout-token'] = {
549
+ 'type': 'api_key',
550
+ 'in': 'query',
551
+ 'key': 'token',
552
+ 'value': self.get_api_key_with_prefix(
553
+ 'checkout-token',
554
+ ),
555
+ }
556
+ if 'session-cookie' in self.api_key:
557
+ auth['session-cookie'] = {
558
+ 'type': 'api_key',
559
+ 'in': 'cookie',
560
+ 'key': 'better-auth.session_token',
561
+ 'value': self.get_api_key_with_prefix(
562
+ 'session-cookie',
563
+ ),
564
+ }
565
+ if 'provider-signature' in self.api_key:
566
+ auth['provider-signature'] = {
567
+ 'type': 'api_key',
568
+ 'in': 'header',
569
+ 'key': 'X-Provider-Signature',
570
+ 'value': self.get_api_key_with_prefix(
571
+ 'provider-signature',
572
+ ),
573
+ }
574
+ return auth
575
+
576
+ def to_debug_report(self) -> str:
577
+ """Gets the essential information for debugging.
578
+
579
+ :return: The report for debugging.
580
+ """
581
+ return "Python SDK Debug Report:\n"\
582
+ "OS: {env}\n"\
583
+ "Python Version: {pyversion}\n"\
584
+ "Version of the API: 2026-08\n"\
585
+ "SDK Package Version: 0.2.0".\
586
+ format(env=sys.platform, pyversion=sys.version)
587
+
588
+ def get_host_settings(self) -> List[HostSetting]:
589
+ """Gets an array of host settings
590
+
591
+ :return: An array of host settings
592
+ """
593
+ return [
594
+ {
595
+ 'url': "https://api.vortex.nyc",
596
+ 'description': "Production",
597
+ },
598
+ {
599
+ 'url': "http://localhost:3210",
600
+ 'description': "Local development",
601
+ }
602
+ ]
603
+
604
+ def get_host_from_settings(
605
+ self,
606
+ index: Optional[int],
607
+ variables: Optional[ServerVariablesT]=None,
608
+ servers: Optional[List[HostSetting]]=None,
609
+ ) -> str:
610
+ """Gets host URL based on the index and variables
611
+ :param index: array index of the host settings
612
+ :param variables: hash of variable and the corresponding value
613
+ :param servers: an array of host settings or None
614
+ :return: URL based on host settings
615
+ """
616
+ if index is None:
617
+ return self._base_path
618
+
619
+ variables = {} if variables is None else variables
620
+ servers = self.get_host_settings() if servers is None else servers
621
+
622
+ try:
623
+ server = servers[index]
624
+ except IndexError:
625
+ raise ValueError(
626
+ "Invalid index {0} when selecting the host settings. "
627
+ "Must be less than {1}".format(index, len(servers)))
628
+
629
+ url = server['url']
630
+
631
+ # go through variables and replace placeholders
632
+ for variable_name, variable in server.get('variables', {}).items():
633
+ used_value = variables.get(
634
+ variable_name, variable['default_value'])
635
+
636
+ if 'enum_values' in variable \
637
+ and variable['enum_values'] \
638
+ and used_value not in variable['enum_values']:
639
+ raise ValueError(
640
+ "The variable `{0}` in the host URL has invalid value "
641
+ "{1}. Must be {2}.".format(
642
+ variable_name, variables[variable_name],
643
+ variable['enum_values']))
644
+
645
+ url = url.replace("{" + variable_name + "}", used_value)
646
+
647
+ return url
648
+
649
+ @property
650
+ def host(self) -> str:
651
+ """Return generated host."""
652
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
653
+
654
+ @host.setter
655
+ def host(self, value: str) -> None:
656
+ """Fix base path."""
657
+ self._base_path = value
658
+ self.server_index = None