diff --git a/.fern/metadata.json b/.fern/metadata.json index 5e419280..cb5a4f8e 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -14,6 +14,6 @@ "use_typeddict_requests_for_file_upload": true, "exclude_types_from_init_exports": true }, - "originGitCommit": "b05364cda2b85e35d8daa9ff2c24bbabbbd9652a", - "sdkVersion": "45.1.0.20260819" + "originGitCommit": "f74d4b7e34b9b8676dc4b58d83a38111dc1d595f", + "sdkVersion": "46.0.0.20260916" } \ No newline at end of file diff --git a/.fern/replay.lock b/.fern/replay.lock index 8ec9716a..7e326947 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -24,5 +24,11 @@ generations: cli_version: unknown generator_versions: fernapi/fern-python-sdk: 4.55.4 -current_generation: cd6e74f053ff22480919bf8c49a452ef62eab4c4 + - commit_sha: 8945a811d575b471777260340645e576ab8b11b1 + tree_hash: 2a0195817e6dd8ff191ec7182429a00d15cececa + timestamp: 2026-09-15T18:46:24.128Z + cli_version: unknown + generator_versions: + fernapi/fern-python-sdk: 4.55.4 +current_generation: 8945a811d575b471777260340645e576ab8b11b1 patches: [] diff --git a/pyproject.toml b/pyproject.toml index c1e9e170..ee07a0c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ dynamic = ["version"] [tool.poetry] name = "squareup" -version = "45.1.0.20260819" +version = "46.0.0.20260916" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 20ee0f36..1cb271f8 100644 --- a/reference.md +++ b/reference.md @@ -8872,62 +8872,6 @@ See the [Pagination](https://developer.squareup.com/docs/working-with-apis/pagin - - - - -
client.inventory.get_transfer(...) -> AsyncHttpResponse[None] -
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from square import Square - -client = Square( - token="YOUR_TOKEN", -) -client.inventory.get_transfer( - transfer_id="transfer_id", -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**transfer_id:** `str` - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- -
@@ -27420,174 +27364,6 @@ client.locations.transactions.get( - - - - -
client.locations.transactions.capture(...) -> AsyncHttpResponse[CaptureTransactionResponse] -
-
- -#### 📝 Description - -
-
- -
-
- -Captures a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) -endpoint with a `delay_capture` value of `true`. - - -See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) -for more information. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from square import Square - -client = Square( - token="YOUR_TOKEN", -) -client.locations.transactions.capture( - location_id="location_id", - transaction_id="transaction_id", -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**location_id:** `str` — - -
-
- -
-
- -**transaction_id:** `str` — - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- - -
-
-
- -
client.locations.transactions.void(...) -> AsyncHttpResponse[VoidTransactionResponse] -
-
- -#### 📝 Description - -
-
- -
-
- -Cancels a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) -endpoint with a `delay_capture` value of `true`. - - -See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) -for more information. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from square import Square - -client = Square( - token="YOUR_TOKEN", -) -client.locations.transactions.void( - location_id="location_id", - transaction_id="transaction_id", -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**location_id:** `str` — - -
-
- -
-
- -**transaction_id:** `str` — - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- -
diff --git a/src/square/core/client_wrapper.py b/src/square/core/client_wrapper.py index 765efaaf..a8c07e70 100644 --- a/src/square/core/client_wrapper.py +++ b/src/square/core/client_wrapper.py @@ -26,18 +26,18 @@ def get_headers(self) -> typing.Dict[str, str]: import platform headers: typing.Dict[str, str] = { - "User-Agent": "squareup/45.1.0.20260819", + "User-Agent": "squareup/46.0.0.20260916", "X-Fern-Language": "Python", "X-Fern-Runtime": f"python/{platform.python_version()}", "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}", "X-Fern-SDK-Name": "squareup", - "X-Fern-SDK-Version": "45.1.0.20260819", + "X-Fern-SDK-Version": "46.0.0.20260916", **(self.get_custom_headers() or {}), } token = self._get_token() if token is not None: headers["Authorization"] = f"Bearer {token}" - headers["Square-Version"] = self._version if self._version is not None else "2026-08-19" + headers["Square-Version"] = self._version if self._version is not None else "2026-09-16" return headers def _get_token(self) -> typing.Optional[str]: diff --git a/src/square/inventory/client.py b/src/square/inventory/client.py index 03e03441..b2b94a31 100644 --- a/src/square/inventory/client.py +++ b/src/square/inventory/client.py @@ -1168,33 +1168,6 @@ def changes( catalog_object_id, location_ids=location_ids, cursor=cursor, request_options=request_options ) - def get_transfer(self, transfer_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: - """ - Parameters - ---------- - transfer_id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - None - - Examples - -------- - from square import Square - - client = Square( - token="YOUR_TOKEN", - ) - client.inventory.get_transfer( - transfer_id="transfer_id", - ) - """ - _response = self._raw_client.get_transfer(transfer_id, request_options=request_options) - return _response.data - class AsyncInventoryClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -2487,38 +2460,3 @@ async def main() -> None: return await self._raw_client.changes( catalog_object_id, location_ids=location_ids, cursor=cursor, request_options=request_options ) - - async def get_transfer(self, transfer_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: - """ - Parameters - ---------- - transfer_id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - None - - Examples - -------- - import asyncio - - from square import AsyncSquare - - client = AsyncSquare( - token="YOUR_TOKEN", - ) - - - async def main() -> None: - await client.inventory.get_transfer( - transfer_id="transfer_id", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.get_transfer(transfer_id, request_options=request_options) - return _response.data diff --git a/src/square/inventory/raw_client.py b/src/square/inventory/raw_client.py index 9e965f32..781a1a51 100644 --- a/src/square/inventory/raw_client.py +++ b/src/square/inventory/raw_client.py @@ -1326,34 +1326,6 @@ def changes( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def get_transfer( - self, transfer_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> HttpResponse[None]: - """ - Parameters - ---------- - transfer_id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[None] - """ - _response = self._client_wrapper.httpx_client.request( - f"v2/inventory/transfers/{jsonable_encoder(transfer_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return HttpResponse(response=_response, data=None) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - class AsyncRawInventoryClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -2653,31 +2625,3 @@ async def _get_next(): except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def get_transfer( - self, transfer_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> AsyncHttpResponse[None]: - """ - Parameters - ---------- - transfer_id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[None] - """ - _response = await self._client_wrapper.httpx_client.request( - f"v2/inventory/transfers/{jsonable_encoder(transfer_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return AsyncHttpResponse(response=_response, data=None) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/square/locations/transactions/client.py b/src/square/locations/transactions/client.py index 2777b102..56a6e73f 100644 --- a/src/square/locations/transactions/client.py +++ b/src/square/locations/transactions/client.py @@ -4,11 +4,9 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions -from ...types.capture_transaction_response import CaptureTransactionResponse from ...types.get_transaction_response import GetTransactionResponse from ...types.list_transactions_response import ListTransactionsResponse from ...types.sort_order import SortOrder -from ...types.void_transaction_response import VoidTransactionResponse from .raw_client import AsyncRawTransactionsClient, RawTransactionsClient @@ -146,90 +144,6 @@ def get( _response = self._raw_client.get(location_id, transaction_id, request_options=request_options) return _response.data - def capture( - self, location_id: str, transaction_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> CaptureTransactionResponse: - """ - Captures a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) - endpoint with a `delay_capture` value of `true`. - - - See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) - for more information. - - Parameters - ---------- - location_id : str - - - transaction_id : str - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CaptureTransactionResponse - Success - - Examples - -------- - from square import Square - - client = Square( - token="YOUR_TOKEN", - ) - client.locations.transactions.capture( - location_id="location_id", - transaction_id="transaction_id", - ) - """ - _response = self._raw_client.capture(location_id, transaction_id, request_options=request_options) - return _response.data - - def void( - self, location_id: str, transaction_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> VoidTransactionResponse: - """ - Cancels a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) - endpoint with a `delay_capture` value of `true`. - - - See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) - for more information. - - Parameters - ---------- - location_id : str - - - transaction_id : str - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - VoidTransactionResponse - Success - - Examples - -------- - from square import Square - - client = Square( - token="YOUR_TOKEN", - ) - client.locations.transactions.void( - location_id="location_id", - transaction_id="transaction_id", - ) - """ - _response = self._raw_client.void(location_id, transaction_id, request_options=request_options) - return _response.data - class AsyncTransactionsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -380,103 +294,3 @@ async def main() -> None: """ _response = await self._raw_client.get(location_id, transaction_id, request_options=request_options) return _response.data - - async def capture( - self, location_id: str, transaction_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> CaptureTransactionResponse: - """ - Captures a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) - endpoint with a `delay_capture` value of `true`. - - - See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) - for more information. - - Parameters - ---------- - location_id : str - - - transaction_id : str - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CaptureTransactionResponse - Success - - Examples - -------- - import asyncio - - from square import AsyncSquare - - client = AsyncSquare( - token="YOUR_TOKEN", - ) - - - async def main() -> None: - await client.locations.transactions.capture( - location_id="location_id", - transaction_id="transaction_id", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.capture(location_id, transaction_id, request_options=request_options) - return _response.data - - async def void( - self, location_id: str, transaction_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> VoidTransactionResponse: - """ - Cancels a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) - endpoint with a `delay_capture` value of `true`. - - - See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) - for more information. - - Parameters - ---------- - location_id : str - - - transaction_id : str - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - VoidTransactionResponse - Success - - Examples - -------- - import asyncio - - from square import AsyncSquare - - client = AsyncSquare( - token="YOUR_TOKEN", - ) - - - async def main() -> None: - await client.locations.transactions.void( - location_id="location_id", - transaction_id="transaction_id", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.void(location_id, transaction_id, request_options=request_options) - return _response.data diff --git a/src/square/locations/transactions/raw_client.py b/src/square/locations/transactions/raw_client.py index 3a0563b0..76591f7a 100644 --- a/src/square/locations/transactions/raw_client.py +++ b/src/square/locations/transactions/raw_client.py @@ -9,11 +9,9 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.request_options import RequestOptions from ...core.unchecked_base_model import construct_type -from ...types.capture_transaction_response import CaptureTransactionResponse from ...types.get_transaction_response import GetTransactionResponse from ...types.list_transactions_response import ListTransactionsResponse from ...types.sort_order import SortOrder -from ...types.void_transaction_response import VoidTransactionResponse class RawTransactionsClient: @@ -145,100 +143,6 @@ def get( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def capture( - self, location_id: str, transaction_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> HttpResponse[CaptureTransactionResponse]: - """ - Captures a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) - endpoint with a `delay_capture` value of `true`. - - - See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) - for more information. - - Parameters - ---------- - location_id : str - - - transaction_id : str - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[CaptureTransactionResponse] - Success - """ - _response = self._client_wrapper.httpx_client.request( - f"v2/locations/{jsonable_encoder(location_id)}/transactions/{jsonable_encoder(transaction_id)}/capture", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - CaptureTransactionResponse, - construct_type( - type_=CaptureTransactionResponse, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - def void( - self, location_id: str, transaction_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> HttpResponse[VoidTransactionResponse]: - """ - Cancels a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) - endpoint with a `delay_capture` value of `true`. - - - See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) - for more information. - - Parameters - ---------- - location_id : str - - - transaction_id : str - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[VoidTransactionResponse] - Success - """ - _response = self._client_wrapper.httpx_client.request( - f"v2/locations/{jsonable_encoder(location_id)}/transactions/{jsonable_encoder(transaction_id)}/void", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - VoidTransactionResponse, - construct_type( - type_=VoidTransactionResponse, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - class AsyncRawTransactionsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -368,97 +272,3 @@ async def get( except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def capture( - self, location_id: str, transaction_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> AsyncHttpResponse[CaptureTransactionResponse]: - """ - Captures a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) - endpoint with a `delay_capture` value of `true`. - - - See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) - for more information. - - Parameters - ---------- - location_id : str - - - transaction_id : str - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[CaptureTransactionResponse] - Success - """ - _response = await self._client_wrapper.httpx_client.request( - f"v2/locations/{jsonable_encoder(location_id)}/transactions/{jsonable_encoder(transaction_id)}/capture", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - CaptureTransactionResponse, - construct_type( - type_=CaptureTransactionResponse, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def void( - self, location_id: str, transaction_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> AsyncHttpResponse[VoidTransactionResponse]: - """ - Cancels a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) - endpoint with a `delay_capture` value of `true`. - - - See [Delayed capture transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) - for more information. - - Parameters - ---------- - location_id : str - - - transaction_id : str - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[VoidTransactionResponse] - Success - """ - _response = await self._client_wrapper.httpx_client.request( - f"v2/locations/{jsonable_encoder(location_id)}/transactions/{jsonable_encoder(transaction_id)}/void", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - VoidTransactionResponse, - construct_type( - type_=VoidTransactionResponse, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/square/requests/capture_transaction_response.py b/src/square/requests/capture_transaction_response.py deleted file mode 100644 index 841db9d4..00000000 --- a/src/square/requests/capture_transaction_response.py +++ /dev/null @@ -1,18 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import typing_extensions -from .error import ErrorParams - - -class CaptureTransactionResponseParams(typing_extensions.TypedDict): - """ - Defines the fields that are included in the response body of - a request to the [CaptureTransaction](api-endpoint:Transactions-CaptureTransaction) endpoint. - """ - - errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] - """ - Any errors that occurred during the request. - """ diff --git a/src/square/requests/void_transaction_response.py b/src/square/requests/void_transaction_response.py deleted file mode 100644 index dab4a82e..00000000 --- a/src/square/requests/void_transaction_response.py +++ /dev/null @@ -1,18 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import typing_extensions -from .error import ErrorParams - - -class VoidTransactionResponseParams(typing_extensions.TypedDict): - """ - Defines the fields that are included in the response body of - a request to the [VoidTransaction](api-endpoint:Transactions-VoidTransaction) endpoint. - """ - - errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] - """ - Any errors that occurred during the request. - """ diff --git a/src/square/types/capture_transaction_response.py b/src/square/types/capture_transaction_response.py deleted file mode 100644 index 1ad61d65..00000000 --- a/src/square/types/capture_transaction_response.py +++ /dev/null @@ -1,29 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel -from .error import Error - - -class CaptureTransactionResponse(UncheckedBaseModel): - """ - Defines the fields that are included in the response body of - a request to the [CaptureTransaction](api-endpoint:Transactions-CaptureTransaction) endpoint. - """ - - errors: typing.Optional[typing.List[Error]] = pydantic.Field(default=None) - """ - Any errors that occurred during the request. - """ - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/square/types/void_transaction_response.py b/src/square/types/void_transaction_response.py deleted file mode 100644 index 8c12f32e..00000000 --- a/src/square/types/void_transaction_response.py +++ /dev/null @@ -1,29 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel -from .error import Error - - -class VoidTransactionResponse(UncheckedBaseModel): - """ - Defines the fields that are included in the response body of - a request to the [VoidTransaction](api-endpoint:Transactions-VoidTransaction) endpoint. - """ - - errors: typing.Optional[typing.List[Error]] = pydantic.Field(default=None) - """ - Any errors that occurred during the request. - """ - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/tests/integration/test_labor.py b/tests/integration/test_labor.py index 2bb659e7..b31b85b1 100644 --- a/tests/integration/test_labor.py +++ b/tests/integration/test_labor.py @@ -1,18 +1,16 @@ import time import uuid -from datetime import datetime, timedelta from functools import wraps from square.core.api_error import ApiError from square.core.request_options import RequestOptions from square.types.break_type import BreakType -from square.types.money import Money -from square.types.shift import Shift -from square.types.shift_wage import ShiftWage -from square.types.team_member import TeamMember from . import helpers +# NOTE: Shift tests were removed when the Shifts API was retired (2026-05-21, +# replaced by Timecards). Break type and workweek config coverage remains. + MAX_TIMEOUT = 120 MAX_RETRIES = 5 @@ -36,30 +34,6 @@ def wrapper(*args, **kwargs): return decorator -@retry_with_backoff() -def get_first_team_member() -> str: - client = helpers.test_client() - - # Search for active team members at the default location - team_response = client.team_members.search( - query={ - "filter": { - "location_ids": [helpers.get_default_location_id(client)], - "status": "ACTIVE" - } - }, - request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), - ) - if not team_response.team_members or len(team_response.team_members) == 0: - raise Exception(f"No team members available at location {helpers.get_default_location_id(client)}") - - team_member = team_response.team_members[0] - assert team_member is not None - assert isinstance(team_member, TeamMember) - assert team_member.id is not None - return team_member.id - - @retry_with_backoff() def create_break_type() -> str: client = helpers.test_client() @@ -94,39 +68,6 @@ def delete_break_type(break_type_id: str): pass -@retry_with_backoff() -def create_shift(team_member_id: str) -> str: - client = helpers.test_client() - - shift_response = client.labor.shifts.create( - shift={ - "location_id": helpers.get_default_location_id(client), - "start_at": helpers.format_date_string(datetime.now()), - "team_member_id": team_member_id, - }, - idempotency_key=str(uuid.uuid4()), - request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), - ) - shift = shift_response.shift - assert shift is not None - assert isinstance(shift, Shift) - assert shift.id is not None - return shift.id - - -def delete_shift(shift_id: str): - client = helpers.test_client() - try: - client.labor.shifts.delete( - id=shift_id, - request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), - ) - except Exception as e: - # test may have already deleted the shift - print(f"Error deleting shift: {str(e)}") - pass - - @retry_with_backoff() def get_first_break_type_id() -> str: client = helpers.test_client() @@ -146,11 +87,7 @@ def test_get_break_type(): time.sleep(3) client = helpers.test_client() - team_member_id = get_first_team_member() - time.sleep(2) # Add delay between operations break_type_id = create_break_type() - time.sleep(2) # Add delay between operations - shift_id = create_shift(team_member_id) response = client.labor.break_types.get( id=break_type_id, @@ -168,17 +105,12 @@ def test_get_break_type(): time.sleep(2) # Add delay before cleanup delete_break_type(break_type_id) - delete_shift(shift_id) @retry_with_backoff() def test_update_break_type(): client = helpers.test_client() - team_member_id = get_first_team_member() - time.sleep(2) # Add delay between operations break_type_id = create_break_type() - time.sleep(2) # Add delay between operations - shift_id = create_shift(team_member_id) response = client.labor.break_types.update( id=break_type_id, @@ -197,143 +129,6 @@ def test_update_break_type(): time.sleep(2) # Add delay before cleanup delete_break_type(break_type_id) - delete_shift(shift_id) - - -@retry_with_backoff() -def test_search_shifts(): - client = helpers.test_client() - team_member_id = get_first_team_member() - time.sleep(2) # Add delay between operations - break_type_id = create_break_type() - time.sleep(2) # Add delay between operations - shift_id = create_shift(team_member_id) - - response = client.labor.shifts.search( - limit=1, - request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), - ) - assert response.shifts is not None - assert len(response.shifts) > 0 - - time.sleep(2) # Add delay before cleanup - delete_break_type(break_type_id) - delete_shift(shift_id) - - -@retry_with_backoff() -def test_get_shift(): - client = helpers.test_client() - team_member_id = get_first_team_member() - time.sleep(2) # Add delay between operations - break_type_id = create_break_type() - time.sleep(2) # Add delay between operations - shift_id = create_shift(team_member_id) - - response = client.labor.shifts.get( - id=shift_id, - request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), - ) - assert response.shift is not None - assert isinstance(response.shift, Shift) - assert shift_id == response.shift.id - - time.sleep(2) # Add delay before cleanup - delete_break_type(break_type_id) - delete_shift(shift_id) - - -@retry_with_backoff() -def test_update_shift(): - client = helpers.test_client() - team_member_id = get_first_team_member() - time.sleep(2) # Add delay between operations - break_type_id = create_break_type() - time.sleep(2) # Add delay between operations - shift_id = create_shift(team_member_id) - - response = client.labor.shifts.update( - id=shift_id, - shift={ - "location_id": helpers.get_default_location_id(client), - "start_at": helpers.format_date_string( - datetime.now() - timedelta(minutes=1) - ), - "team_member_id": team_member_id, - "wage": { - "title": "Manager", - "hourly_rate": {"amount": 2500, "currency": "USD"}, - }, - }, - request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), - ) - shift = response.shift - assert shift is not None - assert isinstance(shift, Shift) - assert shift.wage is not None - assert isinstance(shift.wage, ShiftWage) - assert "Manager" == shift.wage.title - assert isinstance(shift.wage.hourly_rate, Money) - assert 2500 == shift.wage.hourly_rate.amount - assert "USD" == shift.wage.hourly_rate.currency - - time.sleep(2) # Add delay before cleanup - delete_break_type(break_type_id) - delete_shift(shift_id) - - -@retry_with_backoff() -def test_delete_shift(): - client = helpers.test_client() - - # Search for existing shifts for this team member - team_member_id = get_first_team_member() - - # Search for existing shifts - existing_shifts = client.labor.shifts.search( - query={ - "filter": { - "team_member_ids": [team_member_id] - } - }, - limit=100, - request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), - ) - - # Delete any existing shifts - if existing_shifts.shifts: - for shift in existing_shifts.shifts: - if shift.id: - delete_shift(shift.id) - - # Start the shift 10 seconds from now and end it 20 seconds from now - start_time = datetime.now() + timedelta(seconds=10) - end_time = start_time + timedelta(seconds=10) - - # Create shift - shift_response = client.labor.shifts.create( - shift={ - "location_id": helpers.get_default_location_id(client), - "start_at": helpers.format_date_string(start_time), - "end_at": helpers.format_date_string(end_time), - "team_member_id": team_member_id, - }, - idempotency_key=str(uuid.uuid4()), - request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), - ) - - assert shift_response.shift is not None - assert isinstance(shift_response.shift, Shift) - assert shift_response.shift.id is not None - shift_id = shift_response.shift.id - - time.sleep(1) # Add small delay to ensure the shift is fully created - - response = client.labor.shifts.delete( - id=shift_id, - request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), - ) - assert response is not None @retry_with_backoff() @@ -373,4 +168,4 @@ def test_list_workweek_configs(): request_options=RequestOptions(timeout_in_seconds=MAX_TIMEOUT), ) assert response.items is not None - assert len(response.items) > 0 \ No newline at end of file + assert len(response.items) > 0