From 07ce23c8e36f89e7b3c603f2f2a7344d7f2a912c Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 16 Oct 2025 16:03:42 +0000 Subject: [PATCH] SDK regeneration --- poetry.lock | 90 +- pyproject.toml | 2 +- reference.md | 1601 +++++++++++++++-- src/square/__init__.py | 147 +- src/square/bank_accounts/client.py | 12 +- src/square/bookings/__init__.py | 34 +- src/square/bookings/client.py | 124 +- .../custom_attribute_definitions/client.py | 12 +- .../bookings/custom_attributes/client.py | 10 + .../bookings/location_profiles/client.py | 10 +- .../bookings/team_member_profiles/client.py | 14 +- src/square/cards/client.py | 16 +- src/square/cash_drawers/__init__.py | 29 +- src/square/cash_drawers/client.py | 30 +- src/square/cash_drawers/shifts/client.py | 14 + src/square/catalog/__init__.py | 29 +- src/square/catalog/client.py | 63 +- src/square/catalog/object/client.py | 6 + src/square/channels/__init__.py | 4 + src/square/channels/client.py | 339 ++++ src/square/channels/raw_client.py | 360 ++++ src/square/checkout/__init__.py | 29 +- src/square/checkout/client.py | 27 +- src/square/checkout/payment_links/client.py | 10 +- src/square/client.py | 790 ++++++-- src/square/core/__init__.py | 29 +- src/square/core/client_wrapper.py | 6 +- src/square/core/force_multipart.py | 6 +- src/square/core/http_response.py | 2 +- src/square/core/pagination.py | 2 +- src/square/core/pydantic_utilities.py | 7 +- src/square/core/unchecked_base_model.py | 6 +- src/square/customers/__init__.py | 35 +- src/square/customers/client.py | 144 +- .../custom_attribute_definitions/client.py | 12 +- .../customers/custom_attributes/client.py | 10 + src/square/customers/groups/client.py | 10 +- src/square/customers/segments/client.py | 10 +- src/square/devices/__init__.py | 29 +- src/square/devices/client.py | 42 +- src/square/devices/codes/client.py | 12 +- src/square/disputes/__init__.py | 29 +- src/square/disputes/client.py | 39 +- src/square/disputes/evidence/client.py | 2 + src/square/employees/client.py | 14 +- src/square/events/client.py | 8 +- src/square/gift_cards/__init__.py | 29 +- src/square/gift_cards/activities/client.py | 22 +- src/square/gift_cards/client.py | 43 +- src/square/inventory/client.py | 8 + src/square/invoices/client.py | 6 + src/square/labor/__init__.py | 35 +- src/square/labor/break_types/client.py | 12 +- src/square/labor/client.py | 121 +- src/square/labor/employee_wages/client.py | 12 +- src/square/labor/team_member_wages/client.py | 12 +- src/square/labor/workweek_configs/client.py | 10 +- src/square/locations/__init__.py | 33 +- src/square/locations/client.py | 80 +- .../custom_attribute_definitions/client.py | 14 +- .../locations/custom_attributes/client.py | 12 + src/square/locations/transactions/client.py | 8 + src/square/loyalty/__init__.py | 29 +- src/square/loyalty/client.py | 75 +- src/square/loyalty/programs/__init__.py | 29 +- src/square/loyalty/programs/client.py | 27 +- .../loyalty/programs/promotions/client.py | 54 +- .../loyalty/programs/promotions/raw_client.py | 32 +- src/square/merchants/__init__.py | 32 +- src/square/merchants/client.py | 65 +- .../custom_attribute_definitions/client.py | 14 +- .../merchants/custom_attributes/client.py | 12 + src/square/orders/__init__.py | 32 +- src/square/orders/client.py | 56 +- .../custom_attribute_definitions/client.py | 14 +- src/square/orders/custom_attributes/client.py | 12 + src/square/payments/client.py | 36 +- src/square/payouts/client.py | 26 +- src/square/refunds/client.py | 28 +- .../bulk_retrieve_channels_response.py | 27 + .../cancel_transfer_order_response.py | 23 + src/square/requests/channel.py | 52 + .../requests/create_transfer_order_data.py | 52 + .../create_transfer_order_line_data.py | 24 + .../create_transfer_order_response.py | 23 + src/square/requests/custom_attribute.py | 9 +- .../delete_transfer_order_response.py | 17 + src/square/requests/list_channels_response.py | 24 + .../receive_transfer_order_response.py | 23 + src/square/requests/reference.py | 17 + .../requests/retrieve_channel_response.py | 19 + .../retrieve_transfer_order_response.py | 23 + .../search_transfer_orders_response.py | 28 + .../requests/start_transfer_order_response.py | 23 + src/square/requests/transfer_order.py | 131 ++ .../requests/transfer_order_created_event.py | 37 + .../transfer_order_created_event_data.py | 23 + .../transfer_order_created_event_object.py | 11 + .../requests/transfer_order_deleted_event.py | 37 + .../transfer_order_deleted_event_data.py | 22 + src/square/requests/transfer_order_filter.py | 28 + .../requests/transfer_order_goods_receipt.py | 44 + .../transfer_order_goods_receipt_line_item.py | 33 + src/square/requests/transfer_order_line.py | 57 + src/square/requests/transfer_order_query.py | 21 + src/square/requests/transfer_order_sort.py | 23 + .../requests/transfer_order_updated_event.py | 37 + .../transfer_order_updated_event_data.py | 23 + .../transfer_order_updated_event_object.py | 11 + .../requests/update_transfer_order_data.py | 44 + .../update_transfer_order_line_data.py | 33 + .../update_transfer_order_response.py | 23 + src/square/subscriptions/client.py | 6 + src/square/team/client.py | 8 +- src/square/team_members/__init__.py | 29 +- src/square/team_members/client.py | 27 +- src/square/terminal/__init__.py | 29 +- src/square/terminal/client.py | 76 +- src/square/transfer_orders/__init__.py | 4 + src/square/transfer_orders/client.py | 1122 ++++++++++++ src/square/transfer_orders/raw_client.py | 1110 ++++++++++++ ...ulk_retrieve_channels_request_constants.py | 5 + .../types/bulk_retrieve_channels_response.py | 38 + .../types/cancel_transfer_order_response.py | 34 + src/square/types/channel.py | 63 + src/square/types/channel_status.py | 5 + .../types/create_transfer_order_data.py | 63 + .../types/create_transfer_order_line_data.py | 37 + .../types/create_transfer_order_response.py | 34 + src/square/types/custom_attribute.py | 9 +- .../types/delete_transfer_order_response.py | 28 + .../types/list_channels_request_constants.py | 5 + src/square/types/list_channels_response.py | 35 + .../types/receive_transfer_order_response.py | 34 + src/square/types/reference.py | 30 + src/square/types/reference_type.py | 24 + src/square/types/retrieve_channel_response.py | 30 + .../types/retrieve_transfer_order_response.py | 34 + .../types/search_transfer_orders_response.py | 39 + .../types/start_transfer_order_response.py | 34 + src/square/types/transfer_order.py | 142 ++ .../types/transfer_order_created_event.py | 48 + .../transfer_order_created_event_data.py | 34 + .../transfer_order_created_event_object.py | 24 + .../types/transfer_order_deleted_event.py | 48 + .../transfer_order_deleted_event_data.py | 33 + src/square/types/transfer_order_filter.py | 39 + .../types/transfer_order_goods_receipt.py | 55 + .../transfer_order_goods_receipt_line_item.py | 44 + src/square/types/transfer_order_line.py | 70 + src/square/types/transfer_order_query.py | 34 + src/square/types/transfer_order_sort.py | 36 + src/square/types/transfer_order_sort_field.py | 5 + src/square/types/transfer_order_status.py | 7 + .../types/transfer_order_updated_event.py | 48 + .../transfer_order_updated_event_data.py | 34 + .../transfer_order_updated_event_object.py | 24 + .../types/update_transfer_order_data.py | 55 + .../types/update_transfer_order_line_data.py | 44 + .../types/update_transfer_order_response.py | 34 + src/square/v1transactions/client.py | 6 + src/square/webhooks/__init__.py | 29 +- src/square/webhooks/client.py | 54 +- src/square/webhooks/event_types/client.py | 8 +- src/square/webhooks/subscriptions/client.py | 14 +- tests/utils/test_query_encoding.py | 1 - 166 files changed, 9648 insertions(+), 622 deletions(-) create mode 100644 src/square/channels/__init__.py create mode 100644 src/square/channels/client.py create mode 100644 src/square/channels/raw_client.py create mode 100644 src/square/requests/bulk_retrieve_channels_response.py create mode 100644 src/square/requests/cancel_transfer_order_response.py create mode 100644 src/square/requests/channel.py create mode 100644 src/square/requests/create_transfer_order_data.py create mode 100644 src/square/requests/create_transfer_order_line_data.py create mode 100644 src/square/requests/create_transfer_order_response.py create mode 100644 src/square/requests/delete_transfer_order_response.py create mode 100644 src/square/requests/list_channels_response.py create mode 100644 src/square/requests/receive_transfer_order_response.py create mode 100644 src/square/requests/reference.py create mode 100644 src/square/requests/retrieve_channel_response.py create mode 100644 src/square/requests/retrieve_transfer_order_response.py create mode 100644 src/square/requests/search_transfer_orders_response.py create mode 100644 src/square/requests/start_transfer_order_response.py create mode 100644 src/square/requests/transfer_order.py create mode 100644 src/square/requests/transfer_order_created_event.py create mode 100644 src/square/requests/transfer_order_created_event_data.py create mode 100644 src/square/requests/transfer_order_created_event_object.py create mode 100644 src/square/requests/transfer_order_deleted_event.py create mode 100644 src/square/requests/transfer_order_deleted_event_data.py create mode 100644 src/square/requests/transfer_order_filter.py create mode 100644 src/square/requests/transfer_order_goods_receipt.py create mode 100644 src/square/requests/transfer_order_goods_receipt_line_item.py create mode 100644 src/square/requests/transfer_order_line.py create mode 100644 src/square/requests/transfer_order_query.py create mode 100644 src/square/requests/transfer_order_sort.py create mode 100644 src/square/requests/transfer_order_updated_event.py create mode 100644 src/square/requests/transfer_order_updated_event_data.py create mode 100644 src/square/requests/transfer_order_updated_event_object.py create mode 100644 src/square/requests/update_transfer_order_data.py create mode 100644 src/square/requests/update_transfer_order_line_data.py create mode 100644 src/square/requests/update_transfer_order_response.py create mode 100644 src/square/transfer_orders/__init__.py create mode 100644 src/square/transfer_orders/client.py create mode 100644 src/square/transfer_orders/raw_client.py create mode 100644 src/square/types/bulk_retrieve_channels_request_constants.py create mode 100644 src/square/types/bulk_retrieve_channels_response.py create mode 100644 src/square/types/cancel_transfer_order_response.py create mode 100644 src/square/types/channel.py create mode 100644 src/square/types/channel_status.py create mode 100644 src/square/types/create_transfer_order_data.py create mode 100644 src/square/types/create_transfer_order_line_data.py create mode 100644 src/square/types/create_transfer_order_response.py create mode 100644 src/square/types/delete_transfer_order_response.py create mode 100644 src/square/types/list_channels_request_constants.py create mode 100644 src/square/types/list_channels_response.py create mode 100644 src/square/types/receive_transfer_order_response.py create mode 100644 src/square/types/reference.py create mode 100644 src/square/types/reference_type.py create mode 100644 src/square/types/retrieve_channel_response.py create mode 100644 src/square/types/retrieve_transfer_order_response.py create mode 100644 src/square/types/search_transfer_orders_response.py create mode 100644 src/square/types/start_transfer_order_response.py create mode 100644 src/square/types/transfer_order.py create mode 100644 src/square/types/transfer_order_created_event.py create mode 100644 src/square/types/transfer_order_created_event_data.py create mode 100644 src/square/types/transfer_order_created_event_object.py create mode 100644 src/square/types/transfer_order_deleted_event.py create mode 100644 src/square/types/transfer_order_deleted_event_data.py create mode 100644 src/square/types/transfer_order_filter.py create mode 100644 src/square/types/transfer_order_goods_receipt.py create mode 100644 src/square/types/transfer_order_goods_receipt_line_item.py create mode 100644 src/square/types/transfer_order_line.py create mode 100644 src/square/types/transfer_order_query.py create mode 100644 src/square/types/transfer_order_sort.py create mode 100644 src/square/types/transfer_order_sort_field.py create mode 100644 src/square/types/transfer_order_status.py create mode 100644 src/square/types/transfer_order_updated_event.py create mode 100644 src/square/types/transfer_order_updated_event_data.py create mode 100644 src/square/types/transfer_order_updated_event_object.py create mode 100644 src/square/types/update_transfer_order_data.py create mode 100644 src/square/types/update_transfer_order_line_data.py create mode 100644 src/square/types/update_transfer_order_response.py diff --git a/poetry.lock b/poetry.lock index c2ddd863..fef37956 100644 --- a/poetry.lock +++ b/poetry.lock @@ -38,13 +38,13 @@ trio = ["trio (>=0.26.1)"] [[package]] name = "certifi" -version = "2025.8.3" +version = "2025.10.5" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.7" files = [ - {file = "certifi-2025.8.3-py3-none-any.whl", hash = "sha256:f6c12493cfb1b06ba2ff328595af9350c65d6644968e5d3a2ffd78699af217a5"}, - {file = "certifi-2025.8.3.tar.gz", hash = "sha256:e564105f78ded564e3ae7c923924435e1daa7463faeab5bb932bc53ffae63407"}, + {file = "certifi-2025.10.5-py3-none-any.whl", hash = "sha256:0f212c2744a9bb6de0c56639a6f68afe01ecd92d91f14ae897c4fe7bbeeef0de"}, + {file = "certifi-2025.10.5.tar.gz", hash = "sha256:47c09d31ccf2acf0be3f701ea53595ee7e0b8fa08801c6624be771df09ae7b43"}, ] [[package]] @@ -133,13 +133,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "idna" -version = "3.10" +version = "3.11" description = "Internationalized Domain Names in Applications (IDNA)" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, - {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, + {file = "idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea"}, + {file = "idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902"}, ] [package.extras] @@ -483,43 +483,53 @@ files = [ [[package]] name = "tomli" -version = "2.2.1" +version = "2.3.0" description = "A lil' TOML parser" optional = false python-versions = ">=3.8" files = [ - {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, - {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"}, - {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a"}, - {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee"}, - {file = "tomli-2.2.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e"}, - {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4"}, - {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106"}, - {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8"}, - {file = "tomli-2.2.1-cp311-cp311-win32.whl", hash = "sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff"}, - {file = "tomli-2.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b"}, - {file = "tomli-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea"}, - {file = "tomli-2.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8"}, - {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192"}, - {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222"}, - {file = "tomli-2.2.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77"}, - {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6"}, - {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd"}, - {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e"}, - {file = "tomli-2.2.1-cp312-cp312-win32.whl", hash = "sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98"}, - {file = "tomli-2.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4"}, - {file = "tomli-2.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7"}, - {file = "tomli-2.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c"}, - {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13"}, - {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281"}, - {file = "tomli-2.2.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272"}, - {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140"}, - {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2"}, - {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744"}, - {file = "tomli-2.2.1-cp313-cp313-win32.whl", hash = "sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec"}, - {file = "tomli-2.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69"}, - {file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"}, - {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, + {file = "tomli-2.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:88bd15eb972f3664f5ed4b57c1634a97153b4bac4479dcb6a495f41921eb7f45"}, + {file = "tomli-2.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:883b1c0d6398a6a9d29b508c331fa56adbcdff647f6ace4dfca0f50e90dfd0ba"}, + {file = "tomli-2.3.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d1381caf13ab9f300e30dd8feadb3de072aeb86f1d34a8569453ff32a7dea4bf"}, + {file = "tomli-2.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a0e285d2649b78c0d9027570d4da3425bdb49830a6156121360b3f8511ea3441"}, + {file = "tomli-2.3.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:0a154a9ae14bfcf5d8917a59b51ffd5a3ac1fd149b71b47a3a104ca4edcfa845"}, + {file = "tomli-2.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:74bf8464ff93e413514fefd2be591c3b0b23231a77f901db1eb30d6f712fc42c"}, + {file = "tomli-2.3.0-cp311-cp311-win32.whl", hash = "sha256:00b5f5d95bbfc7d12f91ad8c593a1659b6387b43f054104cda404be6bda62456"}, + {file = "tomli-2.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:4dc4ce8483a5d429ab602f111a93a6ab1ed425eae3122032db7e9acf449451be"}, + {file = "tomli-2.3.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d7d86942e56ded512a594786a5ba0a5e521d02529b3826e7761a05138341a2ac"}, + {file = "tomli-2.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:73ee0b47d4dad1c5e996e3cd33b8a76a50167ae5f96a2607cbe8cc773506ab22"}, + {file = "tomli-2.3.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:792262b94d5d0a466afb5bc63c7daa9d75520110971ee269152083270998316f"}, + {file = "tomli-2.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4f195fe57ecceac95a66a75ac24d9d5fbc98ef0962e09b2eddec5d39375aae52"}, + {file = "tomli-2.3.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e31d432427dcbf4d86958c184b9bfd1e96b5b71f8eb17e6d02531f434fd335b8"}, + {file = "tomli-2.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7b0882799624980785240ab732537fcfc372601015c00f7fc367c55308c186f6"}, + {file = "tomli-2.3.0-cp312-cp312-win32.whl", hash = "sha256:ff72b71b5d10d22ecb084d345fc26f42b5143c5533db5e2eaba7d2d335358876"}, + {file = "tomli-2.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:1cb4ed918939151a03f33d4242ccd0aa5f11b3547d0cf30f7c74a408a5b99878"}, + {file = "tomli-2.3.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:5192f562738228945d7b13d4930baffda67b69425a7f0da96d360b0a3888136b"}, + {file = "tomli-2.3.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:be71c93a63d738597996be9528f4abe628d1adf5e6eb11607bc8fe1a510b5dae"}, + {file = "tomli-2.3.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c4665508bcbac83a31ff8ab08f424b665200c0e1e645d2bd9ab3d3e557b6185b"}, + {file = "tomli-2.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4021923f97266babc6ccab9f5068642a0095faa0a51a246a6a02fccbb3514eaf"}, + {file = "tomli-2.3.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a4ea38c40145a357d513bffad0ed869f13c1773716cf71ccaa83b0fa0cc4e42f"}, + {file = "tomli-2.3.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:ad805ea85eda330dbad64c7ea7a4556259665bdf9d2672f5dccc740eb9d3ca05"}, + {file = "tomli-2.3.0-cp313-cp313-win32.whl", hash = "sha256:97d5eec30149fd3294270e889b4234023f2c69747e555a27bd708828353ab606"}, + {file = "tomli-2.3.0-cp313-cp313-win_amd64.whl", hash = "sha256:0c95ca56fbe89e065c6ead5b593ee64b84a26fca063b5d71a1122bf26e533999"}, + {file = "tomli-2.3.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:cebc6fe843e0733ee827a282aca4999b596241195f43b4cc371d64fc6639da9e"}, + {file = "tomli-2.3.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:4c2ef0244c75aba9355561272009d934953817c49f47d768070c3c94355c2aa3"}, + {file = "tomli-2.3.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c22a8bf253bacc0cf11f35ad9808b6cb75ada2631c2d97c971122583b129afbc"}, + {file = "tomli-2.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0eea8cc5c5e9f89c9b90c4896a8deefc74f518db5927d0e0e8d4a80953d774d0"}, + {file = "tomli-2.3.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:b74a0e59ec5d15127acdabd75ea17726ac4c5178ae51b85bfe39c4f8a278e879"}, + {file = "tomli-2.3.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:b5870b50c9db823c595983571d1296a6ff3e1b88f734a4c8f6fc6188397de005"}, + {file = "tomli-2.3.0-cp314-cp314-win32.whl", hash = "sha256:feb0dacc61170ed7ab602d3d972a58f14ee3ee60494292d384649a3dc38ef463"}, + {file = "tomli-2.3.0-cp314-cp314-win_amd64.whl", hash = "sha256:b273fcbd7fc64dc3600c098e39136522650c49bca95df2d11cf3b626422392c8"}, + {file = "tomli-2.3.0-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:940d56ee0410fa17ee1f12b817b37a4d4e4dc4d27340863cc67236c74f582e77"}, + {file = "tomli-2.3.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:f85209946d1fe94416debbb88d00eb92ce9cd5266775424ff81bc959e001acaf"}, + {file = "tomli-2.3.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a56212bdcce682e56b0aaf79e869ba5d15a6163f88d5451cbde388d48b13f530"}, + {file = "tomli-2.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c5f3ffd1e098dfc032d4d3af5c0ac64f6d286d98bc148698356847b80fa4de1b"}, + {file = "tomli-2.3.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:5e01decd096b1530d97d5d85cb4dff4af2d8347bd35686654a004f8dea20fc67"}, + {file = "tomli-2.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:8a35dd0e643bb2610f156cca8db95d213a90015c11fee76c946aa62b7ae7e02f"}, + {file = "tomli-2.3.0-cp314-cp314t-win32.whl", hash = "sha256:a1f7f282fe248311650081faafa5f4732bdbfef5d45fe3f2e702fbc6f2d496e0"}, + {file = "tomli-2.3.0-cp314-cp314t-win_amd64.whl", hash = "sha256:70a251f8d4ba2d9ac2542eecf008b3c8a9fc5c3f9f02c56a9d7952612be2fdba"}, + {file = "tomli-2.3.0-py3-none-any.whl", hash = "sha256:e95b1af3c5b07d9e643909b5abbec77cd9f1217e6d0bca72b0234736b9fb1f1b"}, + {file = "tomli-2.3.0.tar.gz", hash = "sha256:64be704a875d2a59753d80ee8a533c3fe183e3f06807ff7dc2232938ccb01549"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index afa4ac4a..3526b024 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "squareup" [tool.poetry] name = "squareup" -version = "43.1.2.20250924" +version = "43.2.0.20251016" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 9f7c0431..d42bf0f8 100644 --- a/reference.md +++ b/reference.md @@ -583,6 +583,9 @@ client = Square( ) client.v1transactions.v1list_orders( location_id="location_id", + order="DESC", + limit=1, + batch_token="batch_token", ) ``` @@ -965,7 +968,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.bank_accounts.list() +response = client.bank_accounts.list( + cursor="cursor", + limit=1, + location_id="location_id", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -1215,7 +1222,15 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.bookings.list() +response = client.bookings.list( + limit=1, + cursor="cursor", + customer_id="customer_id", + team_member_id="team_member_id", + location_id="location_id", + start_at_min="start_at_min", + start_at_max="start_at_max", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -2033,7 +2048,13 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.cards.list() +response = client.cards.list( + cursor="cursor", + customer_id="customer_id", + include_disabled=True, + reference_id="reference_id", + sort_order="DESC", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -2859,7 +2880,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.catalog.list() +response = client.catalog.list( + cursor="cursor", + types="types", + catalog_version=1000000, +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -3497,6 +3522,261 @@ At least one of `taxes_to_enable` or `taxes_to_disable` must be specified. + + + + +## Channels +
client.channels.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +response = client.channels.list( + reference_type="UNKNOWN_TYPE", + reference_id="reference_id", + status="ACTIVE", + cursor="cursor", + limit=1, +) +for item in response: + yield item +# alternatively, you can paginate page-by-page +for page in response.iter_pages(): + yield page + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**reference_type:** `typing.Optional[ReferenceType]` — Type of reference associated to channel + +
+
+ +
+
+ +**reference_id:** `typing.Optional[str]` — id of reference associated to channel + +
+
+ +
+
+ +**status:** `typing.Optional[ChannelStatus]` — Status of channel + +
+
+ +
+
+ +**cursor:** `typing.Optional[str]` — Cursor to fetch the next result + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` + +Maximum number of results to return. +When not provided the returned results will be cap at 100 channels. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.channels.bulk_retrieve(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.channels.bulk_retrieve( + channel_ids=["CH_9C03D0B59", "CH_6X139B5MN", "NOT_EXISTING"], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**channel_ids:** `typing.Sequence[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.channels.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.channels.get( + channel_id="channel_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**channel_id:** `str` — A channel id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
@@ -3538,7 +3818,13 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.customers.list() +response = client.customers.list( + cursor="cursor", + limit=1, + sort_field="DEFAULT", + sort_order="DESC", + count=True, +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -4677,6 +4963,7 @@ client = Square( ) client.customers.delete( customer_id="customer_id", + version=1000000, ) ``` @@ -4759,7 +5046,12 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.devices.list() +response = client.devices.list( + cursor="cursor", + sort_order="DESC", + limit=1, + location_id="location_id", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -4935,7 +5227,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.disputes.list() +response = client.disputes.list( + cursor="cursor", + states="INQUIRY_EVIDENCE_REQUIRED", + location_id="location_id", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -5441,7 +5737,12 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.employees.list() +response = client.employees.list( + location_id="location_id", + status="ACTIVE", + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -5825,7 +6126,9 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -client.events.list_event_types() +client.events.list_event_types( + api_version="api_version", +) ``` @@ -5895,7 +6198,13 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.gift_cards.list() +response = client.gift_cards.list( + type="type", + state="state", + limit=1, + cursor="cursor", + customer_id="customer_id", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -7712,6 +8021,8 @@ client = Square( ) response = client.inventory.get( catalog_object_id="catalog_object_id", + location_ids="location_ids", + cursor="cursor", ) for item in response: yield item @@ -7823,6 +8134,8 @@ client = Square( ) response = client.inventory.changes( catalog_object_id="catalog_object_id", + location_ids="location_ids", + cursor="cursor", ) for item in response: yield item @@ -7925,6 +8238,8 @@ client = Square( ) response = client.invoices.list( location_id="location_id", + cursor="cursor", + limit=1, ) for item in response: yield item @@ -8458,6 +8773,7 @@ client = Square( ) client.invoices.delete( invoice_id="invoice_id", + version=1, ) ``` @@ -10707,7 +11023,9 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.merchants.list() +response = client.merchants.list( + cursor=1, +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -12052,7 +12370,23 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.payments.list() +response = client.payments.list( + begin_time="begin_time", + end_time="end_time", + sort_order="sort_order", + cursor="cursor", + location_id="location_id", + total=1000000, + last4="last_4", + card_brand="card_brand", + limit=1, + is_offline_payment=True, + offline_begin_time="offline_begin_time", + offline_end_time="offline_end_time", + updated_at_begin_time="updated_at_begin_time", + updated_at_end_time="updated_at_end_time", + sort_field="CREATED_AT", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -13101,7 +13435,15 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.payouts.list() +response = client.payouts.list( + location_id="location_id", + status="SENT", + begin_time="begin_time", + end_time="end_time", + sort_order="DESC", + cursor="cursor", + limit=1, +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -13316,6 +13658,9 @@ client = Square( ) response = client.payouts.list_entries( payout_id="payout_id", + sort_order="DESC", + cursor="cursor", + limit=1, ) for item in response: yield item @@ -13430,7 +13775,19 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.refunds.list() +response = client.refunds.list( + begin_time="begin_time", + end_time="end_time", + sort_order="sort_order", + cursor="cursor", + location_id="location_id", + status="status", + source_type="source_type", + limit=1, + updated_at_begin_time="updated_at_begin_time", + updated_at_end_time="updated_at_end_time", + sort_field="CREATED_AT", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -14693,6 +15050,7 @@ client = Square( ) client.subscriptions.get( subscription_id="subscription_id", + include="include", ) ``` @@ -15106,6 +15464,8 @@ client = Square( ) response = client.subscriptions.list_events( subscription_id="subscription_id", + cursor="cursor", + limit=1, ) for item in response: yield item @@ -16066,7 +16426,762 @@ client.team_members.update(
-**team_member_id:** `str` — The ID of the team member to update. +**team_member_id:** `str` — The ID of the team member to update. + +
+
+ +
+
+ +**team_member:** `typing.Optional[TeamMemberParams]` + +The team member fields to add, change, or clear. Fields can be cleared using a null value. To update +`wage_setting.job_assignments`, you must provide the complete list of job assignments. If needed, call +[ListJobs](api-endpoint:Team-ListJobs) to get the required `job_id` values. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+ + + + + + + + +## Team +
client.team.list_jobs(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists jobs in a seller account. Results are sorted by title in ascending order. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.team.list_jobs( + cursor="cursor", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**cursor:** `typing.Optional[str]` + +The pagination cursor returned by the previous call to this endpoint. Provide this +cursor to retrieve the next page of results for your original request. For more information, +see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.team.create_job(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creates a job in a seller account. A job defines a title and tip eligibility. Note that +compensation is defined in a [job assignment](entity:JobAssignment) in a team member's wage setting. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.team.create_job( + job={"title": "Cashier", "is_tip_eligible": True}, + idempotency_key="idempotency-key-0", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**job:** `JobParams` — The job to create. The `title` field is required and `is_tip_eligible` defaults to true. + +
+
+ +
+
+ +**idempotency_key:** `str` + +A unique identifier for the `CreateJob` request. Keys can be any valid string, +but must be unique for each request. For more information, see +[Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.team.retrieve_job(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieves a specified job. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.team.retrieve_job( + job_id="job_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**job_id:** `str` — The ID of the job to retrieve. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.team.update_job(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates the title or tip eligibility of a job. Changes to the title propagate to all +`JobAssignment`, `Shift`, and `TeamMemberWage` objects that reference the job ID. Changes to +tip eligibility propagate to all `TeamMemberWage` objects that reference the job ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.team.update_job( + job_id="job_id", + job={"title": "Cashier 1", "is_tip_eligible": True}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**job_id:** `str` — The ID of the job to update. + +
+
+ +
+
+ +**job:** `JobParams` + +The job with the updated fields, either `title`, `is_tip_eligible`, or both. Only changed fields need +to be included in the request. Optionally include `version` to enable optimistic concurrency control. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Terminal +
client.terminal.dismiss_terminal_action(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Dismisses a Terminal action request if the status and type of the request permits it. + +See [Link and Dismiss Actions](https://developer.squareup.com/docs/terminal-api/advanced-features/custom-workflows/link-and-dismiss-actions) for more details. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.terminal.dismiss_terminal_action( + action_id="action_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**action_id:** `str` — Unique ID for the `TerminalAction` associated with the action to be dismissed. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.terminal.dismiss_terminal_checkout(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Dismisses a Terminal checkout request if the status and type of the request permits it. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.terminal.dismiss_terminal_checkout( + checkout_id="checkout_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**checkout_id:** `str` — Unique ID for the `TerminalCheckout` associated with the checkout to be dismissed. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.terminal.dismiss_terminal_refund(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Dismisses a Terminal refund request if the status and type of the request permits it. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.terminal.dismiss_terminal_refund( + terminal_refund_id="terminal_refund_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**terminal_refund_id:** `str` — Unique ID for the `TerminalRefund` associated with the refund to be dismissed. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## TransferOrders +
client.transfer_orders.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creates a new transfer order in [DRAFT](entity:TransferOrderStatus) status. A transfer order represents the intent +to move [CatalogItemVariation](entity:CatalogItemVariation)s from one [Location](entity:Location) to another. +The source and destination locations must be different and must belong to your Square account. + +In [DRAFT](entity:TransferOrderStatus) status, you can: +- Add or remove items +- Modify quantities +- Update shipping information +- Delete the entire order via [DeleteTransferOrder](api-endpoint:TransferOrders-DeleteTransferOrder) + +The request requires source_location_id and destination_location_id. +Inventory levels are not affected until the order is started via +[StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder). + +Common integration points: +- Sync with warehouse management systems +- Automate regular stock transfers +- Initialize transfers from inventory optimization systems + +Creates a [transfer_order.created](webhook:transfer_order.created) webhook event. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +client.transfer_orders.create( + idempotency_key="65cc0586-3e82-384s-b524-3885cffd52", + transfer_order={ + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "expected_at": "2025-11-09T05:00:00Z", + "notes": "Example transfer order for inventory redistribution between locations", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5", + }, + { + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "3", + }, + ], + }, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**idempotency_key:** `str` + +A unique string that identifies this CreateTransferOrder request. Keys can be +any valid string but must be unique for every CreateTransferOrder request. + +
+
+ +
+
+ +**transfer_order:** `CreateTransferOrderDataParams` — The transfer order to create + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.transfer_orders.search(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Searches for transfer orders using filters. Returns a paginated list of matching +[TransferOrder](entity:TransferOrder)s sorted by creation date. + +Common search scenarios: +- Find orders for a source [Location](entity:Location) +- Find orders for a destination [Location](entity:Location) +- Find orders in a particular [TransferOrderStatus](entity:TransferOrderStatus) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from square import Square + +client = Square( + token="YOUR_TOKEN", +) +response = client.transfer_orders.search( + query={ + "filter": { + "source_location_ids": ["EXAMPLE_SOURCE_LOCATION_ID_123"], + "destination_location_ids": ["EXAMPLE_DEST_LOCATION_ID_456"], + "statuses": ["STARTED", "PARTIALLY_RECEIVED"], + }, + "sort": {"field": "UPDATED_AT", "order": "DESC"}, + }, + cursor="eyJsYXN0X3VwZGF0ZWRfYXQiOjE3NTMxMTg2NjQ4NzN9", + limit=10, +) +for item in response: + yield item +# alternatively, you can paginate page-by-page +for page in response.iter_pages(): + yield page + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**query:** `typing.Optional[TransferOrderQueryParams]` — The search query + +
+
+ +
+
+ +**cursor:** `typing.Optional[str]` — Pagination cursor from a previous search response
@@ -16074,11 +17189,7 @@ client.team_members.update(
-**team_member:** `typing.Optional[TeamMemberParams]` - -The team member fields to add, change, or clear. Fields can be cleared using a null value. To update -`wage_setting.job_assignments`, you must provide the complete list of job assignments. If needed, call -[ListJobs](api-endpoint:Team-ListJobs) to get the required `job_id` values. +**limit:** `typing.Optional[int]` — Maximum number of results to return (1-100)
@@ -16098,8 +17209,7 @@ The team member fields to add, change, or clear. Fields can be cleared using a n
-## Team -
client.team.list_jobs(...) +
client.transfer_orders.get(...)
@@ -16111,7 +17221,13 @@ The team member fields to add, change, or clear. Fields can be cleared using a n
-Lists jobs in a seller account. Results are sorted by title in ascending order. +Retrieves a specific [TransferOrder](entity:TransferOrder) by ID. Returns the complete +order details including: + +- Basic information (status, dates, notes) +- Line items with ordered and received quantities +- Source and destination [Location](entity:Location)s +- Tracking information (if available)
@@ -16131,7 +17247,9 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -client.team.list_jobs() +client.transfer_orders.get( + transfer_order_id="transfer_order_id", +) ``` @@ -16147,11 +17265,7 @@ client.team.list_jobs()
-**cursor:** `typing.Optional[str]` - -The pagination cursor returned by the previous call to this endpoint. Provide this -cursor to retrieve the next page of results for your original request. For more information, -see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). +**transfer_order_id:** `str` — The ID of the transfer order to retrieve
@@ -16171,7 +17285,7 @@ see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-pat
-
client.team.create_job(...) +
client.transfer_orders.update(...)
@@ -16183,8 +17297,10 @@ see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-pat
-Creates a job in a seller account. A job defines a title and tip eligibility. Note that -compensation is defined in a [job assignment](entity:JobAssignment) in a team member's wage setting. +Updates an existing transfer order. This endpoint supports sparse updates, +allowing you to modify specific fields without affecting others. + +Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event.
@@ -16204,9 +17320,25 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -client.team.create_job( - job={"title": "Cashier", "is_tip_eligible": True}, - idempotency_key="idempotency-key-0", +client.transfer_orders.update( + transfer_order_id="transfer_order_id", + idempotency_key="f47ac10b-58cc-4372-a567-0e02b2c3d479", + transfer_order={ + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_789", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_101", + "expected_at": "2025-11-10T08:00:00Z", + "notes": "Updated: Priority transfer due to low stock at destination", + "tracking_number": "TRACK987654321", + "line_items": [ + {"uid": "1", "quantity_ordered": "7"}, + { + "item_variation_id": "EXAMPLE_NEW_ITEM_VARIATION_ID_003", + "quantity_ordered": "2", + }, + {"uid": "2", "remove": True}, + ], + }, + version=1753109537351, ) ``` @@ -16223,7 +17355,7 @@ client.team.create_job(
-**job:** `JobParams` — The job to create. The `title` field is required and `is_tip_eligible` defaults to true. +**transfer_order_id:** `str` — The ID of the transfer order to update
@@ -16231,11 +17363,23 @@ client.team.create_job(
-**idempotency_key:** `str` +**idempotency_key:** `str` — A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores + +
+
-A unique identifier for the `CreateJob` request. Keys can be any valid string, -but must be unique for each request. For more information, see -[Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). +
+
+ +**transfer_order:** `UpdateTransferOrderDataParams` — The transfer order updates to apply + +
+
+ +
+
+ +**version:** `typing.Optional[int]` — Version for optimistic concurrency
@@ -16255,7 +17399,7 @@ but must be unique for each request. For more information, see
-
client.team.retrieve_job(...) +
client.transfer_orders.delete(...)
@@ -16267,7 +17411,11 @@ but must be unique for each request. For more information, see
-Retrieves a specified job. +Deletes a transfer order in [DRAFT](entity:TransferOrderStatus) status. +Only draft orders can be deleted. Once an order is started via +[StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder), it can no longer be deleted. + +Creates a [transfer_order.deleted](webhook:transfer_order.deleted) webhook event.
@@ -16287,8 +17435,9 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -client.team.retrieve_job( - job_id="job_id", +client.transfer_orders.delete( + transfer_order_id="transfer_order_id", + version=1000000, ) ``` @@ -16305,7 +17454,15 @@ client.team.retrieve_job(
-**job_id:** `str` — The ID of the job to retrieve. +**transfer_order_id:** `str` — The ID of the transfer order to delete + +
+
+ +
+
+ +**version:** `typing.Optional[int]` — Version for optimistic concurrency
@@ -16325,7 +17482,7 @@ client.team.retrieve_job(
-
client.team.update_job(...) +
client.transfer_orders.cancel(...)
@@ -16337,9 +17494,16 @@ client.team.retrieve_job(
-Updates the title or tip eligibility of a job. Changes to the title propagate to all -`JobAssignment`, `Shift`, and `TeamMemberWage` objects that reference the job ID. Changes to -tip eligibility propagate to all `TeamMemberWage` objects that reference the job ID. +Cancels a transfer order in [STARTED](entity:TransferOrderStatus) or +[PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. Any unreceived quantities will no +longer be receivable and will be immediately returned to the source [Location](entity:Location)'s inventory. + +Common reasons for cancellation: +- Items no longer needed at destination +- Source location needs the inventory +- Order created in error + +Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event.
@@ -16359,9 +17523,10 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -client.team.update_job( - job_id="job_id", - job={"title": "Cashier 1", "is_tip_eligible": True}, +client.transfer_orders.cancel( + transfer_order_id="transfer_order_id", + idempotency_key="65cc0586-3e82-4d08-b524-3885cffd52", + version=1753117449752, ) ``` @@ -16378,7 +17543,7 @@ client.team.update_job(
-**job_id:** `str` — The ID of the job to update. +**transfer_order_id:** `str` — The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status.
@@ -16386,10 +17551,18 @@ client.team.update_job(
-**job:** `JobParams` +**idempotency_key:** `str` -The job with the updated fields, either `title`, `is_tip_eligible`, or both. Only changed fields need -to be included in the request. Optionally include `version` to enable optimistic concurrency control. +A unique string that identifies this UpdateTransferOrder request. Keys can be +any valid string but must be unique for every UpdateTransferOrder request. + +
+
+ +
+
+ +**version:** `typing.Optional[int]` — Version for optimistic concurrency
@@ -16409,8 +17582,7 @@ to be included in the request. Optionally include `version` to enable optimistic
-## Terminal -
client.terminal.dismiss_terminal_action(...) +
client.transfer_orders.receive(...)
@@ -16422,9 +17594,22 @@ to be included in the request. Optionally include `version` to enable optimistic
-Dismisses a Terminal action request if the status and type of the request permits it. +Records receipt of [CatalogItemVariation](entity:CatalogItemVariation)s for a transfer order. +This endpoint supports partial receiving - you can receive items in multiple batches. -See [Link and Dismiss Actions](https://developer.squareup.com/docs/terminal-api/advanced-features/custom-workflows/link-and-dismiss-actions) for more details. +For each line item, you can specify: +- Quantity received in good condition (added to destination inventory with [InventoryState](entity:InventoryState) of IN_STOCK) +- Quantity damaged during transit/handling (added to destination inventory with [InventoryState](entity:InventoryState) of WASTE) +- Quantity canceled (returned to source location's inventory) + +The order must be in [STARTED](entity:TransferOrderStatus) or [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. +Received quantities are added to the destination [Location](entity:Location)'s inventory according to their condition. +Canceled quantities are immediately returned to the source [Location](entity:Location)'s inventory. + +When all items are either received, damaged, or canceled, the order moves to +[COMPLETED](entity:TransferOrderStatus) status. + +Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event.
@@ -16444,8 +17629,25 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -client.terminal.dismiss_terminal_action( - action_id="action_id", +client.transfer_orders.receive( + transfer_order_id="transfer_order_id", + idempotency_key="EXAMPLE_IDEMPOTENCY_KEY_101", + receipt={ + "line_items": [ + { + "transfer_order_line_uid": "transfer_order_line_uid", + "quantity_received": "3", + "quantity_damaged": "1", + "quantity_canceled": "1", + }, + { + "transfer_order_line_uid": "transfer_order_line_uid", + "quantity_received": "2", + "quantity_canceled": "1", + }, + ] + }, + version=1753118664873, ) ``` @@ -16462,7 +17664,7 @@ client.terminal.dismiss_terminal_action(
-**action_id:** `str` — Unique ID for the `TerminalAction` associated with the action to be dismissed. +**transfer_order_id:** `str` — The ID of the transfer order to receive items for
@@ -16470,69 +17672,23 @@ client.terminal.dismiss_terminal_action(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**idempotency_key:** `str` — A unique key to make this request idempotent
- -
- - - - -
- -
client.terminal.dismiss_terminal_checkout(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Dismisses a Terminal checkout request if the status and type of the request permits it. -
-
-
-
- -#### 🔌 Usage - -
-
-```python -from square import Square - -client = Square( - token="YOUR_TOKEN", -) -client.terminal.dismiss_terminal_checkout( - checkout_id="checkout_id", -) - -``` -
-
+**receipt:** `TransferOrderGoodsReceiptParams` — The receipt details +
-#### ⚙️ Parameters - -
-
-
-**checkout_id:** `str` — Unique ID for the `TerminalCheckout` associated with the checkout to be dismissed. +**version:** `typing.Optional[int]` — Version for optimistic concurrency
@@ -16552,7 +17708,7 @@ client.terminal.dismiss_terminal_checkout(
-
client.terminal.dismiss_terminal_refund(...) +
client.transfer_orders.start(...)
@@ -16564,7 +17720,14 @@ client.terminal.dismiss_terminal_checkout(
-Dismisses a Terminal refund request if the status and type of the request permits it. +Changes a [DRAFT](entity:TransferOrderStatus) transfer order to [STARTED](entity:TransferOrderStatus) status. +This decrements inventory at the source [Location](entity:Location) and marks it as in-transit. + +The order must be in [DRAFT](entity:TransferOrderStatus) status and have all required fields populated. +Once started, the order can no longer be deleted, but it can be canceled via +[CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + +Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event.
@@ -16584,8 +17747,10 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -client.terminal.dismiss_terminal_refund( - terminal_refund_id="terminal_refund_id", +client.transfer_orders.start( + transfer_order_id="transfer_order_id", + idempotency_key="EXAMPLE_IDEMPOTENCY_KEY_789", + version=1753109537351, ) ``` @@ -16602,7 +17767,26 @@ client.terminal.dismiss_terminal_refund(
-**terminal_refund_id:** `str` — Unique ID for the `TerminalRefund` associated with the refund to be dismissed. +**transfer_order_id:** `str` — The ID of the transfer order to start. Must be in DRAFT status. + +
+
+ +
+
+ +**idempotency_key:** `str` + +A unique string that identifies this UpdateTransferOrder request. Keys can be +any valid string but must be unique for every UpdateTransferOrder request. + +
+
+ +
+
+ +**version:** `typing.Optional[int]` — Version for optimistic concurrency
@@ -17261,7 +18445,10 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.bookings.custom_attribute_definitions.list() +response = client.bookings.custom_attribute_definitions.list( + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -17458,6 +18645,7 @@ client = Square( ) client.bookings.custom_attribute_definitions.get( key="key", + version=1, ) ``` @@ -17893,6 +19081,9 @@ client = Square( ) response = client.bookings.custom_attributes.list( booking_id="booking_id", + limit=1, + cursor="cursor", + with_definitions=True, ) for item in response: yield item @@ -18008,6 +19199,8 @@ client = Square( client.bookings.custom_attributes.get( booking_id="booking_id", key="key", + with_definition=True, + version=1, ) ``` @@ -18321,7 +19514,10 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.bookings.location_profiles.list() +response = client.bookings.location_profiles.list( + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -18403,7 +19599,12 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.bookings.team_member_profiles.list() +response = client.bookings.team_member_profiles.list( + bookable_only=True, + limit=1, + cursor="cursor", + location_id="location_id", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -18574,6 +19775,11 @@ client = Square( ) response = client.cash_drawers.shifts.list( location_id="location_id", + sort_order="DESC", + begin_time="begin_time", + end_time="end_time", + limit=1, + cursor="cursor", ) for item in response: yield item @@ -18776,6 +19982,8 @@ client = Square( response = client.cash_drawers.shifts.list_events( shift_id="shift_id", location_id="location_id", + limit=1, + cursor="cursor", ) for item in response: yield item @@ -19159,6 +20367,9 @@ client = Square( ) client.catalog.object.get( object_id="object_id", + include_related_objects=True, + catalog_version=1000000, + include_category_path_to_root=True, ) ``` @@ -19360,7 +20571,10 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.checkout.payment_links.list() +response = client.checkout.payment_links.list( + cursor="cursor", + limit=1, +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -19832,7 +21046,10 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.customers.custom_attribute_definitions.list() +response = client.customers.custom_attribute_definitions.list( + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -20033,6 +21250,7 @@ client = Square( ) client.customers.custom_attribute_definitions.get( key="key", + version=1, ) ``` @@ -20425,7 +21643,10 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.customers.groups.list() +response = client.customers.groups.list( + cursor="cursor", + limit=1, +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -20980,7 +22201,10 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.customers.segments.list() +response = client.customers.segments.list( + cursor="cursor", + limit=1, +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -21366,6 +22590,9 @@ client = Square( ) response = client.customers.custom_attributes.list( customer_id="customer_id", + limit=1, + cursor="cursor", + with_definitions=True, ) for item in response: yield item @@ -21485,6 +22712,8 @@ client = Square( client.customers.custom_attributes.get( customer_id="customer_id", key="key", + with_definition=True, + version=1, ) ``` @@ -21798,7 +23027,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.devices.codes.list() +response = client.devices.codes.list( + cursor="cursor", + location_id="location_id", + status="UNKNOWN", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -22071,6 +23304,7 @@ client = Square( ) response = client.disputes.evidence.list( dispute_id="dispute_id", + cursor="cursor", ) for item in response: yield item @@ -22321,7 +23555,16 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.gift_cards.activities.list() +response = client.gift_cards.activities.list( + gift_card_id="gift_card_id", + type="type", + location_id="location_id", + begin_time="begin_time", + end_time="end_time", + limit=1, + cursor="cursor", + sort_order="sort_order", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -22571,7 +23814,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.labor.break_types.list() +response = client.labor.break_types.list( + location_id="location_id", + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -22991,7 +24238,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.labor.employee_wages.list() +response = client.labor.employee_wages.list( + employee_id="employee_id", + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -23631,7 +24882,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.labor.team_member_wages.list() +response = client.labor.team_member_wages.list( + team_member_id="team_member_id", + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -23797,7 +25052,10 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.labor.workweek_configs.list() +response = client.labor.workweek_configs.list( + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -23965,7 +25223,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.locations.custom_attribute_definitions.list() +response = client.locations.custom_attribute_definitions.list( + visibility_filter="ALL", + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -24167,6 +25429,7 @@ client = Square( ) client.locations.custom_attribute_definitions.get( key="key", + version=1, ) ``` @@ -24630,6 +25893,10 @@ client = Square( ) response = client.locations.custom_attributes.list( location_id="location_id", + visibility_filter="ALL", + limit=1, + cursor="cursor", + with_definitions=True, ) for item in response: yield item @@ -24754,6 +26021,8 @@ client = Square( client.locations.custom_attributes.get( location_id="location_id", key="key", + with_definition=True, + version=1, ) ``` @@ -25067,6 +26336,10 @@ client = Square( ) client.locations.transactions.list( location_id="location_id", + begin_time="begin_time", + end_time="end_time", + sort_order="DESC", + cursor="cursor", ) ``` @@ -26630,6 +27903,9 @@ client = Square( ) response = client.loyalty.programs.promotions.list( program_id="program_id", + status="ACTIVE", + cursor="cursor", + limit=1, ) for item in response: yield item @@ -26857,8 +28133,8 @@ client = Square( token="YOUR_TOKEN", ) client.loyalty.programs.promotions.get( - promotion_id="promotion_id", program_id="program_id", + promotion_id="promotion_id", ) ``` @@ -26875,7 +28151,10 @@ client.loyalty.programs.promotions.get(
-**promotion_id:** `str` — The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. +**program_id:** `str` + +The ID of the base [loyalty program](entity:LoyaltyProgram). To get the program ID, +call [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) using the `main` keyword.
@@ -26883,10 +28162,7 @@ client.loyalty.programs.promotions.get(
-**program_id:** `str` - -The ID of the base [loyalty program](entity:LoyaltyProgram). To get the program ID, -call [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) using the `main` keyword. +**promotion_id:** `str` — The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve.
@@ -26944,8 +28220,8 @@ client = Square( token="YOUR_TOKEN", ) client.loyalty.programs.promotions.cancel( - promotion_id="promotion_id", program_id="program_id", + promotion_id="promotion_id", ) ``` @@ -26962,10 +28238,7 @@ client.loyalty.programs.promotions.cancel(
-**promotion_id:** `str` - -The ID of the [loyalty promotion](entity:LoyaltyPromotion) to cancel. You can cancel a -promotion that has an `ACTIVE` or `SCHEDULED` status. +**program_id:** `str` — The ID of the base [loyalty program](entity:LoyaltyProgram).
@@ -26973,7 +28246,10 @@ promotion that has an `ACTIVE` or `SCHEDULED` status.
-**program_id:** `str` — The ID of the base [loyalty program](entity:LoyaltyProgram). +**promotion_id:** `str` + +The ID of the [loyalty promotion](entity:LoyaltyPromotion) to cancel. You can cancel a +promotion that has an `ACTIVE` or `SCHEDULED` status.
@@ -27029,7 +28305,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.merchants.custom_attribute_definitions.list() +response = client.merchants.custom_attribute_definitions.list( + visibility_filter="ALL", + limit=1, + cursor="cursor", +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -27231,6 +28511,7 @@ client = Square( ) client.merchants.custom_attribute_definitions.get( key="key", + version=1, ) ``` @@ -27685,6 +28966,10 @@ client = Square( ) response = client.merchants.custom_attributes.list( merchant_id="merchant_id", + visibility_filter="ALL", + limit=1, + cursor="cursor", + with_definitions=True, ) for item in response: yield item @@ -27809,6 +29094,8 @@ client = Square( client.merchants.custom_attributes.get( merchant_id="merchant_id", key="key", + with_definition=True, + version=1, ) ``` @@ -28120,7 +29407,11 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.orders.custom_attribute_definitions.list() +response = client.orders.custom_attribute_definitions.list( + visibility_filter="ALL", + cursor="cursor", + limit=1, +) for item in response: yield item # alternatively, you can paginate page-by-page @@ -28325,6 +29616,7 @@ client = Square( ) client.orders.custom_attribute_definitions.get( key="key", + version=1, ) ``` @@ -28785,6 +30077,10 @@ client = Square( ) response = client.orders.custom_attributes.list( order_id="order_id", + visibility_filter="ALL", + cursor="cursor", + limit=1, + with_definitions=True, ) for item in response: yield item @@ -28913,6 +30209,8 @@ client = Square( client.orders.custom_attributes.get( order_id="order_id", custom_attribute_key="custom_attribute_key", + version=1, + with_definition=True, ) ``` @@ -30384,7 +31682,9 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -client.webhooks.event_types.list() +client.webhooks.event_types.list( + api_version="api_version", +) ``` @@ -30453,7 +31753,12 @@ from square import Square client = Square( token="YOUR_TOKEN", ) -response = client.webhooks.subscriptions.list() +response = client.webhooks.subscriptions.list( + cursor="cursor", + include_disabled=True, + sort_order="DESC", + limit=1, +) for item in response: yield item # alternatively, you can paginate page-by-page diff --git a/src/square/__init__.py b/src/square/__init__.py index 22c3a097..944db404 100644 --- a/src/square/__init__.py +++ b/src/square/__init__.py @@ -2,44 +2,113 @@ # isort: skip_file -from . import ( - apple_pay, - bank_accounts, - bookings, - cards, - cash_drawers, - catalog, - checkout, - customers, - devices, - disputes, - employees, - events, - gift_cards, - inventory, - invoices, - labor, - locations, - loyalty, - merchants, - mobile, - o_auth, - orders, - payments, - payouts, - refunds, - sites, - snippets, - subscriptions, - team, - team_members, - terminal, - v1transactions, - vendors, - webhooks, -) -from .client import AsyncSquare, Square -from .version import __version__ +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import ( + apple_pay, + bank_accounts, + bookings, + cards, + cash_drawers, + catalog, + channels, + checkout, + customers, + devices, + disputes, + employees, + events, + gift_cards, + inventory, + invoices, + labor, + locations, + loyalty, + merchants, + mobile, + o_auth, + orders, + payments, + payouts, + refunds, + sites, + snippets, + subscriptions, + team, + team_members, + terminal, + transfer_orders, + v1transactions, + vendors, + webhooks, + ) + from .client import AsyncSquare, Square + from .version import __version__ +_dynamic_imports: typing.Dict[str, str] = { + "AsyncSquare": ".client", + "Square": ".client", + "__version__": ".version", + "apple_pay": ".apple_pay", + "bank_accounts": ".bank_accounts", + "bookings": ".bookings", + "cards": ".cards", + "cash_drawers": ".cash_drawers", + "catalog": ".catalog", + "channels": ".channels", + "checkout": ".checkout", + "customers": ".customers", + "devices": ".devices", + "disputes": ".disputes", + "employees": ".employees", + "events": ".events", + "gift_cards": ".gift_cards", + "inventory": ".inventory", + "invoices": ".invoices", + "labor": ".labor", + "locations": ".locations", + "loyalty": ".loyalty", + "merchants": ".merchants", + "mobile": ".mobile", + "o_auth": ".o_auth", + "orders": ".orders", + "payments": ".payments", + "payouts": ".payouts", + "refunds": ".refunds", + "sites": ".sites", + "snippets": ".snippets", + "subscriptions": ".subscriptions", + "team": ".team", + "team_members": ".team_members", + "terminal": ".terminal", + "transfer_orders": ".transfer_orders", + "v1transactions": ".v1transactions", + "vendors": ".vendors", + "webhooks": ".webhooks", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = [ "AsyncSquare", @@ -51,6 +120,7 @@ "cards", "cash_drawers", "catalog", + "channels", "checkout", "customers", "devices", @@ -76,6 +146,7 @@ "team", "team_members", "terminal", + "transfer_orders", "v1transactions", "vendors", "webhooks", diff --git a/src/square/bank_accounts/client.py b/src/square/bank_accounts/client.py index 91e251af..c710f15c 100644 --- a/src/square/bank_accounts/client.py +++ b/src/square/bank_accounts/client.py @@ -70,7 +70,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.bank_accounts.list() + response = client.bank_accounts.list( + cursor="cursor", + limit=1, + location_id="location_id", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -214,7 +218,11 @@ async def list( async def main() -> None: - response = await client.bank_accounts.list() + response = await client.bank_accounts.list( + cursor="cursor", + limit=1, + location_id="location_id", + ) async for item in response: yield item diff --git a/src/square/bookings/__init__.py b/src/square/bookings/__init__.py index 96ceaa83..4226d9ab 100644 --- a/src/square/bookings/__init__.py +++ b/src/square/bookings/__init__.py @@ -2,6 +2,38 @@ # isort: skip_file -from . import custom_attribute_definitions, custom_attributes, location_profiles, team_member_profiles +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import custom_attribute_definitions, custom_attributes, location_profiles, team_member_profiles +_dynamic_imports: typing.Dict[str, str] = { + "custom_attribute_definitions": ".custom_attribute_definitions", + "custom_attributes": ".custom_attributes", + "location_profiles": ".location_profiles", + "team_member_profiles": ".team_member_profiles", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["custom_attribute_definitions", "custom_attributes", "location_profiles", "team_member_profiles"] diff --git a/src/square/bookings/client.py b/src/square/bookings/client.py index 72660501..c8899695 100644 --- a/src/square/bookings/client.py +++ b/src/square/bookings/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -17,12 +19,16 @@ from ..types.retrieve_location_booking_profile_response import RetrieveLocationBookingProfileResponse from ..types.search_availability_response import SearchAvailabilityResponse from ..types.update_booking_response import UpdateBookingResponse -from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient, CustomAttributeDefinitionsClient -from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient -from .location_profiles.client import AsyncLocationProfilesClient, LocationProfilesClient from .raw_client import AsyncRawBookingsClient, RawBookingsClient -from .team_member_profiles.client import AsyncTeamMemberProfilesClient, TeamMemberProfilesClient +if typing.TYPE_CHECKING: + from .custom_attribute_definitions.client import ( + AsyncCustomAttributeDefinitionsClient, + CustomAttributeDefinitionsClient, + ) + from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient + from .location_profiles.client import AsyncLocationProfilesClient, LocationProfilesClient + from .team_member_profiles.client import AsyncTeamMemberProfilesClient, TeamMemberProfilesClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -30,13 +36,11 @@ class BookingsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawBookingsClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=client_wrapper) - - self.custom_attributes = CustomAttributesClient(client_wrapper=client_wrapper) - - self.location_profiles = LocationProfilesClient(client_wrapper=client_wrapper) - - self.team_member_profiles = TeamMemberProfilesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[CustomAttributeDefinitionsClient] = None + self._custom_attributes: typing.Optional[CustomAttributesClient] = None + self._location_profiles: typing.Optional[LocationProfilesClient] = None + self._team_member_profiles: typing.Optional[TeamMemberProfilesClient] = None @property def with_raw_response(self) -> RawBookingsClient: @@ -105,7 +109,15 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.bookings.list() + response = client.bookings.list( + limit=1, + cursor="cursor", + customer_id="customer_id", + team_member_id="team_member_id", + location_id="location_id", + start_at_min="start_at_min", + start_at_max="start_at_max", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -488,17 +500,47 @@ def cancel( ) return _response.data + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import CustomAttributeDefinitionsClient # noqa: E402 -class AsyncBookingsClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._raw_client = AsyncRawBookingsClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient(client_wrapper=client_wrapper) + self._custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=self._client_wrapper) + return self._custom_attribute_definitions + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import CustomAttributesClient # noqa: E402 + + self._custom_attributes = CustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes + + @property + def location_profiles(self): + if self._location_profiles is None: + from .location_profiles.client import LocationProfilesClient # noqa: E402 + + self._location_profiles = LocationProfilesClient(client_wrapper=self._client_wrapper) + return self._location_profiles + + @property + def team_member_profiles(self): + if self._team_member_profiles is None: + from .team_member_profiles.client import TeamMemberProfilesClient # noqa: E402 - self.custom_attributes = AsyncCustomAttributesClient(client_wrapper=client_wrapper) + self._team_member_profiles = TeamMemberProfilesClient(client_wrapper=self._client_wrapper) + return self._team_member_profiles - self.location_profiles = AsyncLocationProfilesClient(client_wrapper=client_wrapper) - self.team_member_profiles = AsyncTeamMemberProfilesClient(client_wrapper=client_wrapper) +class AsyncBookingsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawBookingsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[AsyncCustomAttributeDefinitionsClient] = None + self._custom_attributes: typing.Optional[AsyncCustomAttributesClient] = None + self._location_profiles: typing.Optional[AsyncLocationProfilesClient] = None + self._team_member_profiles: typing.Optional[AsyncTeamMemberProfilesClient] = None @property def with_raw_response(self) -> AsyncRawBookingsClient: @@ -572,7 +614,15 @@ async def list( async def main() -> None: - response = await client.bookings.list() + response = await client.bookings.list( + limit=1, + cursor="cursor", + customer_id="customer_id", + team_member_id="team_member_id", + location_id="location_id", + start_at_min="start_at_min", + start_at_max="start_at_max", + ) async for item in response: yield item @@ -1036,3 +1086,37 @@ async def main() -> None: request_options=request_options, ) return _response.data + + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient # noqa: E402 + + self._custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient( + client_wrapper=self._client_wrapper + ) + return self._custom_attribute_definitions + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import AsyncCustomAttributesClient # noqa: E402 + + self._custom_attributes = AsyncCustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes + + @property + def location_profiles(self): + if self._location_profiles is None: + from .location_profiles.client import AsyncLocationProfilesClient # noqa: E402 + + self._location_profiles = AsyncLocationProfilesClient(client_wrapper=self._client_wrapper) + return self._location_profiles + + @property + def team_member_profiles(self): + if self._team_member_profiles is None: + from .team_member_profiles.client import AsyncTeamMemberProfilesClient # noqa: E402 + + self._team_member_profiles = AsyncTeamMemberProfilesClient(client_wrapper=self._client_wrapper) + return self._team_member_profiles diff --git a/src/square/bookings/custom_attribute_definitions/client.py b/src/square/bookings/custom_attribute_definitions/client.py index 120ad244..13fe4564 100644 --- a/src/square/bookings/custom_attribute_definitions/client.py +++ b/src/square/bookings/custom_attribute_definitions/client.py @@ -74,7 +74,10 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.bookings.custom_attribute_definitions.list() + response = client.bookings.custom_attribute_definitions.list( + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -186,6 +189,7 @@ def get( ) client.bookings.custom_attribute_definitions.get( key="key", + version=1, ) """ _response = self._raw_client.get(key, version=version, request_options=request_options) @@ -359,7 +363,10 @@ async def list( async def main() -> None: - response = await client.bookings.custom_attribute_definitions.list() + response = await client.bookings.custom_attribute_definitions.list( + limit=1, + cursor="cursor", + ) async for item in response: yield item @@ -488,6 +495,7 @@ async def get( async def main() -> None: await client.bookings.custom_attribute_definitions.get( key="key", + version=1, ) diff --git a/src/square/bookings/custom_attributes/client.py b/src/square/bookings/custom_attributes/client.py index 5b4c1a66..88c89339 100644 --- a/src/square/bookings/custom_attributes/client.py +++ b/src/square/bookings/custom_attributes/client.py @@ -175,6 +175,9 @@ def list( ) response = client.bookings.custom_attributes.list( booking_id="booking_id", + limit=1, + cursor="cursor", + with_definitions=True, ) for item in response: yield item @@ -240,6 +243,8 @@ def get( client.bookings.custom_attributes.get( booking_id="booking_id", key="key", + with_definition=True, + version=1, ) """ _response = self._raw_client.get( @@ -541,6 +546,9 @@ async def list( async def main() -> None: response = await client.bookings.custom_attributes.list( booking_id="booking_id", + limit=1, + cursor="cursor", + with_definitions=True, ) async for item in response: yield item @@ -615,6 +623,8 @@ async def main() -> None: await client.bookings.custom_attributes.get( booking_id="booking_id", key="key", + with_definition=True, + version=1, ) diff --git a/src/square/bookings/location_profiles/client.py b/src/square/bookings/location_profiles/client.py index 4aef41c6..aeffbc01 100644 --- a/src/square/bookings/location_profiles/client.py +++ b/src/square/bookings/location_profiles/client.py @@ -57,7 +57,10 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.bookings.location_profiles.list() + response = client.bookings.location_profiles.list( + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -120,7 +123,10 @@ async def list( async def main() -> None: - response = await client.bookings.location_profiles.list() + response = await client.bookings.location_profiles.list( + limit=1, + cursor="cursor", + ) async for item in response: yield item diff --git a/src/square/bookings/team_member_profiles/client.py b/src/square/bookings/team_member_profiles/client.py index 9ad7bcde..8d3dae39 100644 --- a/src/square/bookings/team_member_profiles/client.py +++ b/src/square/bookings/team_member_profiles/client.py @@ -66,7 +66,12 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.bookings.team_member_profiles.list() + response = client.bookings.team_member_profiles.list( + bookable_only=True, + limit=1, + cursor="cursor", + location_id="location_id", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -176,7 +181,12 @@ async def list( async def main() -> None: - response = await client.bookings.team_member_profiles.list() + response = await client.bookings.team_member_profiles.list( + bookable_only=True, + limit=1, + cursor="cursor", + location_id="location_id", + ) async for item in response: yield item diff --git a/src/square/cards/client.py b/src/square/cards/client.py index acca8951..ff00ded3 100644 --- a/src/square/cards/client.py +++ b/src/square/cards/client.py @@ -84,7 +84,13 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.cards.list() + response = client.cards.list( + cursor="cursor", + customer_id="customer_id", + include_disabled=True, + reference_id="reference_id", + sort_order="DESC", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -313,7 +319,13 @@ async def list( async def main() -> None: - response = await client.cards.list() + response = await client.cards.list( + cursor="cursor", + customer_id="customer_id", + include_disabled=True, + reference_id="reference_id", + sort_order="DESC", + ) async for item in response: yield item diff --git a/src/square/cash_drawers/__init__.py b/src/square/cash_drawers/__init__.py index 4b2d2334..2fb709c3 100644 --- a/src/square/cash_drawers/__init__.py +++ b/src/square/cash_drawers/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import shifts +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import shifts +_dynamic_imports: typing.Dict[str, str] = {"shifts": ".shifts"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["shifts"] diff --git a/src/square/cash_drawers/client.py b/src/square/cash_drawers/client.py index 063f3629..45a08df9 100644 --- a/src/square/cash_drawers/client.py +++ b/src/square/cash_drawers/client.py @@ -1,14 +1,21 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + +import typing + from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .raw_client import AsyncRawCashDrawersClient, RawCashDrawersClient -from .shifts.client import AsyncShiftsClient, ShiftsClient + +if typing.TYPE_CHECKING: + from .shifts.client import AsyncShiftsClient, ShiftsClient class CashDrawersClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawCashDrawersClient(client_wrapper=client_wrapper) - self.shifts = ShiftsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._shifts: typing.Optional[ShiftsClient] = None @property def with_raw_response(self) -> RawCashDrawersClient: @@ -21,11 +28,20 @@ def with_raw_response(self) -> RawCashDrawersClient: """ return self._raw_client + @property + def shifts(self): + if self._shifts is None: + from .shifts.client import ShiftsClient # noqa: E402 + + self._shifts = ShiftsClient(client_wrapper=self._client_wrapper) + return self._shifts + class AsyncCashDrawersClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawCashDrawersClient(client_wrapper=client_wrapper) - self.shifts = AsyncShiftsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._shifts: typing.Optional[AsyncShiftsClient] = None @property def with_raw_response(self) -> AsyncRawCashDrawersClient: @@ -37,3 +53,11 @@ def with_raw_response(self) -> AsyncRawCashDrawersClient: AsyncRawCashDrawersClient """ return self._raw_client + + @property + def shifts(self): + if self._shifts is None: + from .shifts.client import AsyncShiftsClient # noqa: E402 + + self._shifts = AsyncShiftsClient(client_wrapper=self._client_wrapper) + return self._shifts diff --git a/src/square/cash_drawers/shifts/client.py b/src/square/cash_drawers/shifts/client.py index 5a4e7b17..fa698f2b 100644 --- a/src/square/cash_drawers/shifts/client.py +++ b/src/square/cash_drawers/shifts/client.py @@ -81,6 +81,11 @@ def list( ) response = client.cash_drawers.shifts.list( location_id="location_id", + sort_order="DESC", + begin_time="begin_time", + end_time="end_time", + limit=1, + cursor="cursor", ) for item in response: yield item @@ -181,6 +186,8 @@ def list_events( response = client.cash_drawers.shifts.list_events( shift_id="shift_id", location_id="location_id", + limit=1, + cursor="cursor", ) for item in response: yield item @@ -267,6 +274,11 @@ async def list( async def main() -> None: response = await client.cash_drawers.shifts.list( location_id="location_id", + sort_order="DESC", + begin_time="begin_time", + end_time="end_time", + limit=1, + cursor="cursor", ) async for item in response: yield item @@ -384,6 +396,8 @@ async def main() -> None: response = await client.cash_drawers.shifts.list_events( shift_id="shift_id", location_id="location_id", + limit=1, + cursor="cursor", ) async for item in response: yield item diff --git a/src/square/catalog/__init__.py b/src/square/catalog/__init__.py index 9a90551e..74d161e1 100644 --- a/src/square/catalog/__init__.py +++ b/src/square/catalog/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import images, object +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import images, object +_dynamic_imports: typing.Dict[str, str] = {"images": ".images", "object": ".object"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["images", "object"] diff --git a/src/square/catalog/client.py b/src/square/catalog/client.py index b48b77ce..a13255b5 100644 --- a/src/square/catalog/client.py +++ b/src/square/catalog/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -22,10 +24,11 @@ from ..types.sort_order import SortOrder from ..types.update_item_modifier_lists_response import UpdateItemModifierListsResponse from ..types.update_item_taxes_response import UpdateItemTaxesResponse -from .images.client import AsyncImagesClient, ImagesClient -from .object.client import AsyncObjectClient, ObjectClient from .raw_client import AsyncRawCatalogClient, RawCatalogClient +if typing.TYPE_CHECKING: + from .images.client import AsyncImagesClient, ImagesClient + from .object.client import AsyncObjectClient, ObjectClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -33,9 +36,9 @@ class CatalogClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawCatalogClient(client_wrapper=client_wrapper) - self.images = ImagesClient(client_wrapper=client_wrapper) - - self.object = ObjectClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._images: typing.Optional[ImagesClient] = None + self._object: typing.Optional[ObjectClient] = None @property def with_raw_response(self) -> RawCatalogClient: @@ -385,7 +388,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.catalog.list() + response = client.catalog.list( + cursor="cursor", + types="types", + catalog_version=1000000, + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -745,13 +752,29 @@ def update_item_taxes( ) return _response.data + @property + def images(self): + if self._images is None: + from .images.client import ImagesClient # noqa: E402 + + self._images = ImagesClient(client_wrapper=self._client_wrapper) + return self._images + + @property + def object(self): + if self._object is None: + from .object.client import ObjectClient # noqa: E402 + + self._object = ObjectClient(client_wrapper=self._client_wrapper) + return self._object + class AsyncCatalogClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawCatalogClient(client_wrapper=client_wrapper) - self.images = AsyncImagesClient(client_wrapper=client_wrapper) - - self.object = AsyncObjectClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._images: typing.Optional[AsyncImagesClient] = None + self._object: typing.Optional[AsyncObjectClient] = None @property def with_raw_response(self) -> AsyncRawCatalogClient: @@ -1138,7 +1161,11 @@ async def list( async def main() -> None: - response = await client.catalog.list() + response = await client.catalog.list( + cursor="cursor", + types="types", + catalog_version=1000000, + ) async for item in response: yield item @@ -1536,3 +1563,19 @@ async def main() -> None: request_options=request_options, ) return _response.data + + @property + def images(self): + if self._images is None: + from .images.client import AsyncImagesClient # noqa: E402 + + self._images = AsyncImagesClient(client_wrapper=self._client_wrapper) + return self._images + + @property + def object(self): + if self._object is None: + from .object.client import AsyncObjectClient # noqa: E402 + + self._object = AsyncObjectClient(client_wrapper=self._client_wrapper) + return self._object diff --git a/src/square/catalog/object/client.py b/src/square/catalog/object/client.py index 31251336..62f923fb 100644 --- a/src/square/catalog/object/client.py +++ b/src/square/catalog/object/client.py @@ -156,6 +156,9 @@ def get( ) client.catalog.object.get( object_id="object_id", + include_related_objects=True, + catalog_version=1000000, + include_category_path_to_root=True, ) """ _response = self._raw_client.get( @@ -367,6 +370,9 @@ async def get( async def main() -> None: await client.catalog.object.get( object_id="object_id", + include_related_objects=True, + catalog_version=1000000, + include_category_path_to_root=True, ) diff --git a/src/square/channels/__init__.py b/src/square/channels/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/square/channels/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/square/channels/client.py b/src/square/channels/client.py new file mode 100644 index 00000000..05979621 --- /dev/null +++ b/src/square/channels/client.py @@ -0,0 +1,339 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.pagination import AsyncPager, SyncPager +from ..core.request_options import RequestOptions +from ..types.bulk_retrieve_channels_response import BulkRetrieveChannelsResponse +from ..types.channel import Channel +from ..types.channel_status import ChannelStatus +from ..types.reference_type import ReferenceType +from ..types.retrieve_channel_response import RetrieveChannelResponse +from .raw_client import AsyncRawChannelsClient, RawChannelsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class ChannelsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawChannelsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawChannelsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawChannelsClient + """ + return self._raw_client + + def list( + self, + *, + reference_type: typing.Optional[ReferenceType] = None, + reference_id: typing.Optional[str] = None, + status: typing.Optional[ChannelStatus] = None, + cursor: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Channel]: + """ + + + Parameters + ---------- + reference_type : typing.Optional[ReferenceType] + Type of reference associated to channel + + reference_id : typing.Optional[str] + id of reference associated to channel + + status : typing.Optional[ChannelStatus] + Status of channel + + cursor : typing.Optional[str] + Cursor to fetch the next result + + limit : typing.Optional[int] + Maximum number of results to return. + When not provided the returned results will be cap at 100 channels. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Channel] + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + response = client.channels.list( + reference_type="UNKNOWN_TYPE", + reference_id="reference_id", + status="ACTIVE", + cursor="cursor", + limit=1, + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list( + reference_type=reference_type, + reference_id=reference_id, + status=status, + cursor=cursor, + limit=limit, + request_options=request_options, + ) + + def bulk_retrieve( + self, *, channel_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> BulkRetrieveChannelsResponse: + """ + + + Parameters + ---------- + channel_ids : typing.Sequence[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + BulkRetrieveChannelsResponse + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + client.channels.bulk_retrieve( + channel_ids=["CH_9C03D0B59", "CH_6X139B5MN", "NOT_EXISTING"], + ) + """ + _response = self._raw_client.bulk_retrieve(channel_ids=channel_ids, request_options=request_options) + return _response.data + + def get( + self, channel_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> RetrieveChannelResponse: + """ + + + Parameters + ---------- + channel_id : str + A channel id + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + RetrieveChannelResponse + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + client.channels.get( + channel_id="channel_id", + ) + """ + _response = self._raw_client.get(channel_id, request_options=request_options) + return _response.data + + +class AsyncChannelsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawChannelsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawChannelsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawChannelsClient + """ + return self._raw_client + + async def list( + self, + *, + reference_type: typing.Optional[ReferenceType] = None, + reference_id: typing.Optional[str] = None, + status: typing.Optional[ChannelStatus] = None, + cursor: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Channel]: + """ + + + Parameters + ---------- + reference_type : typing.Optional[ReferenceType] + Type of reference associated to channel + + reference_id : typing.Optional[str] + id of reference associated to channel + + status : typing.Optional[ChannelStatus] + Status of channel + + cursor : typing.Optional[str] + Cursor to fetch the next result + + limit : typing.Optional[int] + Maximum number of results to return. + When not provided the returned results will be cap at 100 channels. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Channel] + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.channels.list( + reference_type="UNKNOWN_TYPE", + reference_id="reference_id", + status="ACTIVE", + cursor="cursor", + limit=1, + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list( + reference_type=reference_type, + reference_id=reference_id, + status=status, + cursor=cursor, + limit=limit, + request_options=request_options, + ) + + async def bulk_retrieve( + self, *, channel_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> BulkRetrieveChannelsResponse: + """ + + + Parameters + ---------- + channel_ids : typing.Sequence[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + BulkRetrieveChannelsResponse + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.channels.bulk_retrieve( + channel_ids=["CH_9C03D0B59", "CH_6X139B5MN", "NOT_EXISTING"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.bulk_retrieve(channel_ids=channel_ids, request_options=request_options) + return _response.data + + async def get( + self, channel_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> RetrieveChannelResponse: + """ + + + Parameters + ---------- + channel_id : str + A channel id + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + RetrieveChannelResponse + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.channels.get( + channel_id="channel_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(channel_id, request_options=request_options) + return _response.data diff --git a/src/square/channels/raw_client.py b/src/square/channels/raw_client.py new file mode 100644 index 00000000..9fa4886d --- /dev/null +++ b/src/square/channels/raw_client.py @@ -0,0 +1,360 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.pagination import AsyncPager, BaseHttpResponse, SyncPager +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..types.bulk_retrieve_channels_response import BulkRetrieveChannelsResponse +from ..types.channel import Channel +from ..types.channel_status import ChannelStatus +from ..types.list_channels_response import ListChannelsResponse +from ..types.reference_type import ReferenceType +from ..types.retrieve_channel_response import RetrieveChannelResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawChannelsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + *, + reference_type: typing.Optional[ReferenceType] = None, + reference_id: typing.Optional[str] = None, + status: typing.Optional[ChannelStatus] = None, + cursor: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Channel]: + """ + + + Parameters + ---------- + reference_type : typing.Optional[ReferenceType] + Type of reference associated to channel + + reference_id : typing.Optional[str] + id of reference associated to channel + + status : typing.Optional[ChannelStatus] + Status of channel + + cursor : typing.Optional[str] + Cursor to fetch the next result + + limit : typing.Optional[int] + Maximum number of results to return. + When not provided the returned results will be cap at 100 channels. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Channel] + Success + """ + _response = self._client_wrapper.httpx_client.request( + "v2/channels", + method="GET", + params={ + "reference_type": reference_type, + "reference_id": reference_id, + "status": status, + "cursor": cursor, + "limit": limit, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListChannelsResponse, + construct_type( + type_=ListChannelsResponse, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.channels + _parsed_next = _parsed_response.cursor + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + reference_type=reference_type, + reference_id=reference_id, + status=status, + cursor=_parsed_next, + limit=limit, + request_options=request_options, + ) + return SyncPager( + has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response) + ) + _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 bulk_retrieve( + self, *, channel_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[BulkRetrieveChannelsResponse]: + """ + + + Parameters + ---------- + channel_ids : typing.Sequence[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkRetrieveChannelsResponse] + Success + """ + _response = self._client_wrapper.httpx_client.request( + "v2/channels/bulk-retrieve", + method="POST", + json={ + "channel_ids": channel_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkRetrieveChannelsResponse, + construct_type( + type_=BulkRetrieveChannelsResponse, # 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 get( + self, channel_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[RetrieveChannelResponse]: + """ + + + Parameters + ---------- + channel_id : str + A channel id + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[RetrieveChannelResponse] + Success + """ + _response = self._client_wrapper.httpx_client.request( + f"v2/channels/{jsonable_encoder(channel_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RetrieveChannelResponse, + construct_type( + type_=RetrieveChannelResponse, # 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 AsyncRawChannelsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + *, + reference_type: typing.Optional[ReferenceType] = None, + reference_id: typing.Optional[str] = None, + status: typing.Optional[ChannelStatus] = None, + cursor: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Channel]: + """ + + + Parameters + ---------- + reference_type : typing.Optional[ReferenceType] + Type of reference associated to channel + + reference_id : typing.Optional[str] + id of reference associated to channel + + status : typing.Optional[ChannelStatus] + Status of channel + + cursor : typing.Optional[str] + Cursor to fetch the next result + + limit : typing.Optional[int] + Maximum number of results to return. + When not provided the returned results will be cap at 100 channels. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Channel] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + "v2/channels", + method="GET", + params={ + "reference_type": reference_type, + "reference_id": reference_id, + "status": status, + "cursor": cursor, + "limit": limit, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListChannelsResponse, + construct_type( + type_=ListChannelsResponse, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.channels + _parsed_next = _parsed_response.cursor + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + reference_type=reference_type, + reference_id=reference_id, + status=status, + cursor=_parsed_next, + limit=limit, + request_options=request_options, + ) + + return AsyncPager( + has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response) + ) + _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 bulk_retrieve( + self, *, channel_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[BulkRetrieveChannelsResponse]: + """ + + + Parameters + ---------- + channel_ids : typing.Sequence[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkRetrieveChannelsResponse] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + "v2/channels/bulk-retrieve", + method="POST", + json={ + "channel_ids": channel_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkRetrieveChannelsResponse, + construct_type( + type_=BulkRetrieveChannelsResponse, # 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 get( + self, channel_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[RetrieveChannelResponse]: + """ + + + Parameters + ---------- + channel_id : str + A channel id + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[RetrieveChannelResponse] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + f"v2/channels/{jsonable_encoder(channel_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RetrieveChannelResponse, + construct_type( + type_=RetrieveChannelResponse, # 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/checkout/__init__.py b/src/square/checkout/__init__.py index d303cc94..602dd63f 100644 --- a/src/square/checkout/__init__.py +++ b/src/square/checkout/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import payment_links +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import payment_links +_dynamic_imports: typing.Dict[str, str] = {"payment_links": ".payment_links"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["payment_links"] diff --git a/src/square/checkout/client.py b/src/square/checkout/client.py index a6620b12..b510a017 100644 --- a/src/square/checkout/client.py +++ b/src/square/checkout/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -10,9 +12,10 @@ from ..types.retrieve_merchant_settings_response import RetrieveMerchantSettingsResponse from ..types.update_location_settings_response import UpdateLocationSettingsResponse from ..types.update_merchant_settings_response import UpdateMerchantSettingsResponse -from .payment_links.client import AsyncPaymentLinksClient, PaymentLinksClient from .raw_client import AsyncRawCheckoutClient, RawCheckoutClient +if typing.TYPE_CHECKING: + from .payment_links.client import AsyncPaymentLinksClient, PaymentLinksClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -20,7 +23,8 @@ class CheckoutClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawCheckoutClient(client_wrapper=client_wrapper) - self.payment_links = PaymentLinksClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._payment_links: typing.Optional[PaymentLinksClient] = None @property def with_raw_response(self) -> RawCheckoutClient: @@ -175,11 +179,20 @@ def update_merchant_settings( ) return _response.data + @property + def payment_links(self): + if self._payment_links is None: + from .payment_links.client import PaymentLinksClient # noqa: E402 + + self._payment_links = PaymentLinksClient(client_wrapper=self._client_wrapper) + return self._payment_links + class AsyncCheckoutClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawCheckoutClient(client_wrapper=client_wrapper) - self.payment_links = AsyncPaymentLinksClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._payment_links: typing.Optional[AsyncPaymentLinksClient] = None @property def with_raw_response(self) -> AsyncRawCheckoutClient: @@ -365,3 +378,11 @@ async def main() -> None: merchant_settings=merchant_settings, request_options=request_options ) return _response.data + + @property + def payment_links(self): + if self._payment_links is None: + from .payment_links.client import AsyncPaymentLinksClient # noqa: E402 + + self._payment_links = AsyncPaymentLinksClient(client_wrapper=self._client_wrapper) + return self._payment_links diff --git a/src/square/checkout/payment_links/client.py b/src/square/checkout/payment_links/client.py index 00d6e9a8..26ece991 100644 --- a/src/square/checkout/payment_links/client.py +++ b/src/square/checkout/payment_links/client.py @@ -76,7 +76,10 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.checkout.payment_links.list() + response = client.checkout.payment_links.list( + cursor="cursor", + limit=1, + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -337,7 +340,10 @@ async def list( async def main() -> None: - response = await client.checkout.payment_links.list() + response = await client.checkout.payment_links.list( + cursor="cursor", + limit=1, + ) async for item in response: yield item diff --git a/src/square/client.py b/src/square/client.py index 307d6d2a..be23db98 100644 --- a/src/square/client.py +++ b/src/square/client.py @@ -1,45 +1,51 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import os import typing import httpx -from .apple_pay.client import ApplePayClient, AsyncApplePayClient -from .bank_accounts.client import AsyncBankAccountsClient, BankAccountsClient -from .bookings.client import AsyncBookingsClient, BookingsClient -from .cards.client import AsyncCardsClient, CardsClient -from .cash_drawers.client import AsyncCashDrawersClient, CashDrawersClient -from .catalog.client import AsyncCatalogClient, CatalogClient -from .checkout.client import AsyncCheckoutClient, CheckoutClient from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from .customers.client import AsyncCustomersClient, CustomersClient -from .devices.client import AsyncDevicesClient, DevicesClient -from .disputes.client import AsyncDisputesClient, DisputesClient -from .employees.client import AsyncEmployeesClient, EmployeesClient from .environment import SquareEnvironment -from .events.client import AsyncEventsClient, EventsClient -from .gift_cards.client import AsyncGiftCardsClient, GiftCardsClient -from .inventory.client import AsyncInventoryClient, InventoryClient -from .invoices.client import AsyncInvoicesClient, InvoicesClient -from .labor.client import AsyncLaborClient, LaborClient -from .locations.client import AsyncLocationsClient, LocationsClient -from .loyalty.client import AsyncLoyaltyClient, LoyaltyClient -from .merchants.client import AsyncMerchantsClient, MerchantsClient -from .mobile.client import AsyncMobileClient, MobileClient -from .o_auth.client import AsyncOAuthClient, OAuthClient -from .orders.client import AsyncOrdersClient, OrdersClient -from .payments.client import AsyncPaymentsClient, PaymentsClient -from .payouts.client import AsyncPayoutsClient, PayoutsClient -from .refunds.client import AsyncRefundsClient, RefundsClient -from .sites.client import AsyncSitesClient, SitesClient -from .snippets.client import AsyncSnippetsClient, SnippetsClient -from .subscriptions.client import AsyncSubscriptionsClient, SubscriptionsClient -from .team.client import AsyncTeamClient, TeamClient -from .team_members.client import AsyncTeamMembersClient, TeamMembersClient -from .terminal.client import AsyncTerminalClient, TerminalClient -from .v1transactions.client import AsyncV1TransactionsClient, V1TransactionsClient -from .vendors.client import AsyncVendorsClient, VendorsClient -from .webhooks.client import AsyncWebhooksClient, WebhooksClient + +if typing.TYPE_CHECKING: + from .apple_pay.client import ApplePayClient, AsyncApplePayClient + from .bank_accounts.client import AsyncBankAccountsClient, BankAccountsClient + from .bookings.client import AsyncBookingsClient, BookingsClient + from .cards.client import AsyncCardsClient, CardsClient + from .cash_drawers.client import AsyncCashDrawersClient, CashDrawersClient + from .catalog.client import AsyncCatalogClient, CatalogClient + from .channels.client import AsyncChannelsClient, ChannelsClient + from .checkout.client import AsyncCheckoutClient, CheckoutClient + from .customers.client import AsyncCustomersClient, CustomersClient + from .devices.client import AsyncDevicesClient, DevicesClient + from .disputes.client import AsyncDisputesClient, DisputesClient + from .employees.client import AsyncEmployeesClient, EmployeesClient + from .events.client import AsyncEventsClient, EventsClient + from .gift_cards.client import AsyncGiftCardsClient, GiftCardsClient + from .inventory.client import AsyncInventoryClient, InventoryClient + from .invoices.client import AsyncInvoicesClient, InvoicesClient + from .labor.client import AsyncLaborClient, LaborClient + from .locations.client import AsyncLocationsClient, LocationsClient + from .loyalty.client import AsyncLoyaltyClient, LoyaltyClient + from .merchants.client import AsyncMerchantsClient, MerchantsClient + from .mobile.client import AsyncMobileClient, MobileClient + from .o_auth.client import AsyncOAuthClient, OAuthClient + from .orders.client import AsyncOrdersClient, OrdersClient + from .payments.client import AsyncPaymentsClient, PaymentsClient + from .payouts.client import AsyncPayoutsClient, PayoutsClient + from .refunds.client import AsyncRefundsClient, RefundsClient + from .sites.client import AsyncSitesClient, SitesClient + from .snippets.client import AsyncSnippetsClient, SnippetsClient + from .subscriptions.client import AsyncSubscriptionsClient, SubscriptionsClient + from .team.client import AsyncTeamClient, TeamClient + from .team_members.client import AsyncTeamMembersClient, TeamMembersClient + from .terminal.client import AsyncTerminalClient, TerminalClient + from .transfer_orders.client import AsyncTransferOrdersClient, TransferOrdersClient + from .v1transactions.client import AsyncV1TransactionsClient, V1TransactionsClient + from .vendors.client import AsyncVendorsClient, VendorsClient + from .webhooks.client import AsyncWebhooksClient, WebhooksClient class Square: @@ -110,40 +116,330 @@ def __init__( timeout=_defaulted_timeout, version=version, ) - self.mobile = MobileClient(client_wrapper=self._client_wrapper) - self.o_auth = OAuthClient(client_wrapper=self._client_wrapper) - self.v1transactions = V1TransactionsClient(client_wrapper=self._client_wrapper) - self.apple_pay = ApplePayClient(client_wrapper=self._client_wrapper) - self.bank_accounts = BankAccountsClient(client_wrapper=self._client_wrapper) - self.bookings = BookingsClient(client_wrapper=self._client_wrapper) - self.cards = CardsClient(client_wrapper=self._client_wrapper) - self.catalog = CatalogClient(client_wrapper=self._client_wrapper) - self.customers = CustomersClient(client_wrapper=self._client_wrapper) - self.devices = DevicesClient(client_wrapper=self._client_wrapper) - self.disputes = DisputesClient(client_wrapper=self._client_wrapper) - self.employees = EmployeesClient(client_wrapper=self._client_wrapper) - self.events = EventsClient(client_wrapper=self._client_wrapper) - self.gift_cards = GiftCardsClient(client_wrapper=self._client_wrapper) - self.inventory = InventoryClient(client_wrapper=self._client_wrapper) - self.invoices = InvoicesClient(client_wrapper=self._client_wrapper) - self.labor = LaborClient(client_wrapper=self._client_wrapper) - self.locations = LocationsClient(client_wrapper=self._client_wrapper) - self.loyalty = LoyaltyClient(client_wrapper=self._client_wrapper) - self.merchants = MerchantsClient(client_wrapper=self._client_wrapper) - self.checkout = CheckoutClient(client_wrapper=self._client_wrapper) - self.orders = OrdersClient(client_wrapper=self._client_wrapper) - self.payments = PaymentsClient(client_wrapper=self._client_wrapper) - self.payouts = PayoutsClient(client_wrapper=self._client_wrapper) - self.refunds = RefundsClient(client_wrapper=self._client_wrapper) - self.sites = SitesClient(client_wrapper=self._client_wrapper) - self.snippets = SnippetsClient(client_wrapper=self._client_wrapper) - self.subscriptions = SubscriptionsClient(client_wrapper=self._client_wrapper) - self.team_members = TeamMembersClient(client_wrapper=self._client_wrapper) - self.team = TeamClient(client_wrapper=self._client_wrapper) - self.terminal = TerminalClient(client_wrapper=self._client_wrapper) - self.vendors = VendorsClient(client_wrapper=self._client_wrapper) - self.cash_drawers = CashDrawersClient(client_wrapper=self._client_wrapper) - self.webhooks = WebhooksClient(client_wrapper=self._client_wrapper) + self._mobile: typing.Optional[MobileClient] = None + self._o_auth: typing.Optional[OAuthClient] = None + self._v1transactions: typing.Optional[V1TransactionsClient] = None + self._apple_pay: typing.Optional[ApplePayClient] = None + self._bank_accounts: typing.Optional[BankAccountsClient] = None + self._bookings: typing.Optional[BookingsClient] = None + self._cards: typing.Optional[CardsClient] = None + self._catalog: typing.Optional[CatalogClient] = None + self._channels: typing.Optional[ChannelsClient] = None + self._customers: typing.Optional[CustomersClient] = None + self._devices: typing.Optional[DevicesClient] = None + self._disputes: typing.Optional[DisputesClient] = None + self._employees: typing.Optional[EmployeesClient] = None + self._events: typing.Optional[EventsClient] = None + self._gift_cards: typing.Optional[GiftCardsClient] = None + self._inventory: typing.Optional[InventoryClient] = None + self._invoices: typing.Optional[InvoicesClient] = None + self._labor: typing.Optional[LaborClient] = None + self._locations: typing.Optional[LocationsClient] = None + self._loyalty: typing.Optional[LoyaltyClient] = None + self._merchants: typing.Optional[MerchantsClient] = None + self._checkout: typing.Optional[CheckoutClient] = None + self._orders: typing.Optional[OrdersClient] = None + self._payments: typing.Optional[PaymentsClient] = None + self._payouts: typing.Optional[PayoutsClient] = None + self._refunds: typing.Optional[RefundsClient] = None + self._sites: typing.Optional[SitesClient] = None + self._snippets: typing.Optional[SnippetsClient] = None + self._subscriptions: typing.Optional[SubscriptionsClient] = None + self._team_members: typing.Optional[TeamMembersClient] = None + self._team: typing.Optional[TeamClient] = None + self._terminal: typing.Optional[TerminalClient] = None + self._transfer_orders: typing.Optional[TransferOrdersClient] = None + self._vendors: typing.Optional[VendorsClient] = None + self._cash_drawers: typing.Optional[CashDrawersClient] = None + self._webhooks: typing.Optional[WebhooksClient] = None + + @property + def mobile(self): + if self._mobile is None: + from .mobile.client import MobileClient # noqa: E402 + + self._mobile = MobileClient(client_wrapper=self._client_wrapper) + return self._mobile + + @property + def o_auth(self): + if self._o_auth is None: + from .o_auth.client import OAuthClient # noqa: E402 + + self._o_auth = OAuthClient(client_wrapper=self._client_wrapper) + return self._o_auth + + @property + def v1transactions(self): + if self._v1transactions is None: + from .v1transactions.client import V1TransactionsClient # noqa: E402 + + self._v1transactions = V1TransactionsClient(client_wrapper=self._client_wrapper) + return self._v1transactions + + @property + def apple_pay(self): + if self._apple_pay is None: + from .apple_pay.client import ApplePayClient # noqa: E402 + + self._apple_pay = ApplePayClient(client_wrapper=self._client_wrapper) + return self._apple_pay + + @property + def bank_accounts(self): + if self._bank_accounts is None: + from .bank_accounts.client import BankAccountsClient # noqa: E402 + + self._bank_accounts = BankAccountsClient(client_wrapper=self._client_wrapper) + return self._bank_accounts + + @property + def bookings(self): + if self._bookings is None: + from .bookings.client import BookingsClient # noqa: E402 + + self._bookings = BookingsClient(client_wrapper=self._client_wrapper) + return self._bookings + + @property + def cards(self): + if self._cards is None: + from .cards.client import CardsClient # noqa: E402 + + self._cards = CardsClient(client_wrapper=self._client_wrapper) + return self._cards + + @property + def catalog(self): + if self._catalog is None: + from .catalog.client import CatalogClient # noqa: E402 + + self._catalog = CatalogClient(client_wrapper=self._client_wrapper) + return self._catalog + + @property + def channels(self): + if self._channels is None: + from .channels.client import ChannelsClient # noqa: E402 + + self._channels = ChannelsClient(client_wrapper=self._client_wrapper) + return self._channels + + @property + def customers(self): + if self._customers is None: + from .customers.client import CustomersClient # noqa: E402 + + self._customers = CustomersClient(client_wrapper=self._client_wrapper) + return self._customers + + @property + def devices(self): + if self._devices is None: + from .devices.client import DevicesClient # noqa: E402 + + self._devices = DevicesClient(client_wrapper=self._client_wrapper) + return self._devices + + @property + def disputes(self): + if self._disputes is None: + from .disputes.client import DisputesClient # noqa: E402 + + self._disputes = DisputesClient(client_wrapper=self._client_wrapper) + return self._disputes + + @property + def employees(self): + if self._employees is None: + from .employees.client import EmployeesClient # noqa: E402 + + self._employees = EmployeesClient(client_wrapper=self._client_wrapper) + return self._employees + + @property + def events(self): + if self._events is None: + from .events.client import EventsClient # noqa: E402 + + self._events = EventsClient(client_wrapper=self._client_wrapper) + return self._events + + @property + def gift_cards(self): + if self._gift_cards is None: + from .gift_cards.client import GiftCardsClient # noqa: E402 + + self._gift_cards = GiftCardsClient(client_wrapper=self._client_wrapper) + return self._gift_cards + + @property + def inventory(self): + if self._inventory is None: + from .inventory.client import InventoryClient # noqa: E402 + + self._inventory = InventoryClient(client_wrapper=self._client_wrapper) + return self._inventory + + @property + def invoices(self): + if self._invoices is None: + from .invoices.client import InvoicesClient # noqa: E402 + + self._invoices = InvoicesClient(client_wrapper=self._client_wrapper) + return self._invoices + + @property + def labor(self): + if self._labor is None: + from .labor.client import LaborClient # noqa: E402 + + self._labor = LaborClient(client_wrapper=self._client_wrapper) + return self._labor + + @property + def locations(self): + if self._locations is None: + from .locations.client import LocationsClient # noqa: E402 + + self._locations = LocationsClient(client_wrapper=self._client_wrapper) + return self._locations + + @property + def loyalty(self): + if self._loyalty is None: + from .loyalty.client import LoyaltyClient # noqa: E402 + + self._loyalty = LoyaltyClient(client_wrapper=self._client_wrapper) + return self._loyalty + + @property + def merchants(self): + if self._merchants is None: + from .merchants.client import MerchantsClient # noqa: E402 + + self._merchants = MerchantsClient(client_wrapper=self._client_wrapper) + return self._merchants + + @property + def checkout(self): + if self._checkout is None: + from .checkout.client import CheckoutClient # noqa: E402 + + self._checkout = CheckoutClient(client_wrapper=self._client_wrapper) + return self._checkout + + @property + def orders(self): + if self._orders is None: + from .orders.client import OrdersClient # noqa: E402 + + self._orders = OrdersClient(client_wrapper=self._client_wrapper) + return self._orders + + @property + def payments(self): + if self._payments is None: + from .payments.client import PaymentsClient # noqa: E402 + + self._payments = PaymentsClient(client_wrapper=self._client_wrapper) + return self._payments + + @property + def payouts(self): + if self._payouts is None: + from .payouts.client import PayoutsClient # noqa: E402 + + self._payouts = PayoutsClient(client_wrapper=self._client_wrapper) + return self._payouts + + @property + def refunds(self): + if self._refunds is None: + from .refunds.client import RefundsClient # noqa: E402 + + self._refunds = RefundsClient(client_wrapper=self._client_wrapper) + return self._refunds + + @property + def sites(self): + if self._sites is None: + from .sites.client import SitesClient # noqa: E402 + + self._sites = SitesClient(client_wrapper=self._client_wrapper) + return self._sites + + @property + def snippets(self): + if self._snippets is None: + from .snippets.client import SnippetsClient # noqa: E402 + + self._snippets = SnippetsClient(client_wrapper=self._client_wrapper) + return self._snippets + + @property + def subscriptions(self): + if self._subscriptions is None: + from .subscriptions.client import SubscriptionsClient # noqa: E402 + + self._subscriptions = SubscriptionsClient(client_wrapper=self._client_wrapper) + return self._subscriptions + + @property + def team_members(self): + if self._team_members is None: + from .team_members.client import TeamMembersClient # noqa: E402 + + self._team_members = TeamMembersClient(client_wrapper=self._client_wrapper) + return self._team_members + + @property + def team(self): + if self._team is None: + from .team.client import TeamClient # noqa: E402 + + self._team = TeamClient(client_wrapper=self._client_wrapper) + return self._team + + @property + def terminal(self): + if self._terminal is None: + from .terminal.client import TerminalClient # noqa: E402 + + self._terminal = TerminalClient(client_wrapper=self._client_wrapper) + return self._terminal + + @property + def transfer_orders(self): + if self._transfer_orders is None: + from .transfer_orders.client import TransferOrdersClient # noqa: E402 + + self._transfer_orders = TransferOrdersClient(client_wrapper=self._client_wrapper) + return self._transfer_orders + + @property + def vendors(self): + if self._vendors is None: + from .vendors.client import VendorsClient # noqa: E402 + + self._vendors = VendorsClient(client_wrapper=self._client_wrapper) + return self._vendors + + @property + def cash_drawers(self): + if self._cash_drawers is None: + from .cash_drawers.client import CashDrawersClient # noqa: E402 + + self._cash_drawers = CashDrawersClient(client_wrapper=self._client_wrapper) + return self._cash_drawers + + @property + def webhooks(self): + if self._webhooks is None: + from .webhooks.client import WebhooksClient # noqa: E402 + + self._webhooks = WebhooksClient(client_wrapper=self._client_wrapper) + return self._webhooks class AsyncSquare: @@ -214,40 +510,330 @@ def __init__( timeout=_defaulted_timeout, version=version, ) - self.mobile = AsyncMobileClient(client_wrapper=self._client_wrapper) - self.o_auth = AsyncOAuthClient(client_wrapper=self._client_wrapper) - self.v1transactions = AsyncV1TransactionsClient(client_wrapper=self._client_wrapper) - self.apple_pay = AsyncApplePayClient(client_wrapper=self._client_wrapper) - self.bank_accounts = AsyncBankAccountsClient(client_wrapper=self._client_wrapper) - self.bookings = AsyncBookingsClient(client_wrapper=self._client_wrapper) - self.cards = AsyncCardsClient(client_wrapper=self._client_wrapper) - self.catalog = AsyncCatalogClient(client_wrapper=self._client_wrapper) - self.customers = AsyncCustomersClient(client_wrapper=self._client_wrapper) - self.devices = AsyncDevicesClient(client_wrapper=self._client_wrapper) - self.disputes = AsyncDisputesClient(client_wrapper=self._client_wrapper) - self.employees = AsyncEmployeesClient(client_wrapper=self._client_wrapper) - self.events = AsyncEventsClient(client_wrapper=self._client_wrapper) - self.gift_cards = AsyncGiftCardsClient(client_wrapper=self._client_wrapper) - self.inventory = AsyncInventoryClient(client_wrapper=self._client_wrapper) - self.invoices = AsyncInvoicesClient(client_wrapper=self._client_wrapper) - self.labor = AsyncLaborClient(client_wrapper=self._client_wrapper) - self.locations = AsyncLocationsClient(client_wrapper=self._client_wrapper) - self.loyalty = AsyncLoyaltyClient(client_wrapper=self._client_wrapper) - self.merchants = AsyncMerchantsClient(client_wrapper=self._client_wrapper) - self.checkout = AsyncCheckoutClient(client_wrapper=self._client_wrapper) - self.orders = AsyncOrdersClient(client_wrapper=self._client_wrapper) - self.payments = AsyncPaymentsClient(client_wrapper=self._client_wrapper) - self.payouts = AsyncPayoutsClient(client_wrapper=self._client_wrapper) - self.refunds = AsyncRefundsClient(client_wrapper=self._client_wrapper) - self.sites = AsyncSitesClient(client_wrapper=self._client_wrapper) - self.snippets = AsyncSnippetsClient(client_wrapper=self._client_wrapper) - self.subscriptions = AsyncSubscriptionsClient(client_wrapper=self._client_wrapper) - self.team_members = AsyncTeamMembersClient(client_wrapper=self._client_wrapper) - self.team = AsyncTeamClient(client_wrapper=self._client_wrapper) - self.terminal = AsyncTerminalClient(client_wrapper=self._client_wrapper) - self.vendors = AsyncVendorsClient(client_wrapper=self._client_wrapper) - self.cash_drawers = AsyncCashDrawersClient(client_wrapper=self._client_wrapper) - self.webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper) + self._mobile: typing.Optional[AsyncMobileClient] = None + self._o_auth: typing.Optional[AsyncOAuthClient] = None + self._v1transactions: typing.Optional[AsyncV1TransactionsClient] = None + self._apple_pay: typing.Optional[AsyncApplePayClient] = None + self._bank_accounts: typing.Optional[AsyncBankAccountsClient] = None + self._bookings: typing.Optional[AsyncBookingsClient] = None + self._cards: typing.Optional[AsyncCardsClient] = None + self._catalog: typing.Optional[AsyncCatalogClient] = None + self._channels: typing.Optional[AsyncChannelsClient] = None + self._customers: typing.Optional[AsyncCustomersClient] = None + self._devices: typing.Optional[AsyncDevicesClient] = None + self._disputes: typing.Optional[AsyncDisputesClient] = None + self._employees: typing.Optional[AsyncEmployeesClient] = None + self._events: typing.Optional[AsyncEventsClient] = None + self._gift_cards: typing.Optional[AsyncGiftCardsClient] = None + self._inventory: typing.Optional[AsyncInventoryClient] = None + self._invoices: typing.Optional[AsyncInvoicesClient] = None + self._labor: typing.Optional[AsyncLaborClient] = None + self._locations: typing.Optional[AsyncLocationsClient] = None + self._loyalty: typing.Optional[AsyncLoyaltyClient] = None + self._merchants: typing.Optional[AsyncMerchantsClient] = None + self._checkout: typing.Optional[AsyncCheckoutClient] = None + self._orders: typing.Optional[AsyncOrdersClient] = None + self._payments: typing.Optional[AsyncPaymentsClient] = None + self._payouts: typing.Optional[AsyncPayoutsClient] = None + self._refunds: typing.Optional[AsyncRefundsClient] = None + self._sites: typing.Optional[AsyncSitesClient] = None + self._snippets: typing.Optional[AsyncSnippetsClient] = None + self._subscriptions: typing.Optional[AsyncSubscriptionsClient] = None + self._team_members: typing.Optional[AsyncTeamMembersClient] = None + self._team: typing.Optional[AsyncTeamClient] = None + self._terminal: typing.Optional[AsyncTerminalClient] = None + self._transfer_orders: typing.Optional[AsyncTransferOrdersClient] = None + self._vendors: typing.Optional[AsyncVendorsClient] = None + self._cash_drawers: typing.Optional[AsyncCashDrawersClient] = None + self._webhooks: typing.Optional[AsyncWebhooksClient] = None + + @property + def mobile(self): + if self._mobile is None: + from .mobile.client import AsyncMobileClient # noqa: E402 + + self._mobile = AsyncMobileClient(client_wrapper=self._client_wrapper) + return self._mobile + + @property + def o_auth(self): + if self._o_auth is None: + from .o_auth.client import AsyncOAuthClient # noqa: E402 + + self._o_auth = AsyncOAuthClient(client_wrapper=self._client_wrapper) + return self._o_auth + + @property + def v1transactions(self): + if self._v1transactions is None: + from .v1transactions.client import AsyncV1TransactionsClient # noqa: E402 + + self._v1transactions = AsyncV1TransactionsClient(client_wrapper=self._client_wrapper) + return self._v1transactions + + @property + def apple_pay(self): + if self._apple_pay is None: + from .apple_pay.client import AsyncApplePayClient # noqa: E402 + + self._apple_pay = AsyncApplePayClient(client_wrapper=self._client_wrapper) + return self._apple_pay + + @property + def bank_accounts(self): + if self._bank_accounts is None: + from .bank_accounts.client import AsyncBankAccountsClient # noqa: E402 + + self._bank_accounts = AsyncBankAccountsClient(client_wrapper=self._client_wrapper) + return self._bank_accounts + + @property + def bookings(self): + if self._bookings is None: + from .bookings.client import AsyncBookingsClient # noqa: E402 + + self._bookings = AsyncBookingsClient(client_wrapper=self._client_wrapper) + return self._bookings + + @property + def cards(self): + if self._cards is None: + from .cards.client import AsyncCardsClient # noqa: E402 + + self._cards = AsyncCardsClient(client_wrapper=self._client_wrapper) + return self._cards + + @property + def catalog(self): + if self._catalog is None: + from .catalog.client import AsyncCatalogClient # noqa: E402 + + self._catalog = AsyncCatalogClient(client_wrapper=self._client_wrapper) + return self._catalog + + @property + def channels(self): + if self._channels is None: + from .channels.client import AsyncChannelsClient # noqa: E402 + + self._channels = AsyncChannelsClient(client_wrapper=self._client_wrapper) + return self._channels + + @property + def customers(self): + if self._customers is None: + from .customers.client import AsyncCustomersClient # noqa: E402 + + self._customers = AsyncCustomersClient(client_wrapper=self._client_wrapper) + return self._customers + + @property + def devices(self): + if self._devices is None: + from .devices.client import AsyncDevicesClient # noqa: E402 + + self._devices = AsyncDevicesClient(client_wrapper=self._client_wrapper) + return self._devices + + @property + def disputes(self): + if self._disputes is None: + from .disputes.client import AsyncDisputesClient # noqa: E402 + + self._disputes = AsyncDisputesClient(client_wrapper=self._client_wrapper) + return self._disputes + + @property + def employees(self): + if self._employees is None: + from .employees.client import AsyncEmployeesClient # noqa: E402 + + self._employees = AsyncEmployeesClient(client_wrapper=self._client_wrapper) + return self._employees + + @property + def events(self): + if self._events is None: + from .events.client import AsyncEventsClient # noqa: E402 + + self._events = AsyncEventsClient(client_wrapper=self._client_wrapper) + return self._events + + @property + def gift_cards(self): + if self._gift_cards is None: + from .gift_cards.client import AsyncGiftCardsClient # noqa: E402 + + self._gift_cards = AsyncGiftCardsClient(client_wrapper=self._client_wrapper) + return self._gift_cards + + @property + def inventory(self): + if self._inventory is None: + from .inventory.client import AsyncInventoryClient # noqa: E402 + + self._inventory = AsyncInventoryClient(client_wrapper=self._client_wrapper) + return self._inventory + + @property + def invoices(self): + if self._invoices is None: + from .invoices.client import AsyncInvoicesClient # noqa: E402 + + self._invoices = AsyncInvoicesClient(client_wrapper=self._client_wrapper) + return self._invoices + + @property + def labor(self): + if self._labor is None: + from .labor.client import AsyncLaborClient # noqa: E402 + + self._labor = AsyncLaborClient(client_wrapper=self._client_wrapper) + return self._labor + + @property + def locations(self): + if self._locations is None: + from .locations.client import AsyncLocationsClient # noqa: E402 + + self._locations = AsyncLocationsClient(client_wrapper=self._client_wrapper) + return self._locations + + @property + def loyalty(self): + if self._loyalty is None: + from .loyalty.client import AsyncLoyaltyClient # noqa: E402 + + self._loyalty = AsyncLoyaltyClient(client_wrapper=self._client_wrapper) + return self._loyalty + + @property + def merchants(self): + if self._merchants is None: + from .merchants.client import AsyncMerchantsClient # noqa: E402 + + self._merchants = AsyncMerchantsClient(client_wrapper=self._client_wrapper) + return self._merchants + + @property + def checkout(self): + if self._checkout is None: + from .checkout.client import AsyncCheckoutClient # noqa: E402 + + self._checkout = AsyncCheckoutClient(client_wrapper=self._client_wrapper) + return self._checkout + + @property + def orders(self): + if self._orders is None: + from .orders.client import AsyncOrdersClient # noqa: E402 + + self._orders = AsyncOrdersClient(client_wrapper=self._client_wrapper) + return self._orders + + @property + def payments(self): + if self._payments is None: + from .payments.client import AsyncPaymentsClient # noqa: E402 + + self._payments = AsyncPaymentsClient(client_wrapper=self._client_wrapper) + return self._payments + + @property + def payouts(self): + if self._payouts is None: + from .payouts.client import AsyncPayoutsClient # noqa: E402 + + self._payouts = AsyncPayoutsClient(client_wrapper=self._client_wrapper) + return self._payouts + + @property + def refunds(self): + if self._refunds is None: + from .refunds.client import AsyncRefundsClient # noqa: E402 + + self._refunds = AsyncRefundsClient(client_wrapper=self._client_wrapper) + return self._refunds + + @property + def sites(self): + if self._sites is None: + from .sites.client import AsyncSitesClient # noqa: E402 + + self._sites = AsyncSitesClient(client_wrapper=self._client_wrapper) + return self._sites + + @property + def snippets(self): + if self._snippets is None: + from .snippets.client import AsyncSnippetsClient # noqa: E402 + + self._snippets = AsyncSnippetsClient(client_wrapper=self._client_wrapper) + return self._snippets + + @property + def subscriptions(self): + if self._subscriptions is None: + from .subscriptions.client import AsyncSubscriptionsClient # noqa: E402 + + self._subscriptions = AsyncSubscriptionsClient(client_wrapper=self._client_wrapper) + return self._subscriptions + + @property + def team_members(self): + if self._team_members is None: + from .team_members.client import AsyncTeamMembersClient # noqa: E402 + + self._team_members = AsyncTeamMembersClient(client_wrapper=self._client_wrapper) + return self._team_members + + @property + def team(self): + if self._team is None: + from .team.client import AsyncTeamClient # noqa: E402 + + self._team = AsyncTeamClient(client_wrapper=self._client_wrapper) + return self._team + + @property + def terminal(self): + if self._terminal is None: + from .terminal.client import AsyncTerminalClient # noqa: E402 + + self._terminal = AsyncTerminalClient(client_wrapper=self._client_wrapper) + return self._terminal + + @property + def transfer_orders(self): + if self._transfer_orders is None: + from .transfer_orders.client import AsyncTransferOrdersClient # noqa: E402 + + self._transfer_orders = AsyncTransferOrdersClient(client_wrapper=self._client_wrapper) + return self._transfer_orders + + @property + def vendors(self): + if self._vendors is None: + from .vendors.client import AsyncVendorsClient # noqa: E402 + + self._vendors = AsyncVendorsClient(client_wrapper=self._client_wrapper) + return self._vendors + + @property + def cash_drawers(self): + if self._cash_drawers is None: + from .cash_drawers.client import AsyncCashDrawersClient # noqa: E402 + + self._cash_drawers = AsyncCashDrawersClient(client_wrapper=self._client_wrapper) + return self._cash_drawers + + @property + def webhooks(self): + if self._webhooks is None: + from .webhooks.client import AsyncWebhooksClient # noqa: E402 + + self._webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper) + return self._webhooks def _get_base_url(*, base_url: typing.Optional[str] = None, environment: SquareEnvironment) -> str: diff --git a/src/square/core/__init__.py b/src/square/core/__init__.py index 73955ba0..0fb6a372 100644 --- a/src/square/core/__init__.py +++ b/src/square/core/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from .file import File, with_content_type +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from .file import File, with_content_type +_dynamic_imports: typing.Dict[str, str] = {"File": ".file", "with_content_type": ".file"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["File", "with_content_type"] diff --git a/src/square/core/client_wrapper.py b/src/square/core/client_wrapper.py index 546da046..bc088c7e 100644 --- a/src/square/core/client_wrapper.py +++ b/src/square/core/client_wrapper.py @@ -24,16 +24,16 @@ def __init__( def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { - "User-Agent": "squareup/43.1.2.20250924", + "User-Agent": "squareup/43.2.0.20251016", "X-Fern-Language": "Python", "X-Fern-SDK-Name": "squareup", - "X-Fern-SDK-Version": "43.1.2.20250924", + "X-Fern-SDK-Version": "43.2.0.20251016", **(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 "2025-09-24" + headers["Square-Version"] = self._version if self._version is not None else "2025-10-16" return headers def _get_token(self) -> typing.Optional[str]: diff --git a/src/square/core/force_multipart.py b/src/square/core/force_multipart.py index ae24ccff..5440913f 100644 --- a/src/square/core/force_multipart.py +++ b/src/square/core/force_multipart.py @@ -1,7 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from typing import Any, Dict -class ForceMultipartDict(dict): + +class ForceMultipartDict(Dict[str, Any]): """ A dictionary subclass that always evaluates to True in boolean contexts. @@ -9,7 +11,7 @@ class ForceMultipartDict(dict): the dictionary is empty, which would normally evaluate to False. """ - def __bool__(self): + def __bool__(self) -> bool: return True diff --git a/src/square/core/http_response.py b/src/square/core/http_response.py index 48a1798a..2479747e 100644 --- a/src/square/core/http_response.py +++ b/src/square/core/http_response.py @@ -4,8 +4,8 @@ import httpx +# Generic to represent the underlying type of the data wrapped by the HTTP response. T = TypeVar("T") -"""Generic to represent the underlying type of the data wrapped by the HTTP response.""" class BaseHttpResponse: diff --git a/src/square/core/pagination.py b/src/square/core/pagination.py index 209a1ff1..97bcb645 100644 --- a/src/square/core/pagination.py +++ b/src/square/core/pagination.py @@ -7,8 +7,8 @@ from .http_response import BaseHttpResponse +# Generic to represent the underlying type of the results within a page T = TypeVar("T") -"""Generic to represent the underlying type of the results within a page""" # SDKs implement a Page ABC per-pagination request, the endpoint then returns a pager that wraps this type diff --git a/src/square/core/pydantic_utilities.py b/src/square/core/pydantic_utilities.py index 7db29500..8906cdfa 100644 --- a/src/square/core/pydantic_utilities.py +++ b/src/square/core/pydantic_utilities.py @@ -61,7 +61,7 @@ class UniversalBaseModel(pydantic.BaseModel): @pydantic.model_serializer(mode="plain", when_used="json") # type: ignore[attr-defined] def serialize_model(self) -> Any: # type: ignore[name-defined] - serialized = self.model_dump() + serialized = self.dict() # type: ignore[attr-defined] data = {k: serialize_datetime(v) if isinstance(v, dt.datetime) else v for k, v in serialized.items()} return data @@ -147,7 +147,10 @@ def dict(self, **kwargs: Any) -> Dict[str, Any]: dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return cast( + Dict[str, Any], + convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write"), + ) def _union_list_of_pydantic_dicts(source: List[Any], destination: List[Any]) -> List[Any]: diff --git a/src/square/core/unchecked_base_model.py b/src/square/core/unchecked_base_model.py index e04a6f81..ae59845f 100644 --- a/src/square/core/unchecked_base_model.py +++ b/src/square/core/unchecked_base_model.py @@ -186,7 +186,7 @@ def _convert_undiscriminated_union_type(union_type: typing.Type[typing.Any], obj def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: base_type = get_origin(type_) or type_ union_type = type_ - if base_type == typing_extensions.Annotated: + if base_type == typing_extensions.Annotated: # type: ignore[comparison-overlap] union_type = get_args(type_)[0] annotated_metadata = get_args(type_)[1:] for metadata in annotated_metadata: @@ -217,11 +217,11 @@ def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> ty return None base_type = get_origin(type_) or type_ - is_annotated = base_type == typing_extensions.Annotated + is_annotated = base_type == typing_extensions.Annotated # type: ignore[comparison-overlap] maybe_annotation_members = get_args(type_) is_annotated_union = is_annotated and is_union(get_origin(maybe_annotation_members[0])) - if base_type == typing.Any: + if base_type == typing.Any: # type: ignore[comparison-overlap] return object_ if base_type == dict: diff --git a/src/square/customers/__init__.py b/src/square/customers/__init__.py index 322c5dab..90daab04 100644 --- a/src/square/customers/__init__.py +++ b/src/square/customers/__init__.py @@ -2,6 +2,39 @@ # isort: skip_file -from . import cards, custom_attribute_definitions, custom_attributes, groups, segments +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import cards, custom_attribute_definitions, custom_attributes, groups, segments +_dynamic_imports: typing.Dict[str, str] = { + "cards": ".cards", + "custom_attribute_definitions": ".custom_attribute_definitions", + "custom_attributes": ".custom_attributes", + "groups": ".groups", + "segments": ".segments", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["cards", "custom_attribute_definitions", "custom_attributes", "groups", "segments"] diff --git a/src/square/customers/client.py b/src/square/customers/client.py index 3dd78b43..a4f268c0 100644 --- a/src/square/customers/client.py +++ b/src/square/customers/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -22,13 +24,17 @@ from ..types.search_customers_response import SearchCustomersResponse from ..types.sort_order import SortOrder from ..types.update_customer_response import UpdateCustomerResponse -from .cards.client import AsyncCardsClient, CardsClient -from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient, CustomAttributeDefinitionsClient -from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient -from .groups.client import AsyncGroupsClient, GroupsClient from .raw_client import AsyncRawCustomersClient, RawCustomersClient -from .segments.client import AsyncSegmentsClient, SegmentsClient +if typing.TYPE_CHECKING: + from .cards.client import AsyncCardsClient, CardsClient + from .custom_attribute_definitions.client import ( + AsyncCustomAttributeDefinitionsClient, + CustomAttributeDefinitionsClient, + ) + from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient + from .groups.client import AsyncGroupsClient, GroupsClient + from .segments.client import AsyncSegmentsClient, SegmentsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -36,15 +42,12 @@ class CustomersClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawCustomersClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=client_wrapper) - - self.groups = GroupsClient(client_wrapper=client_wrapper) - - self.segments = SegmentsClient(client_wrapper=client_wrapper) - - self.cards = CardsClient(client_wrapper=client_wrapper) - - self.custom_attributes = CustomAttributesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[CustomAttributeDefinitionsClient] = None + self._groups: typing.Optional[GroupsClient] = None + self._segments: typing.Optional[SegmentsClient] = None + self._cards: typing.Optional[CardsClient] = None + self._custom_attributes: typing.Optional[CustomAttributesClient] = None @property def with_raw_response(self) -> RawCustomersClient: @@ -119,7 +122,13 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.customers.list() + response = client.customers.list( + cursor="cursor", + limit=1, + sort_field="DEFAULT", + sort_order="DESC", + count=True, + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -769,24 +778,62 @@ def delete( ) client.customers.delete( customer_id="customer_id", + version=1000000, ) """ _response = self._raw_client.delete(customer_id, version=version, request_options=request_options) return _response.data + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import CustomAttributeDefinitionsClient # noqa: E402 -class AsyncCustomersClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._raw_client = AsyncRawCustomersClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient(client_wrapper=client_wrapper) + self._custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=self._client_wrapper) + return self._custom_attribute_definitions - self.groups = AsyncGroupsClient(client_wrapper=client_wrapper) + @property + def groups(self): + if self._groups is None: + from .groups.client import GroupsClient # noqa: E402 + + self._groups = GroupsClient(client_wrapper=self._client_wrapper) + return self._groups + + @property + def segments(self): + if self._segments is None: + from .segments.client import SegmentsClient # noqa: E402 + + self._segments = SegmentsClient(client_wrapper=self._client_wrapper) + return self._segments + + @property + def cards(self): + if self._cards is None: + from .cards.client import CardsClient # noqa: E402 + + self._cards = CardsClient(client_wrapper=self._client_wrapper) + return self._cards + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import CustomAttributesClient # noqa: E402 - self.segments = AsyncSegmentsClient(client_wrapper=client_wrapper) + self._custom_attributes = CustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes - self.cards = AsyncCardsClient(client_wrapper=client_wrapper) - self.custom_attributes = AsyncCustomAttributesClient(client_wrapper=client_wrapper) +class AsyncCustomersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawCustomersClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[AsyncCustomAttributeDefinitionsClient] = None + self._groups: typing.Optional[AsyncGroupsClient] = None + self._segments: typing.Optional[AsyncSegmentsClient] = None + self._cards: typing.Optional[AsyncCardsClient] = None + self._custom_attributes: typing.Optional[AsyncCustomAttributesClient] = None @property def with_raw_response(self) -> AsyncRawCustomersClient: @@ -866,7 +913,13 @@ async def list( async def main() -> None: - response = await client.customers.list() + response = await client.customers.list( + cursor="cursor", + limit=1, + sort_field="DEFAULT", + sort_order="DESC", + count=True, + ) async for item in response: yield item @@ -1598,6 +1651,7 @@ async def delete( async def main() -> None: await client.customers.delete( customer_id="customer_id", + version=1000000, ) @@ -1605,3 +1659,45 @@ async def main() -> None: """ _response = await self._raw_client.delete(customer_id, version=version, request_options=request_options) return _response.data + + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient # noqa: E402 + + self._custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient( + client_wrapper=self._client_wrapper + ) + return self._custom_attribute_definitions + + @property + def groups(self): + if self._groups is None: + from .groups.client import AsyncGroupsClient # noqa: E402 + + self._groups = AsyncGroupsClient(client_wrapper=self._client_wrapper) + return self._groups + + @property + def segments(self): + if self._segments is None: + from .segments.client import AsyncSegmentsClient # noqa: E402 + + self._segments = AsyncSegmentsClient(client_wrapper=self._client_wrapper) + return self._segments + + @property + def cards(self): + if self._cards is None: + from .cards.client import AsyncCardsClient # noqa: E402 + + self._cards = AsyncCardsClient(client_wrapper=self._client_wrapper) + return self._cards + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import AsyncCustomAttributesClient # noqa: E402 + + self._custom_attributes = AsyncCustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes diff --git a/src/square/customers/custom_attribute_definitions/client.py b/src/square/customers/custom_attribute_definitions/client.py index c0a66ac6..0e738370 100644 --- a/src/square/customers/custom_attribute_definitions/client.py +++ b/src/square/customers/custom_attribute_definitions/client.py @@ -84,7 +84,10 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.customers.custom_attribute_definitions.list() + response = client.customers.custom_attribute_definitions.list( + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -200,6 +203,7 @@ def get( ) client.customers.custom_attribute_definitions.get( key="key", + version=1, ) """ _response = self._raw_client.get(key, version=version, request_options=request_options) @@ -458,7 +462,10 @@ async def list( async def main() -> None: - response = await client.customers.custom_attribute_definitions.list() + response = await client.customers.custom_attribute_definitions.list( + limit=1, + cursor="cursor", + ) async for item in response: yield item @@ -591,6 +598,7 @@ async def get( async def main() -> None: await client.customers.custom_attribute_definitions.get( key="key", + version=1, ) diff --git a/src/square/customers/custom_attributes/client.py b/src/square/customers/custom_attributes/client.py index 2415370c..d6984d0c 100644 --- a/src/square/customers/custom_attributes/client.py +++ b/src/square/customers/custom_attributes/client.py @@ -87,6 +87,9 @@ def list( ) response = client.customers.custom_attributes.list( customer_id="customer_id", + limit=1, + cursor="cursor", + with_definitions=True, ) for item in response: yield item @@ -156,6 +159,8 @@ def get( client.customers.custom_attributes.get( customer_id="customer_id", key="key", + with_definition=True, + version=1, ) """ _response = self._raw_client.get( @@ -357,6 +362,9 @@ async def list( async def main() -> None: response = await client.customers.custom_attributes.list( customer_id="customer_id", + limit=1, + cursor="cursor", + with_definitions=True, ) async for item in response: yield item @@ -435,6 +443,8 @@ async def main() -> None: await client.customers.custom_attributes.get( customer_id="customer_id", key="key", + with_definition=True, + version=1, ) diff --git a/src/square/customers/groups/client.py b/src/square/customers/groups/client.py index a7bb0b1b..8418c51b 100644 --- a/src/square/customers/groups/client.py +++ b/src/square/customers/groups/client.py @@ -73,7 +73,10 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.customers.groups.list() + response = client.customers.groups.list( + cursor="cursor", + limit=1, + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -369,7 +372,10 @@ async def list( async def main() -> None: - response = await client.customers.groups.list() + response = await client.customers.groups.list( + cursor="cursor", + limit=1, + ) async for item in response: yield item diff --git a/src/square/customers/segments/client.py b/src/square/customers/segments/client.py index acce7325..d0925abe 100644 --- a/src/square/customers/segments/client.py +++ b/src/square/customers/segments/client.py @@ -64,7 +64,10 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.customers.segments.list() + response = client.customers.segments.list( + cursor="cursor", + limit=1, + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -166,7 +169,10 @@ async def list( async def main() -> None: - response = await client.customers.segments.list() + response = await client.customers.segments.list( + cursor="cursor", + limit=1, + ) async for item in response: yield item diff --git a/src/square/devices/__init__.py b/src/square/devices/__init__.py index 36507dfe..bc1c2328 100644 --- a/src/square/devices/__init__.py +++ b/src/square/devices/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import codes +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import codes +_dynamic_imports: typing.Dict[str, str] = {"codes": ".codes"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["codes"] diff --git a/src/square/devices/client.py b/src/square/devices/client.py index f9c8fbbc..f739356b 100644 --- a/src/square/devices/client.py +++ b/src/square/devices/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -8,14 +10,17 @@ from ..types.device import Device from ..types.get_device_response import GetDeviceResponse from ..types.sort_order import SortOrder -from .codes.client import AsyncCodesClient, CodesClient from .raw_client import AsyncRawDevicesClient, RawDevicesClient +if typing.TYPE_CHECKING: + from .codes.client import AsyncCodesClient, CodesClient + class DevicesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawDevicesClient(client_wrapper=client_wrapper) - self.codes = CodesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._codes: typing.Optional[CodesClient] = None @property def with_raw_response(self) -> RawDevicesClient: @@ -74,7 +79,12 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.devices.list() + response = client.devices.list( + cursor="cursor", + sort_order="DESC", + limit=1, + location_id="location_id", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -116,11 +126,20 @@ def get(self, device_id: str, *, request_options: typing.Optional[RequestOptions _response = self._raw_client.get(device_id, request_options=request_options) return _response.data + @property + def codes(self): + if self._codes is None: + from .codes.client import CodesClient # noqa: E402 + + self._codes = CodesClient(client_wrapper=self._client_wrapper) + return self._codes + class AsyncDevicesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawDevicesClient(client_wrapper=client_wrapper) - self.codes = AsyncCodesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._codes: typing.Optional[AsyncCodesClient] = None @property def with_raw_response(self) -> AsyncRawDevicesClient: @@ -184,7 +203,12 @@ async def list( async def main() -> None: - response = await client.devices.list() + response = await client.devices.list( + cursor="cursor", + sort_order="DESC", + limit=1, + location_id="location_id", + ) async for item in response: yield item @@ -239,3 +263,11 @@ async def main() -> None: """ _response = await self._raw_client.get(device_id, request_options=request_options) return _response.data + + @property + def codes(self): + if self._codes is None: + from .codes.client import AsyncCodesClient # noqa: E402 + + self._codes = AsyncCodesClient(client_wrapper=self._client_wrapper) + return self._codes diff --git a/src/square/devices/codes/client.py b/src/square/devices/codes/client.py index 5c8330aa..456e6f93 100644 --- a/src/square/devices/codes/client.py +++ b/src/square/devices/codes/client.py @@ -79,7 +79,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.devices.codes.list() + response = client.devices.codes.list( + cursor="cursor", + location_id="location_id", + status="UNKNOWN", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -244,7 +248,11 @@ async def list( async def main() -> None: - response = await client.devices.codes.list() + response = await client.devices.codes.list( + cursor="cursor", + location_id="location_id", + status="UNKNOWN", + ) async for item in response: yield item diff --git a/src/square/disputes/__init__.py b/src/square/disputes/__init__.py index 692013d1..94331272 100644 --- a/src/square/disputes/__init__.py +++ b/src/square/disputes/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import evidence +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import evidence +_dynamic_imports: typing.Dict[str, str] = {"evidence": ".evidence"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["evidence"] diff --git a/src/square/disputes/client.py b/src/square/disputes/client.py index c0c568cc..040fd04d 100644 --- a/src/square/disputes/client.py +++ b/src/square/disputes/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from .. import core @@ -15,9 +17,10 @@ from ..types.dispute_state import DisputeState from ..types.get_dispute_response import GetDisputeResponse from ..types.submit_evidence_response import SubmitEvidenceResponse -from .evidence.client import AsyncEvidenceClient, EvidenceClient from .raw_client import AsyncRawDisputesClient, RawDisputesClient +if typing.TYPE_CHECKING: + from .evidence.client import AsyncEvidenceClient, EvidenceClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -25,7 +28,8 @@ class DisputesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawDisputesClient(client_wrapper=client_wrapper) - self.evidence = EvidenceClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._evidence: typing.Optional[EvidenceClient] = None @property def with_raw_response(self) -> RawDisputesClient: @@ -78,7 +82,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.disputes.list() + response = client.disputes.list( + cursor="cursor", + states="INQUIRY_EVIDENCE_REQUIRED", + location_id="location_id", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -300,11 +308,20 @@ def submit_evidence( _response = self._raw_client.submit_evidence(dispute_id, request_options=request_options) return _response.data + @property + def evidence(self): + if self._evidence is None: + from .evidence.client import EvidenceClient # noqa: E402 + + self._evidence = EvidenceClient(client_wrapper=self._client_wrapper) + return self._evidence + class AsyncDisputesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawDisputesClient(client_wrapper=client_wrapper) - self.evidence = AsyncEvidenceClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._evidence: typing.Optional[AsyncEvidenceClient] = None @property def with_raw_response(self) -> AsyncRawDisputesClient: @@ -362,7 +379,11 @@ async def list( async def main() -> None: - response = await client.disputes.list() + response = await client.disputes.list( + cursor="cursor", + states="INQUIRY_EVIDENCE_REQUIRED", + location_id="location_id", + ) async for item in response: yield item @@ -629,3 +650,11 @@ async def main() -> None: """ _response = await self._raw_client.submit_evidence(dispute_id, request_options=request_options) return _response.data + + @property + def evidence(self): + if self._evidence is None: + from .evidence.client import AsyncEvidenceClient # noqa: E402 + + self._evidence = AsyncEvidenceClient(client_wrapper=self._client_wrapper) + return self._evidence diff --git a/src/square/disputes/evidence/client.py b/src/square/disputes/evidence/client.py index d53d0be8..a0ada53b 100644 --- a/src/square/disputes/evidence/client.py +++ b/src/square/disputes/evidence/client.py @@ -63,6 +63,7 @@ def list( ) response = client.disputes.evidence.list( dispute_id="dispute_id", + cursor="cursor", ) for item in response: yield item @@ -207,6 +208,7 @@ async def list( async def main() -> None: response = await client.disputes.evidence.list( dispute_id="dispute_id", + cursor="cursor", ) async for item in response: yield item diff --git a/src/square/employees/client.py b/src/square/employees/client.py index 240e1f55..aa0cee9f 100644 --- a/src/square/employees/client.py +++ b/src/square/employees/client.py @@ -67,7 +67,12 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.employees.list() + response = client.employees.list( + location_id="location_id", + status="ACTIVE", + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -171,7 +176,12 @@ async def list( async def main() -> None: - response = await client.employees.list() + response = await client.employees.list( + location_id="location_id", + status="ACTIVE", + limit=1, + cursor="cursor", + ) async for item in response: yield item diff --git a/src/square/events/client.py b/src/square/events/client.py index 7e62ca68..0b33e0fa 100644 --- a/src/square/events/client.py +++ b/src/square/events/client.py @@ -160,7 +160,9 @@ def list_event_types( client = Square( token="YOUR_TOKEN", ) - client.events.list_event_types() + client.events.list_event_types( + api_version="api_version", + ) """ _response = self._raw_client.list_event_types(api_version=api_version, request_options=request_options) return _response.data @@ -340,7 +342,9 @@ async def list_event_types( async def main() -> None: - await client.events.list_event_types() + await client.events.list_event_types( + api_version="api_version", + ) asyncio.run(main()) diff --git a/src/square/gift_cards/__init__.py b/src/square/gift_cards/__init__.py index a28b6533..6d7e0218 100644 --- a/src/square/gift_cards/__init__.py +++ b/src/square/gift_cards/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import activities +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import activities +_dynamic_imports: typing.Dict[str, str] = {"activities": ".activities"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["activities"] diff --git a/src/square/gift_cards/activities/client.py b/src/square/gift_cards/activities/client.py index 93c38f9c..922ff563 100644 --- a/src/square/gift_cards/activities/client.py +++ b/src/square/gift_cards/activities/client.py @@ -102,7 +102,16 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.gift_cards.activities.list() + response = client.gift_cards.activities.list( + gift_card_id="gift_card_id", + type="type", + location_id="location_id", + begin_time="begin_time", + end_time="end_time", + limit=1, + cursor="cursor", + sort_order="sort_order", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -268,7 +277,16 @@ async def list( async def main() -> None: - response = await client.gift_cards.activities.list() + response = await client.gift_cards.activities.list( + gift_card_id="gift_card_id", + type="type", + location_id="location_id", + begin_time="begin_time", + end_time="end_time", + limit=1, + cursor="cursor", + sort_order="sort_order", + ) async for item in response: yield item diff --git a/src/square/gift_cards/client.py b/src/square/gift_cards/client.py index 938dc642..0129152c 100644 --- a/src/square/gift_cards/client.py +++ b/src/square/gift_cards/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -13,9 +15,10 @@ from ..types.gift_card import GiftCard from ..types.link_customer_to_gift_card_response import LinkCustomerToGiftCardResponse from ..types.unlink_customer_from_gift_card_response import UnlinkCustomerFromGiftCardResponse -from .activities.client import ActivitiesClient, AsyncActivitiesClient from .raw_client import AsyncRawGiftCardsClient, RawGiftCardsClient +if typing.TYPE_CHECKING: + from .activities.client import ActivitiesClient, AsyncActivitiesClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -23,7 +26,8 @@ class GiftCardsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawGiftCardsClient(client_wrapper=client_wrapper) - self.activities = ActivitiesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._activities: typing.Optional[ActivitiesClient] = None @property def with_raw_response(self) -> RawGiftCardsClient: @@ -89,7 +93,13 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.gift_cards.list() + response = client.gift_cards.list( + type="type", + state="state", + limit=1, + cursor="cursor", + customer_id="customer_id", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -350,11 +360,20 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non _response = self._raw_client.get(id, request_options=request_options) return _response.data + @property + def activities(self): + if self._activities is None: + from .activities.client import ActivitiesClient # noqa: E402 + + self._activities = ActivitiesClient(client_wrapper=self._client_wrapper) + return self._activities + class AsyncGiftCardsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawGiftCardsClient(client_wrapper=client_wrapper) - self.activities = AsyncActivitiesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._activities: typing.Optional[AsyncActivitiesClient] = None @property def with_raw_response(self) -> AsyncRawGiftCardsClient: @@ -425,7 +444,13 @@ async def list( async def main() -> None: - response = await client.gift_cards.list() + response = await client.gift_cards.list( + type="type", + state="state", + limit=1, + cursor="cursor", + customer_id="customer_id", + ) async for item in response: yield item @@ -737,3 +762,11 @@ async def main() -> None: """ _response = await self._raw_client.get(id, request_options=request_options) return _response.data + + @property + def activities(self): + if self._activities is None: + from .activities.client import AsyncActivitiesClient # noqa: E402 + + self._activities = AsyncActivitiesClient(client_wrapper=self._client_wrapper) + return self._activities diff --git a/src/square/inventory/client.py b/src/square/inventory/client.py index cc3c4c23..ade24214 100644 --- a/src/square/inventory/client.py +++ b/src/square/inventory/client.py @@ -763,6 +763,8 @@ def get( ) response = client.inventory.get( catalog_object_id="catalog_object_id", + location_ids="location_ids", + cursor="cursor", ) for item in response: yield item @@ -829,6 +831,8 @@ def changes( ) response = client.inventory.changes( catalog_object_id="catalog_object_id", + location_ids="location_ids", + cursor="cursor", ) for item in response: yield item @@ -1679,6 +1683,8 @@ async def get( async def main() -> None: response = await client.inventory.get( catalog_object_id="catalog_object_id", + location_ids="location_ids", + cursor="cursor", ) async for item in response: yield item @@ -1754,6 +1760,8 @@ async def changes( async def main() -> None: response = await client.inventory.changes( catalog_object_id="catalog_object_id", + location_ids="location_ids", + cursor="cursor", ) async for item in response: yield item diff --git a/src/square/invoices/client.py b/src/square/invoices/client.py index 464ff172..b62fe981 100644 --- a/src/square/invoices/client.py +++ b/src/square/invoices/client.py @@ -85,6 +85,8 @@ def list( ) response = client.invoices.list( location_id="location_id", + cursor="cursor", + limit=1, ) for item in response: yield item @@ -398,6 +400,7 @@ def delete( ) client.invoices.delete( invoice_id="invoice_id", + version=1, ) """ _response = self._raw_client.delete(invoice_id, version=version, request_options=request_options) @@ -669,6 +672,8 @@ async def list( async def main() -> None: response = await client.invoices.list( location_id="location_id", + cursor="cursor", + limit=1, ) async for item in response: yield item @@ -1027,6 +1032,7 @@ async def delete( async def main() -> None: await client.invoices.delete( invoice_id="invoice_id", + version=1, ) diff --git a/src/square/labor/__init__.py b/src/square/labor/__init__.py index 61ccfc86..b0129977 100644 --- a/src/square/labor/__init__.py +++ b/src/square/labor/__init__.py @@ -2,6 +2,39 @@ # isort: skip_file -from . import break_types, employee_wages, shifts, team_member_wages, workweek_configs +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import break_types, employee_wages, shifts, team_member_wages, workweek_configs +_dynamic_imports: typing.Dict[str, str] = { + "break_types": ".break_types", + "employee_wages": ".employee_wages", + "shifts": ".shifts", + "team_member_wages": ".team_member_wages", + "workweek_configs": ".workweek_configs", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["break_types", "employee_wages", "shifts", "team_member_wages", "workweek_configs"] diff --git a/src/square/labor/break_types/client.py b/src/square/labor/break_types/client.py index a04a8cf3..d803f191 100644 --- a/src/square/labor/break_types/client.py +++ b/src/square/labor/break_types/client.py @@ -71,7 +71,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.labor.break_types.list() + response = client.labor.break_types.list( + location_id="location_id", + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -310,7 +314,11 @@ async def list( async def main() -> None: - response = await client.labor.break_types.list() + response = await client.labor.break_types.list( + location_id="location_id", + limit=1, + cursor="cursor", + ) async for item in response: yield item diff --git a/src/square/labor/client.py b/src/square/labor/client.py index d1e894e6..099ebb40 100644 --- a/src/square/labor/client.py +++ b/src/square/labor/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -21,13 +23,14 @@ from ..types.search_timecards_response import SearchTimecardsResponse from ..types.update_scheduled_shift_response import UpdateScheduledShiftResponse from ..types.update_timecard_response import UpdateTimecardResponse -from .break_types.client import AsyncBreakTypesClient, BreakTypesClient -from .employee_wages.client import AsyncEmployeeWagesClient, EmployeeWagesClient from .raw_client import AsyncRawLaborClient, RawLaborClient -from .shifts.client import AsyncShiftsClient, ShiftsClient -from .team_member_wages.client import AsyncTeamMemberWagesClient, TeamMemberWagesClient -from .workweek_configs.client import AsyncWorkweekConfigsClient, WorkweekConfigsClient +if typing.TYPE_CHECKING: + from .break_types.client import AsyncBreakTypesClient, BreakTypesClient + from .employee_wages.client import AsyncEmployeeWagesClient, EmployeeWagesClient + from .shifts.client import AsyncShiftsClient, ShiftsClient + from .team_member_wages.client import AsyncTeamMemberWagesClient, TeamMemberWagesClient + from .workweek_configs.client import AsyncWorkweekConfigsClient, WorkweekConfigsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -35,15 +38,12 @@ class LaborClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawLaborClient(client_wrapper=client_wrapper) - self.break_types = BreakTypesClient(client_wrapper=client_wrapper) - - self.employee_wages = EmployeeWagesClient(client_wrapper=client_wrapper) - - self.shifts = ShiftsClient(client_wrapper=client_wrapper) - - self.team_member_wages = TeamMemberWagesClient(client_wrapper=client_wrapper) - - self.workweek_configs = WorkweekConfigsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._break_types: typing.Optional[BreakTypesClient] = None + self._employee_wages: typing.Optional[EmployeeWagesClient] = None + self._shifts: typing.Optional[ShiftsClient] = None + self._team_member_wages: typing.Optional[TeamMemberWagesClient] = None + self._workweek_configs: typing.Optional[WorkweekConfigsClient] = None @property def with_raw_response(self) -> RawLaborClient: @@ -688,19 +688,56 @@ def delete_timecard( _response = self._raw_client.delete_timecard(id, request_options=request_options) return _response.data + @property + def break_types(self): + if self._break_types is None: + from .break_types.client import BreakTypesClient # noqa: E402 -class AsyncLaborClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._raw_client = AsyncRawLaborClient(client_wrapper=client_wrapper) - self.break_types = AsyncBreakTypesClient(client_wrapper=client_wrapper) + self._break_types = BreakTypesClient(client_wrapper=self._client_wrapper) + return self._break_types - self.employee_wages = AsyncEmployeeWagesClient(client_wrapper=client_wrapper) + @property + def employee_wages(self): + if self._employee_wages is None: + from .employee_wages.client import EmployeeWagesClient # noqa: E402 - self.shifts = AsyncShiftsClient(client_wrapper=client_wrapper) + self._employee_wages = EmployeeWagesClient(client_wrapper=self._client_wrapper) + return self._employee_wages - self.team_member_wages = AsyncTeamMemberWagesClient(client_wrapper=client_wrapper) + @property + def shifts(self): + if self._shifts is None: + from .shifts.client import ShiftsClient # noqa: E402 - self.workweek_configs = AsyncWorkweekConfigsClient(client_wrapper=client_wrapper) + self._shifts = ShiftsClient(client_wrapper=self._client_wrapper) + return self._shifts + + @property + def team_member_wages(self): + if self._team_member_wages is None: + from .team_member_wages.client import TeamMemberWagesClient # noqa: E402 + + self._team_member_wages = TeamMemberWagesClient(client_wrapper=self._client_wrapper) + return self._team_member_wages + + @property + def workweek_configs(self): + if self._workweek_configs is None: + from .workweek_configs.client import WorkweekConfigsClient # noqa: E402 + + self._workweek_configs = WorkweekConfigsClient(client_wrapper=self._client_wrapper) + return self._workweek_configs + + +class AsyncLaborClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawLaborClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._break_types: typing.Optional[AsyncBreakTypesClient] = None + self._employee_wages: typing.Optional[AsyncEmployeeWagesClient] = None + self._shifts: typing.Optional[AsyncShiftsClient] = None + self._team_member_wages: typing.Optional[AsyncTeamMemberWagesClient] = None + self._workweek_configs: typing.Optional[AsyncWorkweekConfigsClient] = None @property def with_raw_response(self) -> AsyncRawLaborClient: @@ -1432,3 +1469,43 @@ async def main() -> None: """ _response = await self._raw_client.delete_timecard(id, request_options=request_options) return _response.data + + @property + def break_types(self): + if self._break_types is None: + from .break_types.client import AsyncBreakTypesClient # noqa: E402 + + self._break_types = AsyncBreakTypesClient(client_wrapper=self._client_wrapper) + return self._break_types + + @property + def employee_wages(self): + if self._employee_wages is None: + from .employee_wages.client import AsyncEmployeeWagesClient # noqa: E402 + + self._employee_wages = AsyncEmployeeWagesClient(client_wrapper=self._client_wrapper) + return self._employee_wages + + @property + def shifts(self): + if self._shifts is None: + from .shifts.client import AsyncShiftsClient # noqa: E402 + + self._shifts = AsyncShiftsClient(client_wrapper=self._client_wrapper) + return self._shifts + + @property + def team_member_wages(self): + if self._team_member_wages is None: + from .team_member_wages.client import AsyncTeamMemberWagesClient # noqa: E402 + + self._team_member_wages = AsyncTeamMemberWagesClient(client_wrapper=self._client_wrapper) + return self._team_member_wages + + @property + def workweek_configs(self): + if self._workweek_configs is None: + from .workweek_configs.client import AsyncWorkweekConfigsClient # noqa: E402 + + self._workweek_configs = AsyncWorkweekConfigsClient(client_wrapper=self._client_wrapper) + return self._workweek_configs diff --git a/src/square/labor/employee_wages/client.py b/src/square/labor/employee_wages/client.py index 861fd738..38ed7146 100644 --- a/src/square/labor/employee_wages/client.py +++ b/src/square/labor/employee_wages/client.py @@ -63,7 +63,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.labor.employee_wages.list() + response = client.labor.employee_wages.list( + employee_id="employee_id", + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -164,7 +168,11 @@ async def list( async def main() -> None: - response = await client.labor.employee_wages.list() + response = await client.labor.employee_wages.list( + employee_id="employee_id", + limit=1, + cursor="cursor", + ) async for item in response: yield item diff --git a/src/square/labor/team_member_wages/client.py b/src/square/labor/team_member_wages/client.py index 3273add2..d1efb74e 100644 --- a/src/square/labor/team_member_wages/client.py +++ b/src/square/labor/team_member_wages/client.py @@ -64,7 +64,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.labor.team_member_wages.list() + response = client.labor.team_member_wages.list( + team_member_id="team_member_id", + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -166,7 +170,11 @@ async def list( async def main() -> None: - response = await client.labor.team_member_wages.list() + response = await client.labor.team_member_wages.list( + team_member_id="team_member_id", + limit=1, + cursor="cursor", + ) async for item in response: yield item diff --git a/src/square/labor/workweek_configs/client.py b/src/square/labor/workweek_configs/client.py index 98e35abe..3d6825ca 100644 --- a/src/square/labor/workweek_configs/client.py +++ b/src/square/labor/workweek_configs/client.py @@ -62,7 +62,10 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.labor.workweek_configs.list() + response = client.labor.workweek_configs.list( + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -166,7 +169,10 @@ async def list( async def main() -> None: - response = await client.labor.workweek_configs.list() + response = await client.labor.workweek_configs.list( + limit=1, + cursor="cursor", + ) async for item in response: yield item diff --git a/src/square/locations/__init__.py b/src/square/locations/__init__.py index a012fed8..8deb140c 100644 --- a/src/square/locations/__init__.py +++ b/src/square/locations/__init__.py @@ -2,6 +2,37 @@ # isort: skip_file -from . import custom_attribute_definitions, custom_attributes, transactions +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import custom_attribute_definitions, custom_attributes, transactions +_dynamic_imports: typing.Dict[str, str] = { + "custom_attribute_definitions": ".custom_attribute_definitions", + "custom_attributes": ".custom_attributes", + "transactions": ".transactions", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["custom_attribute_definitions", "custom_attributes", "transactions"] diff --git a/src/square/locations/client.py b/src/square/locations/client.py index 3833ca97..b97d01a8 100644 --- a/src/square/locations/client.py +++ b/src/square/locations/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -13,11 +15,15 @@ from ..types.get_location_response import GetLocationResponse from ..types.list_locations_response import ListLocationsResponse from ..types.update_location_response import UpdateLocationResponse -from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient, CustomAttributeDefinitionsClient -from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient from .raw_client import AsyncRawLocationsClient, RawLocationsClient -from .transactions.client import AsyncTransactionsClient, TransactionsClient +if typing.TYPE_CHECKING: + from .custom_attribute_definitions.client import ( + AsyncCustomAttributeDefinitionsClient, + CustomAttributeDefinitionsClient, + ) + from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient + from .transactions.client import AsyncTransactionsClient, TransactionsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -25,11 +31,10 @@ class LocationsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawLocationsClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=client_wrapper) - - self.custom_attributes = CustomAttributesClient(client_wrapper=client_wrapper) - - self.transactions = TransactionsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[CustomAttributeDefinitionsClient] = None + self._custom_attributes: typing.Optional[CustomAttributesClient] = None + self._transactions: typing.Optional[TransactionsClient] = None @property def with_raw_response(self) -> RawLocationsClient: @@ -424,15 +429,38 @@ def checkouts( ) return _response.data + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import CustomAttributeDefinitionsClient # noqa: E402 + + self._custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=self._client_wrapper) + return self._custom_attribute_definitions + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import CustomAttributesClient # noqa: E402 + + self._custom_attributes = CustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes + + @property + def transactions(self): + if self._transactions is None: + from .transactions.client import TransactionsClient # noqa: E402 + + self._transactions = TransactionsClient(client_wrapper=self._client_wrapper) + return self._transactions + class AsyncLocationsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawLocationsClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient(client_wrapper=client_wrapper) - - self.custom_attributes = AsyncCustomAttributesClient(client_wrapper=client_wrapper) - - self.transactions = AsyncTransactionsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[AsyncCustomAttributeDefinitionsClient] = None + self._custom_attributes: typing.Optional[AsyncCustomAttributesClient] = None + self._transactions: typing.Optional[AsyncTransactionsClient] = None @property def with_raw_response(self) -> AsyncRawLocationsClient: @@ -870,3 +898,29 @@ async def main() -> None: request_options=request_options, ) return _response.data + + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient # noqa: E402 + + self._custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient( + client_wrapper=self._client_wrapper + ) + return self._custom_attribute_definitions + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import AsyncCustomAttributesClient # noqa: E402 + + self._custom_attributes = AsyncCustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes + + @property + def transactions(self): + if self._transactions is None: + from .transactions.client import AsyncTransactionsClient # noqa: E402 + + self._transactions = AsyncTransactionsClient(client_wrapper=self._client_wrapper) + return self._transactions diff --git a/src/square/locations/custom_attribute_definitions/client.py b/src/square/locations/custom_attribute_definitions/client.py index fd590c32..b0cd91ec 100644 --- a/src/square/locations/custom_attribute_definitions/client.py +++ b/src/square/locations/custom_attribute_definitions/client.py @@ -85,7 +85,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.locations.custom_attribute_definitions.list() + response = client.locations.custom_attribute_definitions.list( + visibility_filter="ALL", + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -196,6 +200,7 @@ def get( ) client.locations.custom_attribute_definitions.get( key="key", + version=1, ) """ _response = self._raw_client.get(key, version=version, request_options=request_options) @@ -372,7 +377,11 @@ async def list( async def main() -> None: - response = await client.locations.custom_attribute_definitions.list() + response = await client.locations.custom_attribute_definitions.list( + visibility_filter="ALL", + limit=1, + cursor="cursor", + ) async for item in response: yield item @@ -500,6 +509,7 @@ async def get( async def main() -> None: await client.locations.custom_attribute_definitions.get( key="key", + version=1, ) diff --git a/src/square/locations/custom_attributes/client.py b/src/square/locations/custom_attributes/client.py index 5b2fd6bc..0628e070 100644 --- a/src/square/locations/custom_attributes/client.py +++ b/src/square/locations/custom_attributes/client.py @@ -207,6 +207,10 @@ def list( ) response = client.locations.custom_attributes.list( location_id="location_id", + visibility_filter="ALL", + limit=1, + cursor="cursor", + with_definitions=True, ) for item in response: yield item @@ -278,6 +282,8 @@ def get( client.locations.custom_attributes.get( location_id="location_id", key="key", + with_definition=True, + version=1, ) """ _response = self._raw_client.get( @@ -599,6 +605,10 @@ async def list( async def main() -> None: response = await client.locations.custom_attributes.list( location_id="location_id", + visibility_filter="ALL", + limit=1, + cursor="cursor", + with_definitions=True, ) async for item in response: yield item @@ -679,6 +689,8 @@ async def main() -> None: await client.locations.custom_attributes.get( location_id="location_id", key="key", + with_definition=True, + version=1, ) diff --git a/src/square/locations/transactions/client.py b/src/square/locations/transactions/client.py index 32fd8f55..2777b102 100644 --- a/src/square/locations/transactions/client.py +++ b/src/square/locations/transactions/client.py @@ -93,6 +93,10 @@ def list( ) client.locations.transactions.list( location_id="location_id", + begin_time="begin_time", + end_time="end_time", + sort_order="DESC", + cursor="cursor", ) """ _response = self._raw_client.list( @@ -313,6 +317,10 @@ async def list( async def main() -> None: await client.locations.transactions.list( location_id="location_id", + begin_time="begin_time", + end_time="end_time", + sort_order="DESC", + cursor="cursor", ) diff --git a/src/square/loyalty/__init__.py b/src/square/loyalty/__init__.py index 077a4340..e68adcb7 100644 --- a/src/square/loyalty/__init__.py +++ b/src/square/loyalty/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import accounts, programs, rewards +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import accounts, programs, rewards +_dynamic_imports: typing.Dict[str, str] = {"accounts": ".accounts", "programs": ".programs", "rewards": ".rewards"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["accounts", "programs", "rewards"] diff --git a/src/square/loyalty/client.py b/src/square/loyalty/client.py index 45b174da..972ba866 100644 --- a/src/square/loyalty/client.py +++ b/src/square/loyalty/client.py @@ -1,16 +1,19 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions from ..requests.loyalty_event_query import LoyaltyEventQueryParams from ..types.search_loyalty_events_response import SearchLoyaltyEventsResponse -from .accounts.client import AccountsClient, AsyncAccountsClient -from .programs.client import AsyncProgramsClient, ProgramsClient from .raw_client import AsyncRawLoyaltyClient, RawLoyaltyClient -from .rewards.client import AsyncRewardsClient, RewardsClient +if typing.TYPE_CHECKING: + from .accounts.client import AccountsClient, AsyncAccountsClient + from .programs.client import AsyncProgramsClient, ProgramsClient + from .rewards.client import AsyncRewardsClient, RewardsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -18,11 +21,10 @@ class LoyaltyClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawLoyaltyClient(client_wrapper=client_wrapper) - self.accounts = AccountsClient(client_wrapper=client_wrapper) - - self.programs = ProgramsClient(client_wrapper=client_wrapper) - - self.rewards = RewardsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._accounts: typing.Optional[AccountsClient] = None + self._programs: typing.Optional[ProgramsClient] = None + self._rewards: typing.Optional[RewardsClient] = None @property def with_raw_response(self) -> RawLoyaltyClient: @@ -100,15 +102,38 @@ def search_events( ) return _response.data + @property + def accounts(self): + if self._accounts is None: + from .accounts.client import AccountsClient # noqa: E402 + + self._accounts = AccountsClient(client_wrapper=self._client_wrapper) + return self._accounts + + @property + def programs(self): + if self._programs is None: + from .programs.client import ProgramsClient # noqa: E402 + + self._programs = ProgramsClient(client_wrapper=self._client_wrapper) + return self._programs + + @property + def rewards(self): + if self._rewards is None: + from .rewards.client import RewardsClient # noqa: E402 + + self._rewards = RewardsClient(client_wrapper=self._client_wrapper) + return self._rewards + class AsyncLoyaltyClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawLoyaltyClient(client_wrapper=client_wrapper) - self.accounts = AsyncAccountsClient(client_wrapper=client_wrapper) - - self.programs = AsyncProgramsClient(client_wrapper=client_wrapper) - - self.rewards = AsyncRewardsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._accounts: typing.Optional[AsyncAccountsClient] = None + self._programs: typing.Optional[AsyncProgramsClient] = None + self._rewards: typing.Optional[AsyncRewardsClient] = None @property def with_raw_response(self) -> AsyncRawLoyaltyClient: @@ -193,3 +218,27 @@ async def main() -> None: query=query, limit=limit, cursor=cursor, request_options=request_options ) return _response.data + + @property + def accounts(self): + if self._accounts is None: + from .accounts.client import AsyncAccountsClient # noqa: E402 + + self._accounts = AsyncAccountsClient(client_wrapper=self._client_wrapper) + return self._accounts + + @property + def programs(self): + if self._programs is None: + from .programs.client import AsyncProgramsClient # noqa: E402 + + self._programs = AsyncProgramsClient(client_wrapper=self._client_wrapper) + return self._programs + + @property + def rewards(self): + if self._rewards is None: + from .rewards.client import AsyncRewardsClient # noqa: E402 + + self._rewards = AsyncRewardsClient(client_wrapper=self._client_wrapper) + return self._rewards diff --git a/src/square/loyalty/programs/__init__.py b/src/square/loyalty/programs/__init__.py index 18f9eb17..4d547aec 100644 --- a/src/square/loyalty/programs/__init__.py +++ b/src/square/loyalty/programs/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import promotions +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import promotions +_dynamic_imports: typing.Dict[str, str] = {"promotions": ".promotions"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["promotions"] diff --git a/src/square/loyalty/programs/client.py b/src/square/loyalty/programs/client.py index d44698ee..f438bc15 100644 --- a/src/square/loyalty/programs/client.py +++ b/src/square/loyalty/programs/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -8,9 +10,10 @@ from ...types.calculate_loyalty_points_response import CalculateLoyaltyPointsResponse from ...types.get_loyalty_program_response import GetLoyaltyProgramResponse from ...types.list_loyalty_programs_response import ListLoyaltyProgramsResponse -from .promotions.client import AsyncPromotionsClient, PromotionsClient from .raw_client import AsyncRawProgramsClient, RawProgramsClient +if typing.TYPE_CHECKING: + from .promotions.client import AsyncPromotionsClient, PromotionsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -18,7 +21,8 @@ class ProgramsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawProgramsClient(client_wrapper=client_wrapper) - self.promotions = PromotionsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._promotions: typing.Optional[PromotionsClient] = None @property def with_raw_response(self) -> RawProgramsClient: @@ -177,11 +181,20 @@ def calculate( ) return _response.data + @property + def promotions(self): + if self._promotions is None: + from .promotions.client import PromotionsClient # noqa: E402 + + self._promotions = PromotionsClient(client_wrapper=self._client_wrapper) + return self._promotions + class AsyncProgramsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawProgramsClient(client_wrapper=client_wrapper) - self.promotions = AsyncPromotionsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._promotions: typing.Optional[AsyncPromotionsClient] = None @property def with_raw_response(self) -> AsyncRawProgramsClient: @@ -363,3 +376,11 @@ async def main() -> None: request_options=request_options, ) return _response.data + + @property + def promotions(self): + if self._promotions is None: + from .promotions.client import AsyncPromotionsClient # noqa: E402 + + self._promotions = AsyncPromotionsClient(client_wrapper=self._client_wrapper) + return self._promotions diff --git a/src/square/loyalty/programs/promotions/client.py b/src/square/loyalty/programs/promotions/client.py index c6447be7..325137ed 100644 --- a/src/square/loyalty/programs/promotions/client.py +++ b/src/square/loyalty/programs/promotions/client.py @@ -83,6 +83,9 @@ def list( ) response = client.loyalty.programs.promotions.list( program_id="program_id", + status="ACTIVE", + cursor="cursor", + limit=1, ) for item in response: yield item @@ -168,20 +171,20 @@ def create( return _response.data def get( - self, promotion_id: str, program_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, program_id: str, promotion_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> GetLoyaltyPromotionResponse: """ Retrieves a loyalty promotion. Parameters ---------- - promotion_id : str - The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. - program_id : str The ID of the base [loyalty program](entity:LoyaltyProgram). To get the program ID, call [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) using the `main` keyword. + promotion_id : str + The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -198,15 +201,15 @@ def get( token="YOUR_TOKEN", ) client.loyalty.programs.promotions.get( - promotion_id="promotion_id", program_id="program_id", + promotion_id="promotion_id", ) """ - _response = self._raw_client.get(promotion_id, program_id, request_options=request_options) + _response = self._raw_client.get(program_id, promotion_id, request_options=request_options) return _response.data def cancel( - self, promotion_id: str, program_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, program_id: str, promotion_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> CancelLoyaltyPromotionResponse: """ Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE` promotion earlier than the @@ -218,13 +221,13 @@ def cancel( Parameters ---------- + program_id : str + The ID of the base [loyalty program](entity:LoyaltyProgram). + promotion_id : str The ID of the [loyalty promotion](entity:LoyaltyPromotion) to cancel. You can cancel a promotion that has an `ACTIVE` or `SCHEDULED` status. - program_id : str - The ID of the base [loyalty program](entity:LoyaltyProgram). - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -241,11 +244,11 @@ def cancel( token="YOUR_TOKEN", ) client.loyalty.programs.promotions.cancel( - promotion_id="promotion_id", program_id="program_id", + promotion_id="promotion_id", ) """ - _response = self._raw_client.cancel(promotion_id, program_id, request_options=request_options) + _response = self._raw_client.cancel(program_id, promotion_id, request_options=request_options) return _response.data @@ -320,6 +323,9 @@ async def list( async def main() -> None: response = await client.loyalty.programs.promotions.list( program_id="program_id", + status="ACTIVE", + cursor="cursor", + limit=1, ) async for item in response: yield item @@ -417,20 +423,20 @@ async def main() -> None: return _response.data async def get( - self, promotion_id: str, program_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, program_id: str, promotion_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> GetLoyaltyPromotionResponse: """ Retrieves a loyalty promotion. Parameters ---------- - promotion_id : str - The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. - program_id : str The ID of the base [loyalty program](entity:LoyaltyProgram). To get the program ID, call [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) using the `main` keyword. + promotion_id : str + The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -452,18 +458,18 @@ async def get( async def main() -> None: await client.loyalty.programs.promotions.get( - promotion_id="promotion_id", program_id="program_id", + promotion_id="promotion_id", ) asyncio.run(main()) """ - _response = await self._raw_client.get(promotion_id, program_id, request_options=request_options) + _response = await self._raw_client.get(program_id, promotion_id, request_options=request_options) return _response.data async def cancel( - self, promotion_id: str, program_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, program_id: str, promotion_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> CancelLoyaltyPromotionResponse: """ Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE` promotion earlier than the @@ -475,13 +481,13 @@ async def cancel( Parameters ---------- + program_id : str + The ID of the base [loyalty program](entity:LoyaltyProgram). + promotion_id : str The ID of the [loyalty promotion](entity:LoyaltyPromotion) to cancel. You can cancel a promotion that has an `ACTIVE` or `SCHEDULED` status. - program_id : str - The ID of the base [loyalty program](entity:LoyaltyProgram). - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -503,12 +509,12 @@ async def cancel( async def main() -> None: await client.loyalty.programs.promotions.cancel( - promotion_id="promotion_id", program_id="program_id", + promotion_id="promotion_id", ) asyncio.run(main()) """ - _response = await self._raw_client.cancel(promotion_id, program_id, request_options=request_options) + _response = await self._raw_client.cancel(program_id, promotion_id, request_options=request_options) return _response.data diff --git a/src/square/loyalty/programs/promotions/raw_client.py b/src/square/loyalty/programs/promotions/raw_client.py index 838e369a..9a0de4f9 100644 --- a/src/square/loyalty/programs/promotions/raw_client.py +++ b/src/square/loyalty/programs/promotions/raw_client.py @@ -175,20 +175,20 @@ def create( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def get( - self, promotion_id: str, program_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, program_id: str, promotion_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[GetLoyaltyPromotionResponse]: """ Retrieves a loyalty promotion. Parameters ---------- - promotion_id : str - The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. - program_id : str The ID of the base [loyalty program](entity:LoyaltyProgram). To get the program ID, call [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) using the `main` keyword. + promotion_id : str + The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -218,7 +218,7 @@ def get( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def cancel( - self, promotion_id: str, program_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, program_id: str, promotion_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[CancelLoyaltyPromotionResponse]: """ Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE` promotion earlier than the @@ -230,13 +230,13 @@ def cancel( Parameters ---------- + program_id : str + The ID of the base [loyalty program](entity:LoyaltyProgram). + promotion_id : str The ID of the [loyalty promotion](entity:LoyaltyPromotion) to cancel. You can cancel a promotion that has an `ACTIVE` or `SCHEDULED` status. - program_id : str - The ID of the base [loyalty program](entity:LoyaltyProgram). - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -421,20 +421,20 @@ async def create( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def get( - self, promotion_id: str, program_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, program_id: str, promotion_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[GetLoyaltyPromotionResponse]: """ Retrieves a loyalty promotion. Parameters ---------- - promotion_id : str - The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. - program_id : str The ID of the base [loyalty program](entity:LoyaltyProgram). To get the program ID, call [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) using the `main` keyword. + promotion_id : str + The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -464,7 +464,7 @@ async def get( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def cancel( - self, promotion_id: str, program_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, program_id: str, promotion_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[CancelLoyaltyPromotionResponse]: """ Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE` promotion earlier than the @@ -476,13 +476,13 @@ async def cancel( Parameters ---------- + program_id : str + The ID of the base [loyalty program](entity:LoyaltyProgram). + promotion_id : str The ID of the [loyalty promotion](entity:LoyaltyPromotion) to cancel. You can cancel a promotion that has an `ACTIVE` or `SCHEDULED` status. - program_id : str - The ID of the base [loyalty program](entity:LoyaltyProgram). - request_options : typing.Optional[RequestOptions] Request-specific configuration. diff --git a/src/square/merchants/__init__.py b/src/square/merchants/__init__.py index ab727082..762ae6a5 100644 --- a/src/square/merchants/__init__.py +++ b/src/square/merchants/__init__.py @@ -2,6 +2,36 @@ # isort: skip_file -from . import custom_attribute_definitions, custom_attributes +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import custom_attribute_definitions, custom_attributes +_dynamic_imports: typing.Dict[str, str] = { + "custom_attribute_definitions": ".custom_attribute_definitions", + "custom_attributes": ".custom_attributes", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["custom_attribute_definitions", "custom_attributes"] diff --git a/src/square/merchants/client.py b/src/square/merchants/client.py index 2b368f2c..1ac7b162 100644 --- a/src/square/merchants/client.py +++ b/src/square/merchants/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -7,17 +9,22 @@ from ..core.request_options import RequestOptions from ..types.get_merchant_response import GetMerchantResponse from ..types.merchant import Merchant -from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient, CustomAttributeDefinitionsClient -from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient from .raw_client import AsyncRawMerchantsClient, RawMerchantsClient +if typing.TYPE_CHECKING: + from .custom_attribute_definitions.client import ( + AsyncCustomAttributeDefinitionsClient, + CustomAttributeDefinitionsClient, + ) + from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient + class MerchantsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawMerchantsClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=client_wrapper) - - self.custom_attributes = CustomAttributesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[CustomAttributeDefinitionsClient] = None + self._custom_attributes: typing.Optional[CustomAttributesClient] = None @property def with_raw_response(self) -> RawMerchantsClient: @@ -65,7 +72,9 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.merchants.list() + response = client.merchants.list( + cursor=1, + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -106,13 +115,29 @@ def get(self, merchant_id: str, *, request_options: typing.Optional[RequestOptio _response = self._raw_client.get(merchant_id, request_options=request_options) return _response.data + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import CustomAttributeDefinitionsClient # noqa: E402 + + self._custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=self._client_wrapper) + return self._custom_attribute_definitions + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import CustomAttributesClient # noqa: E402 + + self._custom_attributes = CustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes + class AsyncMerchantsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawMerchantsClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient(client_wrapper=client_wrapper) - - self.custom_attributes = AsyncCustomAttributesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[AsyncCustomAttributeDefinitionsClient] = None + self._custom_attributes: typing.Optional[AsyncCustomAttributesClient] = None @property def with_raw_response(self) -> AsyncRawMerchantsClient: @@ -165,7 +190,9 @@ async def list( async def main() -> None: - response = await client.merchants.list() + response = await client.merchants.list( + cursor=1, + ) async for item in response: yield item @@ -219,3 +246,21 @@ async def main() -> None: """ _response = await self._raw_client.get(merchant_id, request_options=request_options) return _response.data + + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient # noqa: E402 + + self._custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient( + client_wrapper=self._client_wrapper + ) + return self._custom_attribute_definitions + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import AsyncCustomAttributesClient # noqa: E402 + + self._custom_attributes = AsyncCustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes diff --git a/src/square/merchants/custom_attribute_definitions/client.py b/src/square/merchants/custom_attribute_definitions/client.py index e77bee35..72680902 100644 --- a/src/square/merchants/custom_attribute_definitions/client.py +++ b/src/square/merchants/custom_attribute_definitions/client.py @@ -85,7 +85,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.merchants.custom_attribute_definitions.list() + response = client.merchants.custom_attribute_definitions.list( + visibility_filter="ALL", + limit=1, + cursor="cursor", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -196,6 +200,7 @@ def get( ) client.merchants.custom_attribute_definitions.get( key="key", + version=1, ) """ _response = self._raw_client.get(key, version=version, request_options=request_options) @@ -371,7 +376,11 @@ async def list( async def main() -> None: - response = await client.merchants.custom_attribute_definitions.list() + response = await client.merchants.custom_attribute_definitions.list( + visibility_filter="ALL", + limit=1, + cursor="cursor", + ) async for item in response: yield item @@ -499,6 +508,7 @@ async def get( async def main() -> None: await client.merchants.custom_attribute_definitions.get( key="key", + version=1, ) diff --git a/src/square/merchants/custom_attributes/client.py b/src/square/merchants/custom_attributes/client.py index b72feb9a..046e1fcc 100644 --- a/src/square/merchants/custom_attributes/client.py +++ b/src/square/merchants/custom_attributes/client.py @@ -199,6 +199,10 @@ def list( ) response = client.merchants.custom_attributes.list( merchant_id="merchant_id", + visibility_filter="ALL", + limit=1, + cursor="cursor", + with_definitions=True, ) for item in response: yield item @@ -270,6 +274,8 @@ def get( client.merchants.custom_attributes.get( merchant_id="merchant_id", key="key", + with_definition=True, + version=1, ) """ _response = self._raw_client.get( @@ -583,6 +589,10 @@ async def list( async def main() -> None: response = await client.merchants.custom_attributes.list( merchant_id="merchant_id", + visibility_filter="ALL", + limit=1, + cursor="cursor", + with_definitions=True, ) async for item in response: yield item @@ -663,6 +673,8 @@ async def main() -> None: await client.merchants.custom_attributes.get( merchant_id="merchant_id", key="key", + with_definition=True, + version=1, ) diff --git a/src/square/orders/__init__.py b/src/square/orders/__init__.py index ab727082..762ae6a5 100644 --- a/src/square/orders/__init__.py +++ b/src/square/orders/__init__.py @@ -2,6 +2,36 @@ # isort: skip_file -from . import custom_attribute_definitions, custom_attributes +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import custom_attribute_definitions, custom_attributes +_dynamic_imports: typing.Dict[str, str] = { + "custom_attribute_definitions": ".custom_attribute_definitions", + "custom_attributes": ".custom_attributes", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["custom_attribute_definitions", "custom_attributes"] diff --git a/src/square/orders/client.py b/src/square/orders/client.py index cc21dd44..3537c4af 100644 --- a/src/square/orders/client.py +++ b/src/square/orders/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -15,10 +17,14 @@ from ..types.pay_order_response import PayOrderResponse from ..types.search_orders_response import SearchOrdersResponse from ..types.update_order_response import UpdateOrderResponse -from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient, CustomAttributeDefinitionsClient -from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient from .raw_client import AsyncRawOrdersClient, RawOrdersClient +if typing.TYPE_CHECKING: + from .custom_attribute_definitions.client import ( + AsyncCustomAttributeDefinitionsClient, + CustomAttributeDefinitionsClient, + ) + from .custom_attributes.client import AsyncCustomAttributesClient, CustomAttributesClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -26,9 +32,9 @@ class OrdersClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawOrdersClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=client_wrapper) - - self.custom_attributes = CustomAttributesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[CustomAttributeDefinitionsClient] = None + self._custom_attributes: typing.Optional[CustomAttributesClient] = None @property def with_raw_response(self) -> RawOrdersClient: @@ -611,13 +617,29 @@ def pay( ) return _response.data + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import CustomAttributeDefinitionsClient # noqa: E402 + + self._custom_attribute_definitions = CustomAttributeDefinitionsClient(client_wrapper=self._client_wrapper) + return self._custom_attribute_definitions + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import CustomAttributesClient # noqa: E402 + + self._custom_attributes = CustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes + class AsyncOrdersClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawOrdersClient(client_wrapper=client_wrapper) - self.custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient(client_wrapper=client_wrapper) - - self.custom_attributes = AsyncCustomAttributesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._custom_attribute_definitions: typing.Optional[AsyncCustomAttributeDefinitionsClient] = None + self._custom_attributes: typing.Optional[AsyncCustomAttributesClient] = None @property def with_raw_response(self) -> AsyncRawOrdersClient: @@ -1269,3 +1291,21 @@ async def main() -> None: request_options=request_options, ) return _response.data + + @property + def custom_attribute_definitions(self): + if self._custom_attribute_definitions is None: + from .custom_attribute_definitions.client import AsyncCustomAttributeDefinitionsClient # noqa: E402 + + self._custom_attribute_definitions = AsyncCustomAttributeDefinitionsClient( + client_wrapper=self._client_wrapper + ) + return self._custom_attribute_definitions + + @property + def custom_attributes(self): + if self._custom_attributes is None: + from .custom_attributes.client import AsyncCustomAttributesClient # noqa: E402 + + self._custom_attributes = AsyncCustomAttributesClient(client_wrapper=self._client_wrapper) + return self._custom_attributes diff --git a/src/square/orders/custom_attribute_definitions/client.py b/src/square/orders/custom_attribute_definitions/client.py index ea8986fc..07d6b80d 100644 --- a/src/square/orders/custom_attribute_definitions/client.py +++ b/src/square/orders/custom_attribute_definitions/client.py @@ -80,7 +80,11 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.orders.custom_attribute_definitions.list() + response = client.orders.custom_attribute_definitions.list( + visibility_filter="ALL", + cursor="cursor", + limit=1, + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -190,6 +194,7 @@ def get( ) client.orders.custom_attribute_definitions.get( key="key", + version=1, ) """ _response = self._raw_client.get(key, version=version, request_options=request_options) @@ -360,7 +365,11 @@ async def list( async def main() -> None: - response = await client.orders.custom_attribute_definitions.list() + response = await client.orders.custom_attribute_definitions.list( + visibility_filter="ALL", + cursor="cursor", + limit=1, + ) async for item in response: yield item @@ -487,6 +496,7 @@ async def get( async def main() -> None: await client.orders.custom_attribute_definitions.get( key="key", + version=1, ) diff --git a/src/square/orders/custom_attributes/client.py b/src/square/orders/custom_attributes/client.py index a4dadb9d..558e9b0e 100644 --- a/src/square/orders/custom_attributes/client.py +++ b/src/square/orders/custom_attributes/client.py @@ -225,6 +225,10 @@ def list( ) response = client.orders.custom_attributes.list( order_id="order_id", + visibility_filter="ALL", + cursor="cursor", + limit=1, + with_definitions=True, ) for item in response: yield item @@ -296,6 +300,8 @@ def get( client.orders.custom_attributes.get( order_id="order_id", custom_attribute_key="custom_attribute_key", + version=1, + with_definition=True, ) """ _response = self._raw_client.get( @@ -643,6 +649,10 @@ async def list( async def main() -> None: response = await client.orders.custom_attributes.list( order_id="order_id", + visibility_filter="ALL", + cursor="cursor", + limit=1, + with_definitions=True, ) async for item in response: yield item @@ -723,6 +733,8 @@ async def main() -> None: await client.orders.custom_attributes.get( order_id="order_id", custom_attribute_key="custom_attribute_key", + version=1, + with_definition=True, ) diff --git a/src/square/payments/client.py b/src/square/payments/client.py index ca6deb6b..1c5bbe6b 100644 --- a/src/square/payments/client.py +++ b/src/square/payments/client.py @@ -160,7 +160,23 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.payments.list() + response = client.payments.list( + begin_time="begin_time", + end_time="end_time", + sort_order="sort_order", + cursor="cursor", + location_id="location_id", + total=1000000, + last4="last_4", + card_brand="card_brand", + limit=1, + is_offline_payment=True, + offline_begin_time="offline_begin_time", + offline_end_time="offline_end_time", + updated_at_begin_time="updated_at_begin_time", + updated_at_end_time="updated_at_end_time", + sort_field="CREATED_AT", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -808,7 +824,23 @@ async def list( async def main() -> None: - response = await client.payments.list() + response = await client.payments.list( + begin_time="begin_time", + end_time="end_time", + sort_order="sort_order", + cursor="cursor", + location_id="location_id", + total=1000000, + last4="last_4", + card_brand="card_brand", + limit=1, + is_offline_payment=True, + offline_begin_time="offline_begin_time", + offline_end_time="offline_end_time", + updated_at_begin_time="updated_at_begin_time", + updated_at_end_time="updated_at_end_time", + sort_field="CREATED_AT", + ) async for item in response: yield item diff --git a/src/square/payouts/client.py b/src/square/payouts/client.py index 4a66692d..8156389a 100644 --- a/src/square/payouts/client.py +++ b/src/square/payouts/client.py @@ -93,7 +93,15 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.payouts.list() + response = client.payouts.list( + location_id="location_id", + status="SENT", + begin_time="begin_time", + end_time="end_time", + sort_order="DESC", + cursor="cursor", + limit=1, + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -194,6 +202,9 @@ def list_entries( ) response = client.payouts.list_entries( payout_id="payout_id", + sort_order="DESC", + cursor="cursor", + limit=1, ) for item in response: yield item @@ -291,7 +302,15 @@ async def list( async def main() -> None: - response = await client.payouts.list() + response = await client.payouts.list( + location_id="location_id", + status="SENT", + begin_time="begin_time", + end_time="end_time", + sort_order="DESC", + cursor="cursor", + limit=1, + ) async for item in response: yield item @@ -411,6 +430,9 @@ async def list_entries( async def main() -> None: response = await client.payouts.list_entries( payout_id="payout_id", + sort_order="DESC", + cursor="cursor", + limit=1, ) async for item in response: yield item diff --git a/src/square/refunds/client.py b/src/square/refunds/client.py index 54904b0b..a53d44e3 100644 --- a/src/square/refunds/client.py +++ b/src/square/refunds/client.py @@ -139,7 +139,19 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.refunds.list() + response = client.refunds.list( + begin_time="begin_time", + end_time="end_time", + sort_order="sort_order", + cursor="cursor", + location_id="location_id", + status="status", + source_type="source_type", + limit=1, + updated_at_begin_time="updated_at_begin_time", + updated_at_end_time="updated_at_end_time", + sort_field="CREATED_AT", + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -471,7 +483,19 @@ async def list( async def main() -> None: - response = await client.refunds.list() + response = await client.refunds.list( + begin_time="begin_time", + end_time="end_time", + sort_order="sort_order", + cursor="cursor", + location_id="location_id", + status="status", + source_type="source_type", + limit=1, + updated_at_begin_time="updated_at_begin_time", + updated_at_end_time="updated_at_end_time", + sort_field="CREATED_AT", + ) async for item in response: yield item diff --git a/src/square/requests/bulk_retrieve_channels_response.py b/src/square/requests/bulk_retrieve_channels_response.py new file mode 100644 index 00000000..de21568b --- /dev/null +++ b/src/square/requests/bulk_retrieve_channels_response.py @@ -0,0 +1,27 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .error import ErrorParams +from .retrieve_channel_response import RetrieveChannelResponseParams + + +class BulkRetrieveChannelsResponseParams(typing_extensions.TypedDict): + """ + Defines the fields that are included in the request body for the + [BulkRetrieveChannels](api-endpoint:Channels-BulkRetrieveChannels) endpoint. + """ + + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Information about errors encountered during the request. + """ + + responses: typing_extensions.NotRequired[typing.Dict[str, RetrieveChannelResponseParams]] + """ + A map of channel IDs to channel responses which tell whether + retrieval for a specific channel is success or not. + Channel response of a success retrieval would contain channel info + whereas channel response of a failed retrieval would have error info. + """ diff --git a/src/square/requests/cancel_transfer_order_response.py b/src/square/requests/cancel_transfer_order_response.py new file mode 100644 index 00000000..ec1da7b5 --- /dev/null +++ b/src/square/requests/cancel_transfer_order_response.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .error import ErrorParams +from .transfer_order import TransferOrderParams + + +class CancelTransferOrderResponseParams(typing_extensions.TypedDict): + """ + Response for canceling a transfer order + """ + + transfer_order: typing_extensions.NotRequired[TransferOrderParams] + """ + The updated transfer order with status changed to CANCELED + """ + + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Any errors that occurred during the request + """ diff --git a/src/square/requests/channel.py b/src/square/requests/channel.py new file mode 100644 index 00000000..e636e2a2 --- /dev/null +++ b/src/square/requests/channel.py @@ -0,0 +1,52 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from ..types.channel_status import ChannelStatus +from .reference import ReferenceParams + + +class ChannelParams(typing_extensions.TypedDict): + id: typing_extensions.NotRequired[str] + """ + The channel's unique ID. + """ + + merchant_id: typing_extensions.NotRequired[str] + """ + The unique ID of the merchant this channel belongs to. + """ + + name: typing_extensions.NotRequired[typing.Optional[str]] + """ + The name of the channel. + """ + + version: typing_extensions.NotRequired[int] + """ + The version number which is incremented each time an update is made to the channel. + """ + + reference: typing_extensions.NotRequired[ReferenceParams] + """ + Represents an entity the channel is associated with. + """ + + status: typing_extensions.NotRequired[ChannelStatus] + """ + Status of the channel. + See [Status](#type-status) for possible values + """ + + created_at: typing_extensions.NotRequired[str] + """ + The timestamp for when the channel was created, in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). + For more information, see [Working with Dates](https://developer.squareup.com/docs/build-basics/working-with-dates). + """ + + updated_at: typing_extensions.NotRequired[str] + """ + The timestamp for when the channel was last updated, in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). + For more information, see [Working with Dates](https://developer.squareup.com/docs/build-basics/working-with-dates). + """ diff --git a/src/square/requests/create_transfer_order_data.py b/src/square/requests/create_transfer_order_data.py new file mode 100644 index 00000000..f85bfcd2 --- /dev/null +++ b/src/square/requests/create_transfer_order_data.py @@ -0,0 +1,52 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .create_transfer_order_line_data import CreateTransferOrderLineDataParams + + +class CreateTransferOrderDataParams(typing_extensions.TypedDict): + """ + Data for creating a new transfer order to move [CatalogItemVariation](entity:CatalogItemVariation)s + between [Location](entity:Location)s. Used with the [CreateTransferOrder](api-endpoint:TransferOrders-CreateTransferOrder) + endpoint. + """ + + source_location_id: str + """ + The source [Location](entity:Location) that will send the items. Must be an active location + in your Square account with sufficient inventory of the requested items. + """ + + destination_location_id: str + """ + The destination [Location](entity:Location) that will receive the items. Must be an active location + in your Square account + """ + + expected_at: typing_extensions.NotRequired[typing.Optional[str]] + """ + Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z"). + """ + + notes: typing_extensions.NotRequired[typing.Optional[str]] + """ + Optional notes about the transfer + """ + + tracking_number: typing_extensions.NotRequired[typing.Optional[str]] + """ + Optional shipment tracking number + """ + + created_by_team_member_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + ID of the [TeamMember](entity:TeamMember) creating this transfer order. Used for tracking + and auditing purposes. + """ + + line_items: typing_extensions.NotRequired[typing.Optional[typing.Sequence[CreateTransferOrderLineDataParams]]] + """ + List of [CatalogItemVariation](entity:CatalogItemVariation)s to transfer, including quantities + """ diff --git a/src/square/requests/create_transfer_order_line_data.py b/src/square/requests/create_transfer_order_line_data.py new file mode 100644 index 00000000..1cf2d6af --- /dev/null +++ b/src/square/requests/create_transfer_order_line_data.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions + + +class CreateTransferOrderLineDataParams(typing_extensions.TypedDict): + """ + Data for creating a new transfer order line item. Each line item specifies a + [CatalogItemVariation](entity:CatalogItemVariation) and quantity to transfer. + """ + + item_variation_id: str + """ + ID of the [CatalogItemVariation](entity:CatalogItemVariation) to transfer. Must reference a valid + item variation in the [Catalog](api:Catalog). The item variation must be: + - Active and available for sale + - Enabled for inventory tracking + - Available at the source location + """ + + quantity_ordered: str + """ + Total quantity ordered + """ diff --git a/src/square/requests/create_transfer_order_response.py b/src/square/requests/create_transfer_order_response.py new file mode 100644 index 00000000..cb6ceefa --- /dev/null +++ b/src/square/requests/create_transfer_order_response.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .error import ErrorParams +from .transfer_order import TransferOrderParams + + +class CreateTransferOrderResponseParams(typing_extensions.TypedDict): + """ + Response for creating a transfer order. + """ + + transfer_order: typing_extensions.NotRequired[TransferOrderParams] + """ + The created transfer order + """ + + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Any errors that occurred during the request + """ diff --git a/src/square/requests/custom_attribute.py b/src/square/requests/custom_attribute.py index fc11f71d..97927835 100644 --- a/src/square/requests/custom_attribute.py +++ b/src/square/requests/custom_attribute.py @@ -28,7 +28,14 @@ class CustomAttributeParams(typing_extensions.TypedDict): underscores (_), and hyphens (-). """ - value: typing_extensions.NotRequired[typing.Optional[typing.Any]] + value: typing_extensions.NotRequired[typing.Optional[typing.Optional[typing.Any]]] + """ + The value assigned to the custom attribute. It is validated against the custom + attribute definition's schema on write operations. For more information about custom + attribute values, + see [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). + """ + version: typing_extensions.NotRequired[int] """ Read only. The current version of the custom attribute. This field is incremented when the custom attribute is changed. diff --git a/src/square/requests/delete_transfer_order_response.py b/src/square/requests/delete_transfer_order_response.py new file mode 100644 index 00000000..32302ca8 --- /dev/null +++ b/src/square/requests/delete_transfer_order_response.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .error import ErrorParams + + +class DeleteTransferOrderResponseParams(typing_extensions.TypedDict): + """ + Response for deleting a transfer order + """ + + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Any errors that occurred during the request + """ diff --git a/src/square/requests/list_channels_response.py b/src/square/requests/list_channels_response.py new file mode 100644 index 00000000..1e3433ae --- /dev/null +++ b/src/square/requests/list_channels_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .channel import ChannelParams +from .error import ErrorParams + + +class ListChannelsResponseParams(typing_extensions.TypedDict): + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Information about errors encountered during the request. + """ + + channels: typing_extensions.NotRequired[typing.Sequence[ChannelParams]] + """ + List of requested Channel. + """ + + cursor: typing_extensions.NotRequired[str] + """ + The token required to retrieve the next page of results. + """ diff --git a/src/square/requests/receive_transfer_order_response.py b/src/square/requests/receive_transfer_order_response.py new file mode 100644 index 00000000..2415cca1 --- /dev/null +++ b/src/square/requests/receive_transfer_order_response.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .error import ErrorParams +from .transfer_order import TransferOrderParams + + +class ReceiveTransferOrderResponseParams(typing_extensions.TypedDict): + """ + Response for receiving items for a transfer order + """ + + transfer_order: typing_extensions.NotRequired[TransferOrderParams] + """ + The updated transfer order + """ + + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Any errors that occurred during the request + """ diff --git a/src/square/requests/reference.py b/src/square/requests/reference.py new file mode 100644 index 00000000..aec6d062 --- /dev/null +++ b/src/square/requests/reference.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +from ..types.reference_type import ReferenceType + + +class ReferenceParams(typing_extensions.TypedDict): + type: typing_extensions.NotRequired[ReferenceType] + """ + The type of entity a channel is associated with. + See [Type](#type-type) for possible values + """ + + id: typing_extensions.NotRequired[str] + """ + The id of the entity a channel is associated with. + """ diff --git a/src/square/requests/retrieve_channel_response.py b/src/square/requests/retrieve_channel_response.py new file mode 100644 index 00000000..9ca6156a --- /dev/null +++ b/src/square/requests/retrieve_channel_response.py @@ -0,0 +1,19 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .channel import ChannelParams +from .error import ErrorParams + + +class RetrieveChannelResponseParams(typing_extensions.TypedDict): + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Information about errors encountered during the request. + """ + + channel: typing_extensions.NotRequired[ChannelParams] + """ + The requested Channel. + """ diff --git a/src/square/requests/retrieve_transfer_order_response.py b/src/square/requests/retrieve_transfer_order_response.py new file mode 100644 index 00000000..0eefb44e --- /dev/null +++ b/src/square/requests/retrieve_transfer_order_response.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .error import ErrorParams +from .transfer_order import TransferOrderParams + + +class RetrieveTransferOrderResponseParams(typing_extensions.TypedDict): + """ + Response containing the requested transfer order + """ + + transfer_order: typing_extensions.NotRequired[TransferOrderParams] + """ + The requested transfer order + """ + + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Any errors that occurred during the request + """ diff --git a/src/square/requests/search_transfer_orders_response.py b/src/square/requests/search_transfer_orders_response.py new file mode 100644 index 00000000..09440ec6 --- /dev/null +++ b/src/square/requests/search_transfer_orders_response.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .error import ErrorParams +from .transfer_order import TransferOrderParams + + +class SearchTransferOrdersResponseParams(typing_extensions.TypedDict): + """ + Response for searching transfer orders + """ + + transfer_orders: typing_extensions.NotRequired[typing.Sequence[TransferOrderParams]] + """ + List of transfer orders matching the search criteria + """ + + cursor: typing_extensions.NotRequired[str] + """ + Pagination cursor for fetching the next page of results + """ + + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Any errors that occurred during the request + """ diff --git a/src/square/requests/start_transfer_order_response.py b/src/square/requests/start_transfer_order_response.py new file mode 100644 index 00000000..0bc49ade --- /dev/null +++ b/src/square/requests/start_transfer_order_response.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .error import ErrorParams +from .transfer_order import TransferOrderParams + + +class StartTransferOrderResponseParams(typing_extensions.TypedDict): + """ + Response for starting a transfer order. + """ + + transfer_order: typing_extensions.NotRequired[TransferOrderParams] + """ + The updated transfer order with status changed to STARTED + """ + + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Any errors that occurred during the request + """ diff --git a/src/square/requests/transfer_order.py b/src/square/requests/transfer_order.py new file mode 100644 index 00000000..1f216f5c --- /dev/null +++ b/src/square/requests/transfer_order.py @@ -0,0 +1,131 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from ..types.transfer_order_status import TransferOrderStatus +from .transfer_order_line import TransferOrderLineParams + + +class TransferOrderParams(typing_extensions.TypedDict): + """ + Represents a transfer order for moving [CatalogItemVariation](entity:CatalogItemVariation)s + between [Location](entity:Location)s. Transfer orders track the entire lifecycle of an inventory + transfer, including: + - What items and quantities are being moved + - Source and destination locations + - Current [TransferOrderStatus](entity:TransferOrderStatus) + - Shipping information and tracking + - Which [TeamMember](entity:TeamMember) initiated the transfer + + This object is commonly used to: + - Track [CatalogItemVariation](entity:CatalogItemVariation) movements between [Location](entity:Location)s + - Reconcile expected vs received quantities + - Monitor transfer progress and shipping status + - Audit inventory movement history + """ + + id: typing_extensions.NotRequired[str] + """ + Unique system-generated identifier for this transfer order. Use this ID for: + - Retrieving transfer order details + - Tracking status changes via webhooks + - Linking transfers in external systems + """ + + source_location_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + The source [Location](entity:Location) sending the [CatalogItemVariation](entity:CatalogItemVariation)s. + This location must: + - Be active in your Square organization + - Have sufficient inventory for the items being transferred + - Not be the same as the destination location + + This field is not updatable. + """ + + destination_location_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + The destination [Location](entity:Location) receiving the [CatalogItemVariation](entity:CatalogItemVariation)s. + This location must: + - Be active in your Square organization + - Not be the same as the source location + + This field is not updatable. + """ + + status: typing_extensions.NotRequired[TransferOrderStatus] + """ + Current [TransferOrderStatus](entity:TransferOrderStatus) indicating where the order is in its lifecycle. + Status transitions follow this progression: + 1. [DRAFT](entity:TransferOrderStatus) -> [STARTED](entity:TransferOrderStatus) via [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder) + 2. [STARTED](entity:TransferOrderStatus) -> [PARTIALLY_RECEIVED](entity:TransferOrderStatus) via [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder) + 3. [PARTIALLY_RECEIVED](entity:TransferOrderStatus) -> [COMPLETED](entity:TransferOrderStatus) after all items received + + Orders can be [CANCELED](entity:TransferOrderStatus) from [STARTED](entity:TransferOrderStatus) or + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. + + This field is read-only and reflects the current state of the transfer order, and cannot be updated directly. Use the appropriate + endpoints (e.g. [StartPurchaseOrder](api-endpoint:TransferOrders-StartTransferOrder), to change the status. + See [TransferOrderStatus](#type-transferorderstatus) for possible values + """ + + created_at: typing_extensions.NotRequired[str] + """ + Timestamp when the transfer order was created, in RFC 3339 format. + Used for: + - Auditing transfer history + - Tracking order age + - Reporting and analytics + """ + + updated_at: typing_extensions.NotRequired[str] + """ + Timestamp when the transfer order was last updated, in RFC 3339 format. + Updated when: + - Order status changes + - Items are received + - Notes or metadata are modified + """ + + expected_at: typing_extensions.NotRequired[typing.Optional[str]] + """ + Expected transfer completion date, in RFC 3339 format. + Used for: + - Planning inventory availability + - Scheduling receiving staff + - Monitoring transfer timeliness + """ + + completed_at: typing_extensions.NotRequired[str] + """ + Timestamp when the transfer order was completed or canceled, in RFC 3339 format (e.g. "2023-10-01T12:00:00Z"). + """ + + notes: typing_extensions.NotRequired[typing.Optional[str]] + """ + Optional notes about the transfer. + """ + + tracking_number: typing_extensions.NotRequired[typing.Optional[str]] + """ + Shipment tracking number for monitoring transfer progress. + """ + + created_by_team_member_id: typing_extensions.NotRequired[str] + """ + ID of the [TeamMember](entity:TeamMember) who created this transfer order. This field is not writeable by the Connect V2 API. + """ + + line_items: typing_extensions.NotRequired[typing.Optional[typing.Sequence[TransferOrderLineParams]]] + """ + List of [CatalogItemVariation](entity:CatalogItemVariation)s being transferred. + """ + + version: typing_extensions.NotRequired[int] + """ + Version for optimistic concurrency control. This is a monotonically increasing integer + that changes whenever the transfer order is modified. Use this when calling + [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder) and other endpoints to ensure you're + not overwriting concurrent changes. + """ diff --git a/src/square/requests/transfer_order_created_event.py b/src/square/requests/transfer_order_created_event.py new file mode 100644 index 00000000..93dbb581 --- /dev/null +++ b/src/square/requests/transfer_order_created_event.py @@ -0,0 +1,37 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .transfer_order_created_event_data import TransferOrderCreatedEventDataParams + + +class TransferOrderCreatedEventParams(typing_extensions.TypedDict): + """ + Published when a transfer_order is created. + """ + + merchant_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + The ID of the target merchant associated with the event. + """ + + type: typing_extensions.NotRequired[typing.Optional[str]] + """ + The type of event this represents, `"transfer_order.created"`. + """ + + event_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + A unique ID for the event. + """ + + created_at: typing_extensions.NotRequired[str] + """ + Timestamp of when the event was created, in RFC 3339 format. + """ + + data: typing_extensions.NotRequired[TransferOrderCreatedEventDataParams] + """ + Data associated with the event. + """ diff --git a/src/square/requests/transfer_order_created_event_data.py b/src/square/requests/transfer_order_created_event_data.py new file mode 100644 index 00000000..88a23bcc --- /dev/null +++ b/src/square/requests/transfer_order_created_event_data.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .transfer_order_created_event_object import TransferOrderCreatedEventObjectParams + + +class TransferOrderCreatedEventDataParams(typing_extensions.TypedDict): + type: typing_extensions.NotRequired[typing.Optional[str]] + """ + Name of the affected object’s type, `"transfer_order"`. + """ + + id: typing_extensions.NotRequired[str] + """ + ID of the affected transfer_order. + """ + + object: typing_extensions.NotRequired[TransferOrderCreatedEventObjectParams] + """ + An object containing the created transfer_order. + """ diff --git a/src/square/requests/transfer_order_created_event_object.py b/src/square/requests/transfer_order_created_event_object.py new file mode 100644 index 00000000..e0bf87f9 --- /dev/null +++ b/src/square/requests/transfer_order_created_event_object.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +from .transfer_order import TransferOrderParams + + +class TransferOrderCreatedEventObjectParams(typing_extensions.TypedDict): + transfer_order: typing_extensions.NotRequired[TransferOrderParams] + """ + The created transfer_order. + """ diff --git a/src/square/requests/transfer_order_deleted_event.py b/src/square/requests/transfer_order_deleted_event.py new file mode 100644 index 00000000..674de288 --- /dev/null +++ b/src/square/requests/transfer_order_deleted_event.py @@ -0,0 +1,37 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .transfer_order_deleted_event_data import TransferOrderDeletedEventDataParams + + +class TransferOrderDeletedEventParams(typing_extensions.TypedDict): + """ + Published when a transfer_order is deleted. + """ + + merchant_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + The ID of the target merchant associated with the event. + """ + + type: typing_extensions.NotRequired[typing.Optional[str]] + """ + The type of event this represents, `"transfer_order.deleted"`. + """ + + event_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + A unique ID for the event. + """ + + created_at: typing_extensions.NotRequired[str] + """ + Timestamp of when the event was created, in RFC 3339 format. + """ + + data: typing_extensions.NotRequired[TransferOrderDeletedEventDataParams] + """ + Data associated with the event. + """ diff --git a/src/square/requests/transfer_order_deleted_event_data.py b/src/square/requests/transfer_order_deleted_event_data.py new file mode 100644 index 00000000..7d278943 --- /dev/null +++ b/src/square/requests/transfer_order_deleted_event_data.py @@ -0,0 +1,22 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions + + +class TransferOrderDeletedEventDataParams(typing_extensions.TypedDict): + type: typing_extensions.NotRequired[typing.Optional[str]] + """ + Name of the affected object’s type, `"transfer_order"`. + """ + + id: typing_extensions.NotRequired[str] + """ + ID of the affected transfer_order. + """ + + deleted: typing_extensions.NotRequired[typing.Optional[bool]] + """ + Is true if the affected object was deleted. Otherwise absent. + """ diff --git a/src/square/requests/transfer_order_filter.py b/src/square/requests/transfer_order_filter.py new file mode 100644 index 00000000..74f68275 --- /dev/null +++ b/src/square/requests/transfer_order_filter.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from ..types.transfer_order_status import TransferOrderStatus + + +class TransferOrderFilterParams(typing_extensions.TypedDict): + """ + Filter criteria for searching transfer orders + """ + + source_location_ids: typing_extensions.NotRequired[typing.Optional[typing.Sequence[str]]] + """ + Filter by source location IDs + """ + + destination_location_ids: typing_extensions.NotRequired[typing.Optional[typing.Sequence[str]]] + """ + Filter by destination location IDs + """ + + statuses: typing_extensions.NotRequired[typing.Optional[typing.Sequence[TransferOrderStatus]]] + """ + Filter by order statuses + See [TransferOrderStatus](#type-transferorderstatus) for possible values + """ diff --git a/src/square/requests/transfer_order_goods_receipt.py b/src/square/requests/transfer_order_goods_receipt.py new file mode 100644 index 00000000..5bd410cb --- /dev/null +++ b/src/square/requests/transfer_order_goods_receipt.py @@ -0,0 +1,44 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .transfer_order_goods_receipt_line_item import TransferOrderGoodsReceiptLineItemParams + + +class TransferOrderGoodsReceiptParams(typing_extensions.TypedDict): + """ + The goods receipt details for a transfer order. This object represents a single receipt + of goods against a transfer order, tracking: + + - Which [CatalogItemVariation](entity:CatalogItemVariation)s were received + - Quantities received in good condition + - Quantities damaged during transit/handling + - Quantities canceled during receipt + + Multiple goods receipts can be created for a single transfer order to handle: + - Partial deliveries + - Multiple shipments + - Split receipts across different dates + - Cancellations of specific quantities + + Each receipt automatically: + - Updates the transfer order status + - Adjusts received quantities + - Updates inventory levels at both source and destination [Location](entity:Location)s + """ + + line_items: typing_extensions.NotRequired[typing.Optional[typing.Sequence[TransferOrderGoodsReceiptLineItemParams]]] + """ + Line items being received. Each line item specifies: + - The item being received + - Quantity received in good condition + - Quantity received damaged + - Quantity canceled + + Constraints: + - Must include at least one line item + - Maximum of 1000 line items per receipt + - Each line item must reference a valid item from the transfer order + - Total of received, damaged, and canceled quantities cannot exceed ordered quantity + """ diff --git a/src/square/requests/transfer_order_goods_receipt_line_item.py b/src/square/requests/transfer_order_goods_receipt_line_item.py new file mode 100644 index 00000000..cb621d00 --- /dev/null +++ b/src/square/requests/transfer_order_goods_receipt_line_item.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions + + +class TransferOrderGoodsReceiptLineItemParams(typing_extensions.TypedDict): + """ + A simplified line item for goods receipts in transfer orders + """ + + transfer_order_line_uid: str + """ + The unique identifier of the Transfer Order line being received + """ + + quantity_received: typing_extensions.NotRequired[typing.Optional[str]] + """ + The quantity received for this line item as a decimal string (e.g. "10.5"). + These items will be added to the destination [Location](entity:Location)'s inventory with [InventoryState](entity:InventoryState) of IN_STOCK. + """ + + quantity_damaged: typing_extensions.NotRequired[typing.Optional[str]] + """ + The quantity that was damaged during shipping/handling as a decimal string (e.g. "1.5"). + These items will be added to the destination [Location](entity:Location)'s inventory with [InventoryState](entity:InventoryState) of WASTE. + """ + + quantity_canceled: typing_extensions.NotRequired[typing.Optional[str]] + """ + The quantity that was canceled during shipping/handling as a decimal string (e.g. "1.5"). These will be immediately added to inventory in the source location. + """ diff --git a/src/square/requests/transfer_order_line.py b/src/square/requests/transfer_order_line.py new file mode 100644 index 00000000..ef1b26f4 --- /dev/null +++ b/src/square/requests/transfer_order_line.py @@ -0,0 +1,57 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions + + +class TransferOrderLineParams(typing_extensions.TypedDict): + """ + Represents a line item in a transfer order. Each line item tracks a specific + [CatalogItemVariation](entity:CatalogItemVariation) being transferred, including ordered quantities + and receipt status. + """ + + uid: typing_extensions.NotRequired[str] + """ + Unique system-generated identifier for the line item. Provide when updating/removing a line via [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder). + """ + + item_variation_id: str + """ + The required identifier of the [CatalogItemVariation](entity:CatalogItemVariation) being transferred. Must reference + a valid catalog item variation that exists in the [Catalog](api:Catalog). + """ + + quantity_ordered: str + """ + Total quantity ordered, formatted as a decimal string (e.g. "10 or 10.0000"). Required to be a positive number. + + To remove a line item, set `remove` to `true` in [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder). + """ + + quantity_pending: typing_extensions.NotRequired[str] + """ + Calculated quantity of this line item's yet to be received stock. This is the difference between the total quantity ordered and the sum of quantities received, canceled, and damaged. + """ + + quantity_received: typing_extensions.NotRequired[str] + """ + Quantity received at destination. These items are added to the destination + [Location](entity:Location)'s inventory with [InventoryState](entity:InventoryState) of IN_STOCK. + + This field cannot be updated directly in Create/Update operations, instead use [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder). + """ + + quantity_damaged: typing_extensions.NotRequired[str] + """ + Quantity received in damaged condition. These items are added to the destination + [Location](entity:Location)'s inventory with [InventoryState](entity:InventoryState) of WASTE. + + This field cannot be updated directly in Create/Update operations, instead use [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder). + """ + + quantity_canceled: typing_extensions.NotRequired[str] + """ + Quantity that was canceled. These items will be immediately added to inventory in the source location. + + This field cannot be updated directly in Create/Update operations, instead use [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder) or [CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + """ diff --git a/src/square/requests/transfer_order_query.py b/src/square/requests/transfer_order_query.py new file mode 100644 index 00000000..6a2dca84 --- /dev/null +++ b/src/square/requests/transfer_order_query.py @@ -0,0 +1,21 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +from .transfer_order_filter import TransferOrderFilterParams +from .transfer_order_sort import TransferOrderSortParams + + +class TransferOrderQueryParams(typing_extensions.TypedDict): + """ + Query parameters for searching transfer orders + """ + + filter: typing_extensions.NotRequired[TransferOrderFilterParams] + """ + Filter criteria + """ + + sort: typing_extensions.NotRequired[TransferOrderSortParams] + """ + Sort configuration + """ diff --git a/src/square/requests/transfer_order_sort.py b/src/square/requests/transfer_order_sort.py new file mode 100644 index 00000000..8d5b5f37 --- /dev/null +++ b/src/square/requests/transfer_order_sort.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +from ..types.sort_order import SortOrder +from ..types.transfer_order_sort_field import TransferOrderSortField + + +class TransferOrderSortParams(typing_extensions.TypedDict): + """ + Sort configuration for search results + """ + + field: typing_extensions.NotRequired[TransferOrderSortField] + """ + Field to sort by + See [TransferOrderSortField](#type-transferordersortfield) for possible values + """ + + order: typing_extensions.NotRequired[SortOrder] + """ + Sort order direction + See [SortOrder](#type-sortorder) for possible values + """ diff --git a/src/square/requests/transfer_order_updated_event.py b/src/square/requests/transfer_order_updated_event.py new file mode 100644 index 00000000..b292c136 --- /dev/null +++ b/src/square/requests/transfer_order_updated_event.py @@ -0,0 +1,37 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .transfer_order_updated_event_data import TransferOrderUpdatedEventDataParams + + +class TransferOrderUpdatedEventParams(typing_extensions.TypedDict): + """ + Published when a transfer_order is updated. + """ + + merchant_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + The ID of the target merchant associated with the event. + """ + + type: typing_extensions.NotRequired[typing.Optional[str]] + """ + The type of event this represents, `"transfer_order.updated"`. + """ + + event_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + A unique ID for the event. + """ + + created_at: typing_extensions.NotRequired[str] + """ + Timestamp of when the event was created, in RFC 3339 format. + """ + + data: typing_extensions.NotRequired[TransferOrderUpdatedEventDataParams] + """ + Data associated with the event. + """ diff --git a/src/square/requests/transfer_order_updated_event_data.py b/src/square/requests/transfer_order_updated_event_data.py new file mode 100644 index 00000000..f28a8488 --- /dev/null +++ b/src/square/requests/transfer_order_updated_event_data.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .transfer_order_updated_event_object import TransferOrderUpdatedEventObjectParams + + +class TransferOrderUpdatedEventDataParams(typing_extensions.TypedDict): + type: typing_extensions.NotRequired[typing.Optional[str]] + """ + Name of the affected object’s type, `"transfer_order"`. + """ + + id: typing_extensions.NotRequired[str] + """ + ID of the affected transfer_order. + """ + + object: typing_extensions.NotRequired[TransferOrderUpdatedEventObjectParams] + """ + An object containing the updated transfer_order. + """ diff --git a/src/square/requests/transfer_order_updated_event_object.py b/src/square/requests/transfer_order_updated_event_object.py new file mode 100644 index 00000000..e64de1f3 --- /dev/null +++ b/src/square/requests/transfer_order_updated_event_object.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +from .transfer_order import TransferOrderParams + + +class TransferOrderUpdatedEventObjectParams(typing_extensions.TypedDict): + transfer_order: typing_extensions.NotRequired[TransferOrderParams] + """ + The updated transfer_order. + """ diff --git a/src/square/requests/update_transfer_order_data.py b/src/square/requests/update_transfer_order_data.py new file mode 100644 index 00000000..c16f8b15 --- /dev/null +++ b/src/square/requests/update_transfer_order_data.py @@ -0,0 +1,44 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .update_transfer_order_line_data import UpdateTransferOrderLineDataParams + + +class UpdateTransferOrderDataParams(typing_extensions.TypedDict): + """ + Data model for updating a transfer order. All fields are optional. + """ + + source_location_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + The source [Location](entity:Location) that will send the items. Must be an active location + in your Square account with sufficient inventory of the requested items. + """ + + destination_location_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + The destination [Location](entity:Location) that will receive the items. Must be an active location + in your Square account. + """ + + expected_at: typing_extensions.NotRequired[typing.Optional[str]] + """ + Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z"). + """ + + notes: typing_extensions.NotRequired[typing.Optional[str]] + """ + Optional notes about the transfer + """ + + tracking_number: typing_extensions.NotRequired[typing.Optional[str]] + """ + Shipment tracking number + """ + + line_items: typing_extensions.NotRequired[typing.Optional[typing.Sequence[UpdateTransferOrderLineDataParams]]] + """ + List of items being transferred + """ diff --git a/src/square/requests/update_transfer_order_line_data.py b/src/square/requests/update_transfer_order_line_data.py new file mode 100644 index 00000000..ce5982df --- /dev/null +++ b/src/square/requests/update_transfer_order_line_data.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions + + +class UpdateTransferOrderLineDataParams(typing_extensions.TypedDict): + """ + Represents a line item update in a transfer order + """ + + uid: typing_extensions.NotRequired[typing.Optional[str]] + """ + Line item id being updated. Required for updating/removing existing line items, but should not be set for new line items. + """ + + item_variation_id: typing_extensions.NotRequired[typing.Optional[str]] + """ + Catalog item variation being transferred + + Required for new line items, but otherwise is not updatable. + """ + + quantity_ordered: typing_extensions.NotRequired[typing.Optional[str]] + """ + Total quantity ordered + """ + + remove: typing_extensions.NotRequired[typing.Optional[bool]] + """ + Flag to remove the line item during update. Must include `uid` in removal request + """ diff --git a/src/square/requests/update_transfer_order_response.py b/src/square/requests/update_transfer_order_response.py new file mode 100644 index 00000000..cff2fe53 --- /dev/null +++ b/src/square/requests/update_transfer_order_response.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import typing_extensions +from .error import ErrorParams +from .transfer_order import TransferOrderParams + + +class UpdateTransferOrderResponseParams(typing_extensions.TypedDict): + """ + Response for updating a transfer order + """ + + transfer_order: typing_extensions.NotRequired[TransferOrderParams] + """ + The updated transfer order + """ + + errors: typing_extensions.NotRequired[typing.Sequence[ErrorParams]] + """ + Any errors that occurred during the request + """ diff --git a/src/square/subscriptions/client.py b/src/square/subscriptions/client.py index b31cedc9..376f3c0b 100644 --- a/src/square/subscriptions/client.py +++ b/src/square/subscriptions/client.py @@ -358,6 +358,7 @@ def get( ) client.subscriptions.get( subscription_id="subscription_id", + include="include", ) """ _response = self._raw_client.get(subscription_id, include=include, request_options=request_options) @@ -578,6 +579,8 @@ def list_events( ) response = client.subscriptions.list_events( subscription_id="subscription_id", + cursor="cursor", + limit=1, ) for item in response: yield item @@ -1125,6 +1128,7 @@ async def get( async def main() -> None: await client.subscriptions.get( subscription_id="subscription_id", + include="include", ) @@ -1387,6 +1391,8 @@ async def list_events( async def main() -> None: response = await client.subscriptions.list_events( subscription_id="subscription_id", + cursor="cursor", + limit=1, ) async for item in response: yield item diff --git a/src/square/team/client.py b/src/square/team/client.py index 9cf26420..00da1e88 100644 --- a/src/square/team/client.py +++ b/src/square/team/client.py @@ -58,7 +58,9 @@ def list_jobs( client = Square( token="YOUR_TOKEN", ) - client.team.list_jobs() + client.team.list_jobs( + cursor="cursor", + ) """ _response = self._raw_client.list_jobs(cursor=cursor, request_options=request_options) return _response.data @@ -227,7 +229,9 @@ async def list_jobs( async def main() -> None: - await client.team.list_jobs() + await client.team.list_jobs( + cursor="cursor", + ) asyncio.run(main()) diff --git a/src/square/team_members/__init__.py b/src/square/team_members/__init__.py index 6b947428..9ab60957 100644 --- a/src/square/team_members/__init__.py +++ b/src/square/team_members/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import wage_setting +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import wage_setting +_dynamic_imports: typing.Dict[str, str] = {"wage_setting": ".wage_setting"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["wage_setting"] diff --git a/src/square/team_members/client.py b/src/square/team_members/client.py index 7a684670..9dc0559c 100644 --- a/src/square/team_members/client.py +++ b/src/square/team_members/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -15,8 +17,9 @@ from ..types.search_team_members_response import SearchTeamMembersResponse from ..types.update_team_member_response import UpdateTeamMemberResponse from .raw_client import AsyncRawTeamMembersClient, RawTeamMembersClient -from .wage_setting.client import AsyncWageSettingClient, WageSettingClient +if typing.TYPE_CHECKING: + from .wage_setting.client import AsyncWageSettingClient, WageSettingClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -24,7 +27,8 @@ class TeamMembersClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawTeamMembersClient(client_wrapper=client_wrapper) - self.wage_setting = WageSettingClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._wage_setting: typing.Optional[WageSettingClient] = None @property def with_raw_response(self) -> RawTeamMembersClient: @@ -416,11 +420,20 @@ def update( _response = self._raw_client.update(team_member_id, team_member=team_member, request_options=request_options) return _response.data + @property + def wage_setting(self): + if self._wage_setting is None: + from .wage_setting.client import WageSettingClient # noqa: E402 + + self._wage_setting = WageSettingClient(client_wrapper=self._client_wrapper) + return self._wage_setting + class AsyncTeamMembersClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawTeamMembersClient(client_wrapper=client_wrapper) - self.wage_setting = AsyncWageSettingClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._wage_setting: typing.Optional[AsyncWageSettingClient] = None @property def with_raw_response(self) -> AsyncRawTeamMembersClient: @@ -865,3 +878,11 @@ async def main() -> None: team_member_id, team_member=team_member, request_options=request_options ) return _response.data + + @property + def wage_setting(self): + if self._wage_setting is None: + from .wage_setting.client import AsyncWageSettingClient # noqa: E402 + + self._wage_setting = AsyncWageSettingClient(client_wrapper=self._client_wrapper) + return self._wage_setting diff --git a/src/square/terminal/__init__.py b/src/square/terminal/__init__.py index 78b5601e..0f6c8376 100644 --- a/src/square/terminal/__init__.py +++ b/src/square/terminal/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import actions, checkouts, refunds +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import actions, checkouts, refunds +_dynamic_imports: typing.Dict[str, str] = {"actions": ".actions", "checkouts": ".checkouts", "refunds": ".refunds"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["actions", "checkouts", "refunds"] diff --git a/src/square/terminal/client.py b/src/square/terminal/client.py index a60488ee..2f71f21b 100644 --- a/src/square/terminal/client.py +++ b/src/square/terminal/client.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -7,20 +9,21 @@ from ..types.dismiss_terminal_action_response import DismissTerminalActionResponse from ..types.dismiss_terminal_checkout_response import DismissTerminalCheckoutResponse from ..types.dismiss_terminal_refund_response import DismissTerminalRefundResponse -from .actions.client import ActionsClient, AsyncActionsClient -from .checkouts.client import AsyncCheckoutsClient, CheckoutsClient from .raw_client import AsyncRawTerminalClient, RawTerminalClient -from .refunds.client import AsyncRefundsClient, RefundsClient + +if typing.TYPE_CHECKING: + from .actions.client import ActionsClient, AsyncActionsClient + from .checkouts.client import AsyncCheckoutsClient, CheckoutsClient + from .refunds.client import AsyncRefundsClient, RefundsClient class TerminalClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawTerminalClient(client_wrapper=client_wrapper) - self.actions = ActionsClient(client_wrapper=client_wrapper) - - self.checkouts = CheckoutsClient(client_wrapper=client_wrapper) - - self.refunds = RefundsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._actions: typing.Optional[ActionsClient] = None + self._checkouts: typing.Optional[CheckoutsClient] = None + self._refunds: typing.Optional[RefundsClient] = None @property def with_raw_response(self) -> RawTerminalClient: @@ -134,15 +137,38 @@ def dismiss_terminal_refund( _response = self._raw_client.dismiss_terminal_refund(terminal_refund_id, request_options=request_options) return _response.data + @property + def actions(self): + if self._actions is None: + from .actions.client import ActionsClient # noqa: E402 + + self._actions = ActionsClient(client_wrapper=self._client_wrapper) + return self._actions + + @property + def checkouts(self): + if self._checkouts is None: + from .checkouts.client import CheckoutsClient # noqa: E402 + + self._checkouts = CheckoutsClient(client_wrapper=self._client_wrapper) + return self._checkouts + + @property + def refunds(self): + if self._refunds is None: + from .refunds.client import RefundsClient # noqa: E402 + + self._refunds = RefundsClient(client_wrapper=self._client_wrapper) + return self._refunds + class AsyncTerminalClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawTerminalClient(client_wrapper=client_wrapper) - self.actions = AsyncActionsClient(client_wrapper=client_wrapper) - - self.checkouts = AsyncCheckoutsClient(client_wrapper=client_wrapper) - - self.refunds = AsyncRefundsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._actions: typing.Optional[AsyncActionsClient] = None + self._checkouts: typing.Optional[AsyncCheckoutsClient] = None + self._refunds: typing.Optional[AsyncRefundsClient] = None @property def with_raw_response(self) -> AsyncRawTerminalClient: @@ -279,3 +305,27 @@ async def main() -> None: """ _response = await self._raw_client.dismiss_terminal_refund(terminal_refund_id, request_options=request_options) return _response.data + + @property + def actions(self): + if self._actions is None: + from .actions.client import AsyncActionsClient # noqa: E402 + + self._actions = AsyncActionsClient(client_wrapper=self._client_wrapper) + return self._actions + + @property + def checkouts(self): + if self._checkouts is None: + from .checkouts.client import AsyncCheckoutsClient # noqa: E402 + + self._checkouts = AsyncCheckoutsClient(client_wrapper=self._client_wrapper) + return self._checkouts + + @property + def refunds(self): + if self._refunds is None: + from .refunds.client import AsyncRefundsClient # noqa: E402 + + self._refunds = AsyncRefundsClient(client_wrapper=self._client_wrapper) + return self._refunds diff --git a/src/square/transfer_orders/__init__.py b/src/square/transfer_orders/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/square/transfer_orders/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/square/transfer_orders/client.py b/src/square/transfer_orders/client.py new file mode 100644 index 00000000..e3caacd7 --- /dev/null +++ b/src/square/transfer_orders/client.py @@ -0,0 +1,1122 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.pagination import AsyncPager, SyncPager +from ..core.request_options import RequestOptions +from ..requests.create_transfer_order_data import CreateTransferOrderDataParams +from ..requests.transfer_order_goods_receipt import TransferOrderGoodsReceiptParams +from ..requests.transfer_order_query import TransferOrderQueryParams +from ..requests.update_transfer_order_data import UpdateTransferOrderDataParams +from ..types.cancel_transfer_order_response import CancelTransferOrderResponse +from ..types.create_transfer_order_response import CreateTransferOrderResponse +from ..types.delete_transfer_order_response import DeleteTransferOrderResponse +from ..types.receive_transfer_order_response import ReceiveTransferOrderResponse +from ..types.retrieve_transfer_order_response import RetrieveTransferOrderResponse +from ..types.start_transfer_order_response import StartTransferOrderResponse +from ..types.transfer_order import TransferOrder +from ..types.update_transfer_order_response import UpdateTransferOrderResponse +from .raw_client import AsyncRawTransferOrdersClient, RawTransferOrdersClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class TransferOrdersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawTransferOrdersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawTransferOrdersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawTransferOrdersClient + """ + return self._raw_client + + def create( + self, + *, + idempotency_key: str, + transfer_order: CreateTransferOrderDataParams, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreateTransferOrderResponse: + """ + Creates a new transfer order in [DRAFT](entity:TransferOrderStatus) status. A transfer order represents the intent + to move [CatalogItemVariation](entity:CatalogItemVariation)s from one [Location](entity:Location) to another. + The source and destination locations must be different and must belong to your Square account. + + In [DRAFT](entity:TransferOrderStatus) status, you can: + - Add or remove items + - Modify quantities + - Update shipping information + - Delete the entire order via [DeleteTransferOrder](api-endpoint:TransferOrders-DeleteTransferOrder) + + The request requires source_location_id and destination_location_id. + Inventory levels are not affected until the order is started via + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder). + + Common integration points: + - Sync with warehouse management systems + - Automate regular stock transfers + - Initialize transfers from inventory optimization systems + + Creates a [transfer_order.created](webhook:transfer_order.created) webhook event. + + Parameters + ---------- + idempotency_key : str + A unique string that identifies this CreateTransferOrder request. Keys can be + any valid string but must be unique for every CreateTransferOrder request. + + transfer_order : CreateTransferOrderDataParams + The transfer order to create + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreateTransferOrderResponse + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + client.transfer_orders.create( + idempotency_key="65cc0586-3e82-384s-b524-3885cffd52", + transfer_order={ + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "expected_at": "2025-11-09T05:00:00Z", + "notes": "Example transfer order for inventory redistribution between locations", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5", + }, + { + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "3", + }, + ], + }, + ) + """ + _response = self._raw_client.create( + idempotency_key=idempotency_key, transfer_order=transfer_order, request_options=request_options + ) + return _response.data + + def search( + self, + *, + query: typing.Optional[TransferOrderQueryParams] = OMIT, + cursor: typing.Optional[str] = OMIT, + limit: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[TransferOrder]: + """ + Searches for transfer orders using filters. Returns a paginated list of matching + [TransferOrder](entity:TransferOrder)s sorted by creation date. + + Common search scenarios: + - Find orders for a source [Location](entity:Location) + - Find orders for a destination [Location](entity:Location) + - Find orders in a particular [TransferOrderStatus](entity:TransferOrderStatus) + + Parameters + ---------- + query : typing.Optional[TransferOrderQueryParams] + The search query + + cursor : typing.Optional[str] + Pagination cursor from a previous search response + + limit : typing.Optional[int] + Maximum number of results to return (1-100) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[TransferOrder] + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + response = client.transfer_orders.search( + query={ + "filter": { + "source_location_ids": ["EXAMPLE_SOURCE_LOCATION_ID_123"], + "destination_location_ids": ["EXAMPLE_DEST_LOCATION_ID_456"], + "statuses": ["STARTED", "PARTIALLY_RECEIVED"], + }, + "sort": {"field": "UPDATED_AT", "order": "DESC"}, + }, + cursor="eyJsYXN0X3VwZGF0ZWRfYXQiOjE3NTMxMTg2NjQ4NzN9", + limit=10, + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.search(query=query, cursor=cursor, limit=limit, request_options=request_options) + + def get( + self, transfer_order_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> RetrieveTransferOrderResponse: + """ + Retrieves a specific [TransferOrder](entity:TransferOrder) by ID. Returns the complete + order details including: + + - Basic information (status, dates, notes) + - Line items with ordered and received quantities + - Source and destination [Location](entity:Location)s + - Tracking information (if available) + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to retrieve + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + RetrieveTransferOrderResponse + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + client.transfer_orders.get( + transfer_order_id="transfer_order_id", + ) + """ + _response = self._raw_client.get(transfer_order_id, request_options=request_options) + return _response.data + + def update( + self, + transfer_order_id: str, + *, + idempotency_key: str, + transfer_order: UpdateTransferOrderDataParams, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdateTransferOrderResponse: + """ + Updates an existing transfer order. This endpoint supports sparse updates, + allowing you to modify specific fields without affecting others. + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to update + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores + + transfer_order : UpdateTransferOrderDataParams + The transfer order updates to apply + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdateTransferOrderResponse + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + client.transfer_orders.update( + transfer_order_id="transfer_order_id", + idempotency_key="f47ac10b-58cc-4372-a567-0e02b2c3d479", + transfer_order={ + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_789", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_101", + "expected_at": "2025-11-10T08:00:00Z", + "notes": "Updated: Priority transfer due to low stock at destination", + "tracking_number": "TRACK987654321", + "line_items": [ + {"uid": "1", "quantity_ordered": "7"}, + { + "item_variation_id": "EXAMPLE_NEW_ITEM_VARIATION_ID_003", + "quantity_ordered": "2", + }, + {"uid": "2", "remove": True}, + ], + }, + version=1753109537351, + ) + """ + _response = self._raw_client.update( + transfer_order_id, + idempotency_key=idempotency_key, + transfer_order=transfer_order, + version=version, + request_options=request_options, + ) + return _response.data + + def delete( + self, + transfer_order_id: str, + *, + version: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> DeleteTransferOrderResponse: + """ + Deletes a transfer order in [DRAFT](entity:TransferOrderStatus) status. + Only draft orders can be deleted. Once an order is started via + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder), it can no longer be deleted. + + Creates a [transfer_order.deleted](webhook:transfer_order.deleted) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to delete + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteTransferOrderResponse + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + client.transfer_orders.delete( + transfer_order_id="transfer_order_id", + version=1000000, + ) + """ + _response = self._raw_client.delete(transfer_order_id, version=version, request_options=request_options) + return _response.data + + def cancel( + self, + transfer_order_id: str, + *, + idempotency_key: str, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CancelTransferOrderResponse: + """ + Cancels a transfer order in [STARTED](entity:TransferOrderStatus) or + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. Any unreceived quantities will no + longer be receivable and will be immediately returned to the source [Location](entity:Location)'s inventory. + + Common reasons for cancellation: + - Items no longer needed at destination + - Source location needs the inventory + - Order created in error + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status. + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys can be + any valid string but must be unique for every UpdateTransferOrder request. + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CancelTransferOrderResponse + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + client.transfer_orders.cancel( + transfer_order_id="transfer_order_id", + idempotency_key="65cc0586-3e82-4d08-b524-3885cffd52", + version=1753117449752, + ) + """ + _response = self._raw_client.cancel( + transfer_order_id, idempotency_key=idempotency_key, version=version, request_options=request_options + ) + return _response.data + + def receive( + self, + transfer_order_id: str, + *, + idempotency_key: str, + receipt: TransferOrderGoodsReceiptParams, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiveTransferOrderResponse: + """ + Records receipt of [CatalogItemVariation](entity:CatalogItemVariation)s for a transfer order. + This endpoint supports partial receiving - you can receive items in multiple batches. + + For each line item, you can specify: + - Quantity received in good condition (added to destination inventory with [InventoryState](entity:InventoryState) of IN_STOCK) + - Quantity damaged during transit/handling (added to destination inventory with [InventoryState](entity:InventoryState) of WASTE) + - Quantity canceled (returned to source location's inventory) + + The order must be in [STARTED](entity:TransferOrderStatus) or [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. + Received quantities are added to the destination [Location](entity:Location)'s inventory according to their condition. + Canceled quantities are immediately returned to the source [Location](entity:Location)'s inventory. + + When all items are either received, damaged, or canceled, the order moves to + [COMPLETED](entity:TransferOrderStatus) status. + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to receive items for + + idempotency_key : str + A unique key to make this request idempotent + + receipt : TransferOrderGoodsReceiptParams + The receipt details + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiveTransferOrderResponse + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + client.transfer_orders.receive( + transfer_order_id="transfer_order_id", + idempotency_key="EXAMPLE_IDEMPOTENCY_KEY_101", + receipt={ + "line_items": [ + { + "transfer_order_line_uid": "transfer_order_line_uid", + "quantity_received": "3", + "quantity_damaged": "1", + "quantity_canceled": "1", + }, + { + "transfer_order_line_uid": "transfer_order_line_uid", + "quantity_received": "2", + "quantity_canceled": "1", + }, + ] + }, + version=1753118664873, + ) + """ + _response = self._raw_client.receive( + transfer_order_id, + idempotency_key=idempotency_key, + receipt=receipt, + version=version, + request_options=request_options, + ) + return _response.data + + def start( + self, + transfer_order_id: str, + *, + idempotency_key: str, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> StartTransferOrderResponse: + """ + Changes a [DRAFT](entity:TransferOrderStatus) transfer order to [STARTED](entity:TransferOrderStatus) status. + This decrements inventory at the source [Location](entity:Location) and marks it as in-transit. + + The order must be in [DRAFT](entity:TransferOrderStatus) status and have all required fields populated. + Once started, the order can no longer be deleted, but it can be canceled via + [CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to start. Must be in DRAFT status. + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys can be + any valid string but must be unique for every UpdateTransferOrder request. + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + StartTransferOrderResponse + Success + + Examples + -------- + from square import Square + + client = Square( + token="YOUR_TOKEN", + ) + client.transfer_orders.start( + transfer_order_id="transfer_order_id", + idempotency_key="EXAMPLE_IDEMPOTENCY_KEY_789", + version=1753109537351, + ) + """ + _response = self._raw_client.start( + transfer_order_id, idempotency_key=idempotency_key, version=version, request_options=request_options + ) + return _response.data + + +class AsyncTransferOrdersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawTransferOrdersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawTransferOrdersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawTransferOrdersClient + """ + return self._raw_client + + async def create( + self, + *, + idempotency_key: str, + transfer_order: CreateTransferOrderDataParams, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreateTransferOrderResponse: + """ + Creates a new transfer order in [DRAFT](entity:TransferOrderStatus) status. A transfer order represents the intent + to move [CatalogItemVariation](entity:CatalogItemVariation)s from one [Location](entity:Location) to another. + The source and destination locations must be different and must belong to your Square account. + + In [DRAFT](entity:TransferOrderStatus) status, you can: + - Add or remove items + - Modify quantities + - Update shipping information + - Delete the entire order via [DeleteTransferOrder](api-endpoint:TransferOrders-DeleteTransferOrder) + + The request requires source_location_id and destination_location_id. + Inventory levels are not affected until the order is started via + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder). + + Common integration points: + - Sync with warehouse management systems + - Automate regular stock transfers + - Initialize transfers from inventory optimization systems + + Creates a [transfer_order.created](webhook:transfer_order.created) webhook event. + + Parameters + ---------- + idempotency_key : str + A unique string that identifies this CreateTransferOrder request. Keys can be + any valid string but must be unique for every CreateTransferOrder request. + + transfer_order : CreateTransferOrderDataParams + The transfer order to create + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreateTransferOrderResponse + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.transfer_orders.create( + idempotency_key="65cc0586-3e82-384s-b524-3885cffd52", + transfer_order={ + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "expected_at": "2025-11-09T05:00:00Z", + "notes": "Example transfer order for inventory redistribution between locations", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5", + }, + { + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "3", + }, + ], + }, + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + idempotency_key=idempotency_key, transfer_order=transfer_order, request_options=request_options + ) + return _response.data + + async def search( + self, + *, + query: typing.Optional[TransferOrderQueryParams] = OMIT, + cursor: typing.Optional[str] = OMIT, + limit: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[TransferOrder]: + """ + Searches for transfer orders using filters. Returns a paginated list of matching + [TransferOrder](entity:TransferOrder)s sorted by creation date. + + Common search scenarios: + - Find orders for a source [Location](entity:Location) + - Find orders for a destination [Location](entity:Location) + - Find orders in a particular [TransferOrderStatus](entity:TransferOrderStatus) + + Parameters + ---------- + query : typing.Optional[TransferOrderQueryParams] + The search query + + cursor : typing.Optional[str] + Pagination cursor from a previous search response + + limit : typing.Optional[int] + Maximum number of results to return (1-100) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[TransferOrder] + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.transfer_orders.search( + query={ + "filter": { + "source_location_ids": ["EXAMPLE_SOURCE_LOCATION_ID_123"], + "destination_location_ids": ["EXAMPLE_DEST_LOCATION_ID_456"], + "statuses": ["STARTED", "PARTIALLY_RECEIVED"], + }, + "sort": {"field": "UPDATED_AT", "order": "DESC"}, + }, + cursor="eyJsYXN0X3VwZGF0ZWRfYXQiOjE3NTMxMTg2NjQ4NzN9", + limit=10, + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.search(query=query, cursor=cursor, limit=limit, request_options=request_options) + + async def get( + self, transfer_order_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> RetrieveTransferOrderResponse: + """ + Retrieves a specific [TransferOrder](entity:TransferOrder) by ID. Returns the complete + order details including: + + - Basic information (status, dates, notes) + - Line items with ordered and received quantities + - Source and destination [Location](entity:Location)s + - Tracking information (if available) + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to retrieve + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + RetrieveTransferOrderResponse + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.transfer_orders.get( + transfer_order_id="transfer_order_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(transfer_order_id, request_options=request_options) + return _response.data + + async def update( + self, + transfer_order_id: str, + *, + idempotency_key: str, + transfer_order: UpdateTransferOrderDataParams, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdateTransferOrderResponse: + """ + Updates an existing transfer order. This endpoint supports sparse updates, + allowing you to modify specific fields without affecting others. + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to update + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores + + transfer_order : UpdateTransferOrderDataParams + The transfer order updates to apply + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdateTransferOrderResponse + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.transfer_orders.update( + transfer_order_id="transfer_order_id", + idempotency_key="f47ac10b-58cc-4372-a567-0e02b2c3d479", + transfer_order={ + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_789", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_101", + "expected_at": "2025-11-10T08:00:00Z", + "notes": "Updated: Priority transfer due to low stock at destination", + "tracking_number": "TRACK987654321", + "line_items": [ + {"uid": "1", "quantity_ordered": "7"}, + { + "item_variation_id": "EXAMPLE_NEW_ITEM_VARIATION_ID_003", + "quantity_ordered": "2", + }, + {"uid": "2", "remove": True}, + ], + }, + version=1753109537351, + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update( + transfer_order_id, + idempotency_key=idempotency_key, + transfer_order=transfer_order, + version=version, + request_options=request_options, + ) + return _response.data + + async def delete( + self, + transfer_order_id: str, + *, + version: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> DeleteTransferOrderResponse: + """ + Deletes a transfer order in [DRAFT](entity:TransferOrderStatus) status. + Only draft orders can be deleted. Once an order is started via + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder), it can no longer be deleted. + + Creates a [transfer_order.deleted](webhook:transfer_order.deleted) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to delete + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteTransferOrderResponse + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.transfer_orders.delete( + transfer_order_id="transfer_order_id", + version=1000000, + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(transfer_order_id, version=version, request_options=request_options) + return _response.data + + async def cancel( + self, + transfer_order_id: str, + *, + idempotency_key: str, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CancelTransferOrderResponse: + """ + Cancels a transfer order in [STARTED](entity:TransferOrderStatus) or + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. Any unreceived quantities will no + longer be receivable and will be immediately returned to the source [Location](entity:Location)'s inventory. + + Common reasons for cancellation: + - Items no longer needed at destination + - Source location needs the inventory + - Order created in error + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status. + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys can be + any valid string but must be unique for every UpdateTransferOrder request. + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CancelTransferOrderResponse + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.transfer_orders.cancel( + transfer_order_id="transfer_order_id", + idempotency_key="65cc0586-3e82-4d08-b524-3885cffd52", + version=1753117449752, + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.cancel( + transfer_order_id, idempotency_key=idempotency_key, version=version, request_options=request_options + ) + return _response.data + + async def receive( + self, + transfer_order_id: str, + *, + idempotency_key: str, + receipt: TransferOrderGoodsReceiptParams, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ReceiveTransferOrderResponse: + """ + Records receipt of [CatalogItemVariation](entity:CatalogItemVariation)s for a transfer order. + This endpoint supports partial receiving - you can receive items in multiple batches. + + For each line item, you can specify: + - Quantity received in good condition (added to destination inventory with [InventoryState](entity:InventoryState) of IN_STOCK) + - Quantity damaged during transit/handling (added to destination inventory with [InventoryState](entity:InventoryState) of WASTE) + - Quantity canceled (returned to source location's inventory) + + The order must be in [STARTED](entity:TransferOrderStatus) or [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. + Received quantities are added to the destination [Location](entity:Location)'s inventory according to their condition. + Canceled quantities are immediately returned to the source [Location](entity:Location)'s inventory. + + When all items are either received, damaged, or canceled, the order moves to + [COMPLETED](entity:TransferOrderStatus) status. + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to receive items for + + idempotency_key : str + A unique key to make this request idempotent + + receipt : TransferOrderGoodsReceiptParams + The receipt details + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ReceiveTransferOrderResponse + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.transfer_orders.receive( + transfer_order_id="transfer_order_id", + idempotency_key="EXAMPLE_IDEMPOTENCY_KEY_101", + receipt={ + "line_items": [ + { + "transfer_order_line_uid": "transfer_order_line_uid", + "quantity_received": "3", + "quantity_damaged": "1", + "quantity_canceled": "1", + }, + { + "transfer_order_line_uid": "transfer_order_line_uid", + "quantity_received": "2", + "quantity_canceled": "1", + }, + ] + }, + version=1753118664873, + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.receive( + transfer_order_id, + idempotency_key=idempotency_key, + receipt=receipt, + version=version, + request_options=request_options, + ) + return _response.data + + async def start( + self, + transfer_order_id: str, + *, + idempotency_key: str, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> StartTransferOrderResponse: + """ + Changes a [DRAFT](entity:TransferOrderStatus) transfer order to [STARTED](entity:TransferOrderStatus) status. + This decrements inventory at the source [Location](entity:Location) and marks it as in-transit. + + The order must be in [DRAFT](entity:TransferOrderStatus) status and have all required fields populated. + Once started, the order can no longer be deleted, but it can be canceled via + [CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to start. Must be in DRAFT status. + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys can be + any valid string but must be unique for every UpdateTransferOrder request. + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + StartTransferOrderResponse + Success + + Examples + -------- + import asyncio + + from square import AsyncSquare + + client = AsyncSquare( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.transfer_orders.start( + transfer_order_id="transfer_order_id", + idempotency_key="EXAMPLE_IDEMPOTENCY_KEY_789", + version=1753109537351, + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.start( + transfer_order_id, idempotency_key=idempotency_key, version=version, request_options=request_options + ) + return _response.data diff --git a/src/square/transfer_orders/raw_client.py b/src/square/transfer_orders/raw_client.py new file mode 100644 index 00000000..f6e8c471 --- /dev/null +++ b/src/square/transfer_orders/raw_client.py @@ -0,0 +1,1110 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.pagination import AsyncPager, BaseHttpResponse, SyncPager +from ..core.request_options import RequestOptions +from ..core.serialization import convert_and_respect_annotation_metadata +from ..core.unchecked_base_model import construct_type +from ..requests.create_transfer_order_data import CreateTransferOrderDataParams +from ..requests.transfer_order_goods_receipt import TransferOrderGoodsReceiptParams +from ..requests.transfer_order_query import TransferOrderQueryParams +from ..requests.update_transfer_order_data import UpdateTransferOrderDataParams +from ..types.cancel_transfer_order_response import CancelTransferOrderResponse +from ..types.create_transfer_order_response import CreateTransferOrderResponse +from ..types.delete_transfer_order_response import DeleteTransferOrderResponse +from ..types.receive_transfer_order_response import ReceiveTransferOrderResponse +from ..types.retrieve_transfer_order_response import RetrieveTransferOrderResponse +from ..types.search_transfer_orders_response import SearchTransferOrdersResponse +from ..types.start_transfer_order_response import StartTransferOrderResponse +from ..types.transfer_order import TransferOrder +from ..types.update_transfer_order_response import UpdateTransferOrderResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawTransferOrdersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + idempotency_key: str, + transfer_order: CreateTransferOrderDataParams, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[CreateTransferOrderResponse]: + """ + Creates a new transfer order in [DRAFT](entity:TransferOrderStatus) status. A transfer order represents the intent + to move [CatalogItemVariation](entity:CatalogItemVariation)s from one [Location](entity:Location) to another. + The source and destination locations must be different and must belong to your Square account. + + In [DRAFT](entity:TransferOrderStatus) status, you can: + - Add or remove items + - Modify quantities + - Update shipping information + - Delete the entire order via [DeleteTransferOrder](api-endpoint:TransferOrders-DeleteTransferOrder) + + The request requires source_location_id and destination_location_id. + Inventory levels are not affected until the order is started via + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder). + + Common integration points: + - Sync with warehouse management systems + - Automate regular stock transfers + - Initialize transfers from inventory optimization systems + + Creates a [transfer_order.created](webhook:transfer_order.created) webhook event. + + Parameters + ---------- + idempotency_key : str + A unique string that identifies this CreateTransferOrder request. Keys can be + any valid string but must be unique for every CreateTransferOrder request. + + transfer_order : CreateTransferOrderDataParams + The transfer order to create + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CreateTransferOrderResponse] + Success + """ + _response = self._client_wrapper.httpx_client.request( + "v2/transfer-orders", + method="POST", + json={ + "idempotency_key": idempotency_key, + "transfer_order": convert_and_respect_annotation_metadata( + object_=transfer_order, annotation=CreateTransferOrderDataParams, direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateTransferOrderResponse, + construct_type( + type_=CreateTransferOrderResponse, # 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 search( + self, + *, + query: typing.Optional[TransferOrderQueryParams] = OMIT, + cursor: typing.Optional[str] = OMIT, + limit: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[TransferOrder]: + """ + Searches for transfer orders using filters. Returns a paginated list of matching + [TransferOrder](entity:TransferOrder)s sorted by creation date. + + Common search scenarios: + - Find orders for a source [Location](entity:Location) + - Find orders for a destination [Location](entity:Location) + - Find orders in a particular [TransferOrderStatus](entity:TransferOrderStatus) + + Parameters + ---------- + query : typing.Optional[TransferOrderQueryParams] + The search query + + cursor : typing.Optional[str] + Pagination cursor from a previous search response + + limit : typing.Optional[int] + Maximum number of results to return (1-100) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[TransferOrder] + Success + """ + _response = self._client_wrapper.httpx_client.request( + "v2/transfer-orders/search", + method="POST", + json={ + "query": convert_and_respect_annotation_metadata( + object_=query, annotation=TransferOrderQueryParams, direction="write" + ), + "cursor": cursor, + "limit": limit, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + SearchTransferOrdersResponse, + construct_type( + type_=SearchTransferOrdersResponse, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.transfer_orders + _parsed_next = _parsed_response.cursor + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.search( + query=query, + cursor=_parsed_next, + limit=limit, + request_options=request_options, + ) + return SyncPager( + has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response) + ) + _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 get( + self, transfer_order_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[RetrieveTransferOrderResponse]: + """ + Retrieves a specific [TransferOrder](entity:TransferOrder) by ID. Returns the complete + order details including: + + - Basic information (status, dates, notes) + - Line items with ordered and received quantities + - Source and destination [Location](entity:Location)s + - Tracking information (if available) + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to retrieve + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[RetrieveTransferOrderResponse] + Success + """ + _response = self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RetrieveTransferOrderResponse, + construct_type( + type_=RetrieveTransferOrderResponse, # 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 update( + self, + transfer_order_id: str, + *, + idempotency_key: str, + transfer_order: UpdateTransferOrderDataParams, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[UpdateTransferOrderResponse]: + """ + Updates an existing transfer order. This endpoint supports sparse updates, + allowing you to modify specific fields without affecting others. + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to update + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores + + transfer_order : UpdateTransferOrderDataParams + The transfer order updates to apply + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[UpdateTransferOrderResponse] + Success + """ + _response = self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}", + method="PUT", + json={ + "idempotency_key": idempotency_key, + "transfer_order": convert_and_respect_annotation_metadata( + object_=transfer_order, annotation=UpdateTransferOrderDataParams, direction="write" + ), + "version": version, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UpdateTransferOrderResponse, + construct_type( + type_=UpdateTransferOrderResponse, # 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 delete( + self, + transfer_order_id: str, + *, + version: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[DeleteTransferOrderResponse]: + """ + Deletes a transfer order in [DRAFT](entity:TransferOrderStatus) status. + Only draft orders can be deleted. Once an order is started via + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder), it can no longer be deleted. + + Creates a [transfer_order.deleted](webhook:transfer_order.deleted) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to delete + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteTransferOrderResponse] + Success + """ + _response = self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}", + method="DELETE", + params={ + "version": version, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteTransferOrderResponse, + construct_type( + type_=DeleteTransferOrderResponse, # 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 cancel( + self, + transfer_order_id: str, + *, + idempotency_key: str, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[CancelTransferOrderResponse]: + """ + Cancels a transfer order in [STARTED](entity:TransferOrderStatus) or + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. Any unreceived quantities will no + longer be receivable and will be immediately returned to the source [Location](entity:Location)'s inventory. + + Common reasons for cancellation: + - Items no longer needed at destination + - Source location needs the inventory + - Order created in error + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status. + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys can be + any valid string but must be unique for every UpdateTransferOrder request. + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CancelTransferOrderResponse] + Success + """ + _response = self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}/cancel", + method="POST", + json={ + "idempotency_key": idempotency_key, + "version": version, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelTransferOrderResponse, + construct_type( + type_=CancelTransferOrderResponse, # 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 receive( + self, + transfer_order_id: str, + *, + idempotency_key: str, + receipt: TransferOrderGoodsReceiptParams, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ReceiveTransferOrderResponse]: + """ + Records receipt of [CatalogItemVariation](entity:CatalogItemVariation)s for a transfer order. + This endpoint supports partial receiving - you can receive items in multiple batches. + + For each line item, you can specify: + - Quantity received in good condition (added to destination inventory with [InventoryState](entity:InventoryState) of IN_STOCK) + - Quantity damaged during transit/handling (added to destination inventory with [InventoryState](entity:InventoryState) of WASTE) + - Quantity canceled (returned to source location's inventory) + + The order must be in [STARTED](entity:TransferOrderStatus) or [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. + Received quantities are added to the destination [Location](entity:Location)'s inventory according to their condition. + Canceled quantities are immediately returned to the source [Location](entity:Location)'s inventory. + + When all items are either received, damaged, or canceled, the order moves to + [COMPLETED](entity:TransferOrderStatus) status. + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to receive items for + + idempotency_key : str + A unique key to make this request idempotent + + receipt : TransferOrderGoodsReceiptParams + The receipt details + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ReceiveTransferOrderResponse] + Success + """ + _response = self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}/receive", + method="POST", + json={ + "idempotency_key": idempotency_key, + "receipt": convert_and_respect_annotation_metadata( + object_=receipt, annotation=TransferOrderGoodsReceiptParams, direction="write" + ), + "version": version, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiveTransferOrderResponse, + construct_type( + type_=ReceiveTransferOrderResponse, # 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 start( + self, + transfer_order_id: str, + *, + idempotency_key: str, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[StartTransferOrderResponse]: + """ + Changes a [DRAFT](entity:TransferOrderStatus) transfer order to [STARTED](entity:TransferOrderStatus) status. + This decrements inventory at the source [Location](entity:Location) and marks it as in-transit. + + The order must be in [DRAFT](entity:TransferOrderStatus) status and have all required fields populated. + Once started, the order can no longer be deleted, but it can be canceled via + [CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to start. Must be in DRAFT status. + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys can be + any valid string but must be unique for every UpdateTransferOrder request. + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[StartTransferOrderResponse] + Success + """ + _response = self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}/start", + method="POST", + json={ + "idempotency_key": idempotency_key, + "version": version, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + StartTransferOrderResponse, + construct_type( + type_=StartTransferOrderResponse, # 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 AsyncRawTransferOrdersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + idempotency_key: str, + transfer_order: CreateTransferOrderDataParams, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[CreateTransferOrderResponse]: + """ + Creates a new transfer order in [DRAFT](entity:TransferOrderStatus) status. A transfer order represents the intent + to move [CatalogItemVariation](entity:CatalogItemVariation)s from one [Location](entity:Location) to another. + The source and destination locations must be different and must belong to your Square account. + + In [DRAFT](entity:TransferOrderStatus) status, you can: + - Add or remove items + - Modify quantities + - Update shipping information + - Delete the entire order via [DeleteTransferOrder](api-endpoint:TransferOrders-DeleteTransferOrder) + + The request requires source_location_id and destination_location_id. + Inventory levels are not affected until the order is started via + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder). + + Common integration points: + - Sync with warehouse management systems + - Automate regular stock transfers + - Initialize transfers from inventory optimization systems + + Creates a [transfer_order.created](webhook:transfer_order.created) webhook event. + + Parameters + ---------- + idempotency_key : str + A unique string that identifies this CreateTransferOrder request. Keys can be + any valid string but must be unique for every CreateTransferOrder request. + + transfer_order : CreateTransferOrderDataParams + The transfer order to create + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CreateTransferOrderResponse] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + "v2/transfer-orders", + method="POST", + json={ + "idempotency_key": idempotency_key, + "transfer_order": convert_and_respect_annotation_metadata( + object_=transfer_order, annotation=CreateTransferOrderDataParams, direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateTransferOrderResponse, + construct_type( + type_=CreateTransferOrderResponse, # 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 search( + self, + *, + query: typing.Optional[TransferOrderQueryParams] = OMIT, + cursor: typing.Optional[str] = OMIT, + limit: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[TransferOrder]: + """ + Searches for transfer orders using filters. Returns a paginated list of matching + [TransferOrder](entity:TransferOrder)s sorted by creation date. + + Common search scenarios: + - Find orders for a source [Location](entity:Location) + - Find orders for a destination [Location](entity:Location) + - Find orders in a particular [TransferOrderStatus](entity:TransferOrderStatus) + + Parameters + ---------- + query : typing.Optional[TransferOrderQueryParams] + The search query + + cursor : typing.Optional[str] + Pagination cursor from a previous search response + + limit : typing.Optional[int] + Maximum number of results to return (1-100) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[TransferOrder] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + "v2/transfer-orders/search", + method="POST", + json={ + "query": convert_and_respect_annotation_metadata( + object_=query, annotation=TransferOrderQueryParams, direction="write" + ), + "cursor": cursor, + "limit": limit, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + SearchTransferOrdersResponse, + construct_type( + type_=SearchTransferOrdersResponse, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.transfer_orders + _parsed_next = _parsed_response.cursor + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.search( + query=query, + cursor=_parsed_next, + limit=limit, + request_options=request_options, + ) + + return AsyncPager( + has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response) + ) + _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 get( + self, transfer_order_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[RetrieveTransferOrderResponse]: + """ + Retrieves a specific [TransferOrder](entity:TransferOrder) by ID. Returns the complete + order details including: + + - Basic information (status, dates, notes) + - Line items with ordered and received quantities + - Source and destination [Location](entity:Location)s + - Tracking information (if available) + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to retrieve + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[RetrieveTransferOrderResponse] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RetrieveTransferOrderResponse, + construct_type( + type_=RetrieveTransferOrderResponse, # 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 update( + self, + transfer_order_id: str, + *, + idempotency_key: str, + transfer_order: UpdateTransferOrderDataParams, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[UpdateTransferOrderResponse]: + """ + Updates an existing transfer order. This endpoint supports sparse updates, + allowing you to modify specific fields without affecting others. + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to update + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores + + transfer_order : UpdateTransferOrderDataParams + The transfer order updates to apply + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[UpdateTransferOrderResponse] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}", + method="PUT", + json={ + "idempotency_key": idempotency_key, + "transfer_order": convert_and_respect_annotation_metadata( + object_=transfer_order, annotation=UpdateTransferOrderDataParams, direction="write" + ), + "version": version, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UpdateTransferOrderResponse, + construct_type( + type_=UpdateTransferOrderResponse, # 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 delete( + self, + transfer_order_id: str, + *, + version: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[DeleteTransferOrderResponse]: + """ + Deletes a transfer order in [DRAFT](entity:TransferOrderStatus) status. + Only draft orders can be deleted. Once an order is started via + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder), it can no longer be deleted. + + Creates a [transfer_order.deleted](webhook:transfer_order.deleted) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to delete + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteTransferOrderResponse] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}", + method="DELETE", + params={ + "version": version, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteTransferOrderResponse, + construct_type( + type_=DeleteTransferOrderResponse, # 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 cancel( + self, + transfer_order_id: str, + *, + idempotency_key: str, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[CancelTransferOrderResponse]: + """ + Cancels a transfer order in [STARTED](entity:TransferOrderStatus) or + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. Any unreceived quantities will no + longer be receivable and will be immediately returned to the source [Location](entity:Location)'s inventory. + + Common reasons for cancellation: + - Items no longer needed at destination + - Source location needs the inventory + - Order created in error + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status. + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys can be + any valid string but must be unique for every UpdateTransferOrder request. + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CancelTransferOrderResponse] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}/cancel", + method="POST", + json={ + "idempotency_key": idempotency_key, + "version": version, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelTransferOrderResponse, + construct_type( + type_=CancelTransferOrderResponse, # 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 receive( + self, + transfer_order_id: str, + *, + idempotency_key: str, + receipt: TransferOrderGoodsReceiptParams, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ReceiveTransferOrderResponse]: + """ + Records receipt of [CatalogItemVariation](entity:CatalogItemVariation)s for a transfer order. + This endpoint supports partial receiving - you can receive items in multiple batches. + + For each line item, you can specify: + - Quantity received in good condition (added to destination inventory with [InventoryState](entity:InventoryState) of IN_STOCK) + - Quantity damaged during transit/handling (added to destination inventory with [InventoryState](entity:InventoryState) of WASTE) + - Quantity canceled (returned to source location's inventory) + + The order must be in [STARTED](entity:TransferOrderStatus) or [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. + Received quantities are added to the destination [Location](entity:Location)'s inventory according to their condition. + Canceled quantities are immediately returned to the source [Location](entity:Location)'s inventory. + + When all items are either received, damaged, or canceled, the order moves to + [COMPLETED](entity:TransferOrderStatus) status. + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to receive items for + + idempotency_key : str + A unique key to make this request idempotent + + receipt : TransferOrderGoodsReceiptParams + The receipt details + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ReceiveTransferOrderResponse] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}/receive", + method="POST", + json={ + "idempotency_key": idempotency_key, + "receipt": convert_and_respect_annotation_metadata( + object_=receipt, annotation=TransferOrderGoodsReceiptParams, direction="write" + ), + "version": version, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ReceiveTransferOrderResponse, + construct_type( + type_=ReceiveTransferOrderResponse, # 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 start( + self, + transfer_order_id: str, + *, + idempotency_key: str, + version: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[StartTransferOrderResponse]: + """ + Changes a [DRAFT](entity:TransferOrderStatus) transfer order to [STARTED](entity:TransferOrderStatus) status. + This decrements inventory at the source [Location](entity:Location) and marks it as in-transit. + + The order must be in [DRAFT](entity:TransferOrderStatus) status and have all required fields populated. + Once started, the order can no longer be deleted, but it can be canceled via + [CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + + Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. + + Parameters + ---------- + transfer_order_id : str + The ID of the transfer order to start. Must be in DRAFT status. + + idempotency_key : str + A unique string that identifies this UpdateTransferOrder request. Keys can be + any valid string but must be unique for every UpdateTransferOrder request. + + version : typing.Optional[int] + Version for optimistic concurrency + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[StartTransferOrderResponse] + Success + """ + _response = await self._client_wrapper.httpx_client.request( + f"v2/transfer-orders/{jsonable_encoder(transfer_order_id)}/start", + method="POST", + json={ + "idempotency_key": idempotency_key, + "version": version, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + StartTransferOrderResponse, + construct_type( + type_=StartTransferOrderResponse, # 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/types/bulk_retrieve_channels_request_constants.py b/src/square/types/bulk_retrieve_channels_request_constants.py new file mode 100644 index 00000000..16779a7d --- /dev/null +++ b/src/square/types/bulk_retrieve_channels_request_constants.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +BulkRetrieveChannelsRequestConstants = typing.Literal["MAX_BATCH_SIZE"] diff --git a/src/square/types/bulk_retrieve_channels_response.py b/src/square/types/bulk_retrieve_channels_response.py new file mode 100644 index 00000000..b448ef5f --- /dev/null +++ b/src/square/types/bulk_retrieve_channels_response.py @@ -0,0 +1,38 @@ +# 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 +from .retrieve_channel_response import RetrieveChannelResponse + + +class BulkRetrieveChannelsResponse(UncheckedBaseModel): + """ + Defines the fields that are included in the request body for the + [BulkRetrieveChannels](api-endpoint:Channels-BulkRetrieveChannels) endpoint. + """ + + errors: typing.Optional[typing.List[Error]] = pydantic.Field(default=None) + """ + Information about errors encountered during the request. + """ + + responses: typing.Optional[typing.Dict[str, RetrieveChannelResponse]] = pydantic.Field(default=None) + """ + A map of channel IDs to channel responses which tell whether + retrieval for a specific channel is success or not. + Channel response of a success retrieval would contain channel info + whereas channel response of a failed retrieval would have error info. + """ + + 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/cancel_transfer_order_response.py b/src/square/types/cancel_transfer_order_response.py new file mode 100644 index 00000000..26e2324f --- /dev/null +++ b/src/square/types/cancel_transfer_order_response.py @@ -0,0 +1,34 @@ +# 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 +from .transfer_order import TransferOrder + + +class CancelTransferOrderResponse(UncheckedBaseModel): + """ + Response for canceling a transfer order + """ + + transfer_order: typing.Optional[TransferOrder] = pydantic.Field(default=None) + """ + The updated transfer order with status changed to CANCELED + """ + + 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/channel.py b/src/square/types/channel.py new file mode 100644 index 00000000..4c34c585 --- /dev/null +++ b/src/square/types/channel.py @@ -0,0 +1,63 @@ +# 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 .channel_status import ChannelStatus +from .reference import Reference + + +class Channel(UncheckedBaseModel): + id: typing.Optional[str] = pydantic.Field(default=None) + """ + The channel's unique ID. + """ + + merchant_id: typing.Optional[str] = pydantic.Field(default=None) + """ + The unique ID of the merchant this channel belongs to. + """ + + name: typing.Optional[str] = pydantic.Field(default=None) + """ + The name of the channel. + """ + + version: typing.Optional[int] = pydantic.Field(default=None) + """ + The version number which is incremented each time an update is made to the channel. + """ + + reference: typing.Optional[Reference] = pydantic.Field(default=None) + """ + Represents an entity the channel is associated with. + """ + + status: typing.Optional[ChannelStatus] = pydantic.Field(default=None) + """ + Status of the channel. + See [Status](#type-status) for possible values + """ + + created_at: typing.Optional[str] = pydantic.Field(default=None) + """ + The timestamp for when the channel was created, in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). + For more information, see [Working with Dates](https://developer.squareup.com/docs/build-basics/working-with-dates). + """ + + updated_at: typing.Optional[str] = pydantic.Field(default=None) + """ + The timestamp for when the channel was last updated, in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). + For more information, see [Working with Dates](https://developer.squareup.com/docs/build-basics/working-with-dates). + """ + + 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/channel_status.py b/src/square/types/channel_status.py new file mode 100644 index 00000000..b3fd439d --- /dev/null +++ b/src/square/types/channel_status.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ChannelStatus = typing.Union[typing.Literal["ACTIVE", "INACTIVE"], typing.Any] diff --git a/src/square/types/create_transfer_order_data.py b/src/square/types/create_transfer_order_data.py new file mode 100644 index 00000000..4ef6be5c --- /dev/null +++ b/src/square/types/create_transfer_order_data.py @@ -0,0 +1,63 @@ +# 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 .create_transfer_order_line_data import CreateTransferOrderLineData + + +class CreateTransferOrderData(UncheckedBaseModel): + """ + Data for creating a new transfer order to move [CatalogItemVariation](entity:CatalogItemVariation)s + between [Location](entity:Location)s. Used with the [CreateTransferOrder](api-endpoint:TransferOrders-CreateTransferOrder) + endpoint. + """ + + source_location_id: str = pydantic.Field() + """ + The source [Location](entity:Location) that will send the items. Must be an active location + in your Square account with sufficient inventory of the requested items. + """ + + destination_location_id: str = pydantic.Field() + """ + The destination [Location](entity:Location) that will receive the items. Must be an active location + in your Square account + """ + + expected_at: typing.Optional[str] = pydantic.Field(default=None) + """ + Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z"). + """ + + notes: typing.Optional[str] = pydantic.Field(default=None) + """ + Optional notes about the transfer + """ + + tracking_number: typing.Optional[str] = pydantic.Field(default=None) + """ + Optional shipment tracking number + """ + + created_by_team_member_id: typing.Optional[str] = pydantic.Field(default=None) + """ + ID of the [TeamMember](entity:TeamMember) creating this transfer order. Used for tracking + and auditing purposes. + """ + + line_items: typing.Optional[typing.List[CreateTransferOrderLineData]] = pydantic.Field(default=None) + """ + List of [CatalogItemVariation](entity:CatalogItemVariation)s to transfer, including quantities + """ + + 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/create_transfer_order_line_data.py b/src/square/types/create_transfer_order_line_data.py new file mode 100644 index 00000000..7f874371 --- /dev/null +++ b/src/square/types/create_transfer_order_line_data.py @@ -0,0 +1,37 @@ +# 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 + + +class CreateTransferOrderLineData(UncheckedBaseModel): + """ + Data for creating a new transfer order line item. Each line item specifies a + [CatalogItemVariation](entity:CatalogItemVariation) and quantity to transfer. + """ + + item_variation_id: str = pydantic.Field() + """ + ID of the [CatalogItemVariation](entity:CatalogItemVariation) to transfer. Must reference a valid + item variation in the [Catalog](api:Catalog). The item variation must be: + - Active and available for sale + - Enabled for inventory tracking + - Available at the source location + """ + + quantity_ordered: str = pydantic.Field() + """ + Total quantity ordered + """ + + 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/create_transfer_order_response.py b/src/square/types/create_transfer_order_response.py new file mode 100644 index 00000000..d76169c5 --- /dev/null +++ b/src/square/types/create_transfer_order_response.py @@ -0,0 +1,34 @@ +# 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 +from .transfer_order import TransferOrder + + +class CreateTransferOrderResponse(UncheckedBaseModel): + """ + Response for creating a transfer order. + """ + + transfer_order: typing.Optional[TransferOrder] = pydantic.Field(default=None) + """ + The created transfer order + """ + + 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/custom_attribute.py b/src/square/types/custom_attribute.py index 3fa08e66..cd1d13cb 100644 --- a/src/square/types/custom_attribute.py +++ b/src/square/types/custom_attribute.py @@ -30,7 +30,14 @@ class CustomAttribute(UncheckedBaseModel): underscores (_), and hyphens (-). """ - value: typing.Optional[typing.Optional[typing.Any]] = None + value: typing.Optional[typing.Optional[typing.Any]] = pydantic.Field(default=None) + """ + The value assigned to the custom attribute. It is validated against the custom + attribute definition's schema on write operations. For more information about custom + attribute values, + see [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). + """ + version: typing.Optional[int] = pydantic.Field(default=None) """ Read only. The current version of the custom attribute. This field is incremented when the custom attribute is changed. diff --git a/src/square/types/delete_transfer_order_response.py b/src/square/types/delete_transfer_order_response.py new file mode 100644 index 00000000..71e147e4 --- /dev/null +++ b/src/square/types/delete_transfer_order_response.py @@ -0,0 +1,28 @@ +# 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 DeleteTransferOrderResponse(UncheckedBaseModel): + """ + Response for deleting a transfer order + """ + + 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/list_channels_request_constants.py b/src/square/types/list_channels_request_constants.py new file mode 100644 index 00000000..c63482b5 --- /dev/null +++ b/src/square/types/list_channels_request_constants.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ListChannelsRequestConstants = typing.Literal["MAX_PAGE_SIZE"] diff --git a/src/square/types/list_channels_response.py b/src/square/types/list_channels_response.py new file mode 100644 index 00000000..939cd62e --- /dev/null +++ b/src/square/types/list_channels_response.py @@ -0,0 +1,35 @@ +# 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 .channel import Channel +from .error import Error + + +class ListChannelsResponse(UncheckedBaseModel): + errors: typing.Optional[typing.List[Error]] = pydantic.Field(default=None) + """ + Information about errors encountered during the request. + """ + + channels: typing.Optional[typing.List[Channel]] = pydantic.Field(default=None) + """ + List of requested Channel. + """ + + cursor: typing.Optional[str] = pydantic.Field(default=None) + """ + The token required to retrieve the next page of results. + """ + + 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/receive_transfer_order_response.py b/src/square/types/receive_transfer_order_response.py new file mode 100644 index 00000000..635ffde3 --- /dev/null +++ b/src/square/types/receive_transfer_order_response.py @@ -0,0 +1,34 @@ +# 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 +from .transfer_order import TransferOrder + + +class ReceiveTransferOrderResponse(UncheckedBaseModel): + """ + Response for receiving items for a transfer order + """ + + transfer_order: typing.Optional[TransferOrder] = pydantic.Field(default=None) + """ + The updated transfer order + """ + + 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/reference.py b/src/square/types/reference.py new file mode 100644 index 00000000..b07a6e88 --- /dev/null +++ b/src/square/types/reference.py @@ -0,0 +1,30 @@ +# 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 .reference_type import ReferenceType + + +class Reference(UncheckedBaseModel): + type: typing.Optional[ReferenceType] = pydantic.Field(default=None) + """ + The type of entity a channel is associated with. + See [Type](#type-type) for possible values + """ + + id: typing.Optional[str] = pydantic.Field(default=None) + """ + The id of the entity a channel is associated with. + """ + + 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/reference_type.py b/src/square/types/reference_type.py new file mode 100644 index 00000000..6b8b82ec --- /dev/null +++ b/src/square/types/reference_type.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ReferenceType = typing.Union[ + typing.Literal[ + "UNKNOWN_TYPE", + "LOCATION", + "FIRST_PARTY_INTEGRATION", + "OAUTH_APPLICATION", + "ONLINE_SITE", + "ONLINE_CHECKOUT", + "INVOICE", + "GIFT_CARD", + "GIFT_CARD_MARKETPLACE", + "RECURRING_SUBSCRIPTION", + "ONLINE_BOOKING_FLOW", + "SQUARE_ASSISTANT", + "CASH_LOCAL", + "POINT_OF_SALE", + "KIOSK", + ], + typing.Any, +] diff --git a/src/square/types/retrieve_channel_response.py b/src/square/types/retrieve_channel_response.py new file mode 100644 index 00000000..c8c9d8e3 --- /dev/null +++ b/src/square/types/retrieve_channel_response.py @@ -0,0 +1,30 @@ +# 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 .channel import Channel +from .error import Error + + +class RetrieveChannelResponse(UncheckedBaseModel): + errors: typing.Optional[typing.List[Error]] = pydantic.Field(default=None) + """ + Information about errors encountered during the request. + """ + + channel: typing.Optional[Channel] = pydantic.Field(default=None) + """ + The requested Channel. + """ + + 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/retrieve_transfer_order_response.py b/src/square/types/retrieve_transfer_order_response.py new file mode 100644 index 00000000..df629ead --- /dev/null +++ b/src/square/types/retrieve_transfer_order_response.py @@ -0,0 +1,34 @@ +# 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 +from .transfer_order import TransferOrder + + +class RetrieveTransferOrderResponse(UncheckedBaseModel): + """ + Response containing the requested transfer order + """ + + transfer_order: typing.Optional[TransferOrder] = pydantic.Field(default=None) + """ + The requested transfer order + """ + + 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/search_transfer_orders_response.py b/src/square/types/search_transfer_orders_response.py new file mode 100644 index 00000000..33bbda2a --- /dev/null +++ b/src/square/types/search_transfer_orders_response.py @@ -0,0 +1,39 @@ +# 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 +from .transfer_order import TransferOrder + + +class SearchTransferOrdersResponse(UncheckedBaseModel): + """ + Response for searching transfer orders + """ + + transfer_orders: typing.Optional[typing.List[TransferOrder]] = pydantic.Field(default=None) + """ + List of transfer orders matching the search criteria + """ + + cursor: typing.Optional[str] = pydantic.Field(default=None) + """ + Pagination cursor for fetching the next page of results + """ + + 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/start_transfer_order_response.py b/src/square/types/start_transfer_order_response.py new file mode 100644 index 00000000..ee077dab --- /dev/null +++ b/src/square/types/start_transfer_order_response.py @@ -0,0 +1,34 @@ +# 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 +from .transfer_order import TransferOrder + + +class StartTransferOrderResponse(UncheckedBaseModel): + """ + Response for starting a transfer order. + """ + + transfer_order: typing.Optional[TransferOrder] = pydantic.Field(default=None) + """ + The updated transfer order with status changed to STARTED + """ + + 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/transfer_order.py b/src/square/types/transfer_order.py new file mode 100644 index 00000000..0e17bfd1 --- /dev/null +++ b/src/square/types/transfer_order.py @@ -0,0 +1,142 @@ +# 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 .transfer_order_line import TransferOrderLine +from .transfer_order_status import TransferOrderStatus + + +class TransferOrder(UncheckedBaseModel): + """ + Represents a transfer order for moving [CatalogItemVariation](entity:CatalogItemVariation)s + between [Location](entity:Location)s. Transfer orders track the entire lifecycle of an inventory + transfer, including: + - What items and quantities are being moved + - Source and destination locations + - Current [TransferOrderStatus](entity:TransferOrderStatus) + - Shipping information and tracking + - Which [TeamMember](entity:TeamMember) initiated the transfer + + This object is commonly used to: + - Track [CatalogItemVariation](entity:CatalogItemVariation) movements between [Location](entity:Location)s + - Reconcile expected vs received quantities + - Monitor transfer progress and shipping status + - Audit inventory movement history + """ + + id: typing.Optional[str] = pydantic.Field(default=None) + """ + Unique system-generated identifier for this transfer order. Use this ID for: + - Retrieving transfer order details + - Tracking status changes via webhooks + - Linking transfers in external systems + """ + + source_location_id: typing.Optional[str] = pydantic.Field(default=None) + """ + The source [Location](entity:Location) sending the [CatalogItemVariation](entity:CatalogItemVariation)s. + This location must: + - Be active in your Square organization + - Have sufficient inventory for the items being transferred + - Not be the same as the destination location + + This field is not updatable. + """ + + destination_location_id: typing.Optional[str] = pydantic.Field(default=None) + """ + The destination [Location](entity:Location) receiving the [CatalogItemVariation](entity:CatalogItemVariation)s. + This location must: + - Be active in your Square organization + - Not be the same as the source location + + This field is not updatable. + """ + + status: typing.Optional[TransferOrderStatus] = pydantic.Field(default=None) + """ + Current [TransferOrderStatus](entity:TransferOrderStatus) indicating where the order is in its lifecycle. + Status transitions follow this progression: + 1. [DRAFT](entity:TransferOrderStatus) -> [STARTED](entity:TransferOrderStatus) via [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder) + 2. [STARTED](entity:TransferOrderStatus) -> [PARTIALLY_RECEIVED](entity:TransferOrderStatus) via [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder) + 3. [PARTIALLY_RECEIVED](entity:TransferOrderStatus) -> [COMPLETED](entity:TransferOrderStatus) after all items received + + Orders can be [CANCELED](entity:TransferOrderStatus) from [STARTED](entity:TransferOrderStatus) or + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. + + This field is read-only and reflects the current state of the transfer order, and cannot be updated directly. Use the appropriate + endpoints (e.g. [StartPurchaseOrder](api-endpoint:TransferOrders-StartTransferOrder), to change the status. + See [TransferOrderStatus](#type-transferorderstatus) for possible values + """ + + created_at: typing.Optional[str] = pydantic.Field(default=None) + """ + Timestamp when the transfer order was created, in RFC 3339 format. + Used for: + - Auditing transfer history + - Tracking order age + - Reporting and analytics + """ + + updated_at: typing.Optional[str] = pydantic.Field(default=None) + """ + Timestamp when the transfer order was last updated, in RFC 3339 format. + Updated when: + - Order status changes + - Items are received + - Notes or metadata are modified + """ + + expected_at: typing.Optional[str] = pydantic.Field(default=None) + """ + Expected transfer completion date, in RFC 3339 format. + Used for: + - Planning inventory availability + - Scheduling receiving staff + - Monitoring transfer timeliness + """ + + completed_at: typing.Optional[str] = pydantic.Field(default=None) + """ + Timestamp when the transfer order was completed or canceled, in RFC 3339 format (e.g. "2023-10-01T12:00:00Z"). + """ + + notes: typing.Optional[str] = pydantic.Field(default=None) + """ + Optional notes about the transfer. + """ + + tracking_number: typing.Optional[str] = pydantic.Field(default=None) + """ + Shipment tracking number for monitoring transfer progress. + """ + + created_by_team_member_id: typing.Optional[str] = pydantic.Field(default=None) + """ + ID of the [TeamMember](entity:TeamMember) who created this transfer order. This field is not writeable by the Connect V2 API. + """ + + line_items: typing.Optional[typing.List[TransferOrderLine]] = pydantic.Field(default=None) + """ + List of [CatalogItemVariation](entity:CatalogItemVariation)s being transferred. + """ + + version: typing.Optional[int] = pydantic.Field(default=None) + """ + Version for optimistic concurrency control. This is a monotonically increasing integer + that changes whenever the transfer order is modified. Use this when calling + [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder) and other endpoints to ensure you're + not overwriting concurrent changes. + """ + + 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/transfer_order_created_event.py b/src/square/types/transfer_order_created_event.py new file mode 100644 index 00000000..0665a675 --- /dev/null +++ b/src/square/types/transfer_order_created_event.py @@ -0,0 +1,48 @@ +# 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 .transfer_order_created_event_data import TransferOrderCreatedEventData + + +class TransferOrderCreatedEvent(UncheckedBaseModel): + """ + Published when a transfer_order is created. + """ + + merchant_id: typing.Optional[str] = pydantic.Field(default=None) + """ + The ID of the target merchant associated with the event. + """ + + type: typing.Optional[str] = pydantic.Field(default=None) + """ + The type of event this represents, `"transfer_order.created"`. + """ + + event_id: typing.Optional[str] = pydantic.Field(default=None) + """ + A unique ID for the event. + """ + + created_at: typing.Optional[str] = pydantic.Field(default=None) + """ + Timestamp of when the event was created, in RFC 3339 format. + """ + + data: typing.Optional[TransferOrderCreatedEventData] = pydantic.Field(default=None) + """ + Data associated with the event. + """ + + 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/transfer_order_created_event_data.py b/src/square/types/transfer_order_created_event_data.py new file mode 100644 index 00000000..534debe8 --- /dev/null +++ b/src/square/types/transfer_order_created_event_data.py @@ -0,0 +1,34 @@ +# 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 .transfer_order_created_event_object import TransferOrderCreatedEventObject + + +class TransferOrderCreatedEventData(UncheckedBaseModel): + type: typing.Optional[str] = pydantic.Field(default=None) + """ + Name of the affected object’s type, `"transfer_order"`. + """ + + id: typing.Optional[str] = pydantic.Field(default=None) + """ + ID of the affected transfer_order. + """ + + object: typing.Optional[TransferOrderCreatedEventObject] = pydantic.Field(default=None) + """ + An object containing the created transfer_order. + """ + + 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/transfer_order_created_event_object.py b/src/square/types/transfer_order_created_event_object.py new file mode 100644 index 00000000..484682d2 --- /dev/null +++ b/src/square/types/transfer_order_created_event_object.py @@ -0,0 +1,24 @@ +# 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 .transfer_order import TransferOrder + + +class TransferOrderCreatedEventObject(UncheckedBaseModel): + transfer_order: typing.Optional[TransferOrder] = pydantic.Field(default=None) + """ + The created transfer_order. + """ + + 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/transfer_order_deleted_event.py b/src/square/types/transfer_order_deleted_event.py new file mode 100644 index 00000000..ff2863af --- /dev/null +++ b/src/square/types/transfer_order_deleted_event.py @@ -0,0 +1,48 @@ +# 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 .transfer_order_deleted_event_data import TransferOrderDeletedEventData + + +class TransferOrderDeletedEvent(UncheckedBaseModel): + """ + Published when a transfer_order is deleted. + """ + + merchant_id: typing.Optional[str] = pydantic.Field(default=None) + """ + The ID of the target merchant associated with the event. + """ + + type: typing.Optional[str] = pydantic.Field(default=None) + """ + The type of event this represents, `"transfer_order.deleted"`. + """ + + event_id: typing.Optional[str] = pydantic.Field(default=None) + """ + A unique ID for the event. + """ + + created_at: typing.Optional[str] = pydantic.Field(default=None) + """ + Timestamp of when the event was created, in RFC 3339 format. + """ + + data: typing.Optional[TransferOrderDeletedEventData] = pydantic.Field(default=None) + """ + Data associated with the event. + """ + + 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/transfer_order_deleted_event_data.py b/src/square/types/transfer_order_deleted_event_data.py new file mode 100644 index 00000000..74453b3b --- /dev/null +++ b/src/square/types/transfer_order_deleted_event_data.py @@ -0,0 +1,33 @@ +# 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 + + +class TransferOrderDeletedEventData(UncheckedBaseModel): + type: typing.Optional[str] = pydantic.Field(default=None) + """ + Name of the affected object’s type, `"transfer_order"`. + """ + + id: typing.Optional[str] = pydantic.Field(default=None) + """ + ID of the affected transfer_order. + """ + + deleted: typing.Optional[bool] = pydantic.Field(default=None) + """ + Is true if the affected object was deleted. Otherwise absent. + """ + + 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/transfer_order_filter.py b/src/square/types/transfer_order_filter.py new file mode 100644 index 00000000..ab914898 --- /dev/null +++ b/src/square/types/transfer_order_filter.py @@ -0,0 +1,39 @@ +# 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 .transfer_order_status import TransferOrderStatus + + +class TransferOrderFilter(UncheckedBaseModel): + """ + Filter criteria for searching transfer orders + """ + + source_location_ids: typing.Optional[typing.List[str]] = pydantic.Field(default=None) + """ + Filter by source location IDs + """ + + destination_location_ids: typing.Optional[typing.List[str]] = pydantic.Field(default=None) + """ + Filter by destination location IDs + """ + + statuses: typing.Optional[typing.List[TransferOrderStatus]] = pydantic.Field(default=None) + """ + Filter by order statuses + See [TransferOrderStatus](#type-transferorderstatus) for possible values + """ + + 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/transfer_order_goods_receipt.py b/src/square/types/transfer_order_goods_receipt.py new file mode 100644 index 00000000..51534d37 --- /dev/null +++ b/src/square/types/transfer_order_goods_receipt.py @@ -0,0 +1,55 @@ +# 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 .transfer_order_goods_receipt_line_item import TransferOrderGoodsReceiptLineItem + + +class TransferOrderGoodsReceipt(UncheckedBaseModel): + """ + The goods receipt details for a transfer order. This object represents a single receipt + of goods against a transfer order, tracking: + + - Which [CatalogItemVariation](entity:CatalogItemVariation)s were received + - Quantities received in good condition + - Quantities damaged during transit/handling + - Quantities canceled during receipt + + Multiple goods receipts can be created for a single transfer order to handle: + - Partial deliveries + - Multiple shipments + - Split receipts across different dates + - Cancellations of specific quantities + + Each receipt automatically: + - Updates the transfer order status + - Adjusts received quantities + - Updates inventory levels at both source and destination [Location](entity:Location)s + """ + + line_items: typing.Optional[typing.List[TransferOrderGoodsReceiptLineItem]] = pydantic.Field(default=None) + """ + Line items being received. Each line item specifies: + - The item being received + - Quantity received in good condition + - Quantity received damaged + - Quantity canceled + + Constraints: + - Must include at least one line item + - Maximum of 1000 line items per receipt + - Each line item must reference a valid item from the transfer order + - Total of received, damaged, and canceled quantities cannot exceed ordered quantity + """ + + 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/transfer_order_goods_receipt_line_item.py b/src/square/types/transfer_order_goods_receipt_line_item.py new file mode 100644 index 00000000..e1d414f2 --- /dev/null +++ b/src/square/types/transfer_order_goods_receipt_line_item.py @@ -0,0 +1,44 @@ +# 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 + + +class TransferOrderGoodsReceiptLineItem(UncheckedBaseModel): + """ + A simplified line item for goods receipts in transfer orders + """ + + transfer_order_line_uid: str = pydantic.Field() + """ + The unique identifier of the Transfer Order line being received + """ + + quantity_received: typing.Optional[str] = pydantic.Field(default=None) + """ + The quantity received for this line item as a decimal string (e.g. "10.5"). + These items will be added to the destination [Location](entity:Location)'s inventory with [InventoryState](entity:InventoryState) of IN_STOCK. + """ + + quantity_damaged: typing.Optional[str] = pydantic.Field(default=None) + """ + The quantity that was damaged during shipping/handling as a decimal string (e.g. "1.5"). + These items will be added to the destination [Location](entity:Location)'s inventory with [InventoryState](entity:InventoryState) of WASTE. + """ + + quantity_canceled: typing.Optional[str] = pydantic.Field(default=None) + """ + The quantity that was canceled during shipping/handling as a decimal string (e.g. "1.5"). These will be immediately added to inventory in the source location. + """ + + 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/transfer_order_line.py b/src/square/types/transfer_order_line.py new file mode 100644 index 00000000..611b5de9 --- /dev/null +++ b/src/square/types/transfer_order_line.py @@ -0,0 +1,70 @@ +# 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 + + +class TransferOrderLine(UncheckedBaseModel): + """ + Represents a line item in a transfer order. Each line item tracks a specific + [CatalogItemVariation](entity:CatalogItemVariation) being transferred, including ordered quantities + and receipt status. + """ + + uid: typing.Optional[str] = pydantic.Field(default=None) + """ + Unique system-generated identifier for the line item. Provide when updating/removing a line via [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder). + """ + + item_variation_id: str = pydantic.Field() + """ + The required identifier of the [CatalogItemVariation](entity:CatalogItemVariation) being transferred. Must reference + a valid catalog item variation that exists in the [Catalog](api:Catalog). + """ + + quantity_ordered: str = pydantic.Field() + """ + Total quantity ordered, formatted as a decimal string (e.g. "10 or 10.0000"). Required to be a positive number. + + To remove a line item, set `remove` to `true` in [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder). + """ + + quantity_pending: typing.Optional[str] = pydantic.Field(default=None) + """ + Calculated quantity of this line item's yet to be received stock. This is the difference between the total quantity ordered and the sum of quantities received, canceled, and damaged. + """ + + quantity_received: typing.Optional[str] = pydantic.Field(default=None) + """ + Quantity received at destination. These items are added to the destination + [Location](entity:Location)'s inventory with [InventoryState](entity:InventoryState) of IN_STOCK. + + This field cannot be updated directly in Create/Update operations, instead use [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder). + """ + + quantity_damaged: typing.Optional[str] = pydantic.Field(default=None) + """ + Quantity received in damaged condition. These items are added to the destination + [Location](entity:Location)'s inventory with [InventoryState](entity:InventoryState) of WASTE. + + This field cannot be updated directly in Create/Update operations, instead use [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder). + """ + + quantity_canceled: typing.Optional[str] = pydantic.Field(default=None) + """ + Quantity that was canceled. These items will be immediately added to inventory in the source location. + + This field cannot be updated directly in Create/Update operations, instead use [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder) or [CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + """ + + 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/transfer_order_query.py b/src/square/types/transfer_order_query.py new file mode 100644 index 00000000..b365a0fd --- /dev/null +++ b/src/square/types/transfer_order_query.py @@ -0,0 +1,34 @@ +# 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 .transfer_order_filter import TransferOrderFilter +from .transfer_order_sort import TransferOrderSort + + +class TransferOrderQuery(UncheckedBaseModel): + """ + Query parameters for searching transfer orders + """ + + filter: typing.Optional[TransferOrderFilter] = pydantic.Field(default=None) + """ + Filter criteria + """ + + sort: typing.Optional[TransferOrderSort] = pydantic.Field(default=None) + """ + Sort configuration + """ + + 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/transfer_order_sort.py b/src/square/types/transfer_order_sort.py new file mode 100644 index 00000000..f6edc9c7 --- /dev/null +++ b/src/square/types/transfer_order_sort.py @@ -0,0 +1,36 @@ +# 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 .sort_order import SortOrder +from .transfer_order_sort_field import TransferOrderSortField + + +class TransferOrderSort(UncheckedBaseModel): + """ + Sort configuration for search results + """ + + field: typing.Optional[TransferOrderSortField] = pydantic.Field(default=None) + """ + Field to sort by + See [TransferOrderSortField](#type-transferordersortfield) for possible values + """ + + order: typing.Optional[SortOrder] = pydantic.Field(default=None) + """ + Sort order direction + See [SortOrder](#type-sortorder) for possible values + """ + + 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/transfer_order_sort_field.py b/src/square/types/transfer_order_sort_field.py new file mode 100644 index 00000000..f785b651 --- /dev/null +++ b/src/square/types/transfer_order_sort_field.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +TransferOrderSortField = typing.Union[typing.Literal["CREATED_AT", "UPDATED_AT"], typing.Any] diff --git a/src/square/types/transfer_order_status.py b/src/square/types/transfer_order_status.py new file mode 100644 index 00000000..894cee4d --- /dev/null +++ b/src/square/types/transfer_order_status.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +TransferOrderStatus = typing.Union[ + typing.Literal["DRAFT", "STARTED", "PARTIALLY_RECEIVED", "COMPLETED", "CANCELED"], typing.Any +] diff --git a/src/square/types/transfer_order_updated_event.py b/src/square/types/transfer_order_updated_event.py new file mode 100644 index 00000000..35942a7d --- /dev/null +++ b/src/square/types/transfer_order_updated_event.py @@ -0,0 +1,48 @@ +# 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 .transfer_order_updated_event_data import TransferOrderUpdatedEventData + + +class TransferOrderUpdatedEvent(UncheckedBaseModel): + """ + Published when a transfer_order is updated. + """ + + merchant_id: typing.Optional[str] = pydantic.Field(default=None) + """ + The ID of the target merchant associated with the event. + """ + + type: typing.Optional[str] = pydantic.Field(default=None) + """ + The type of event this represents, `"transfer_order.updated"`. + """ + + event_id: typing.Optional[str] = pydantic.Field(default=None) + """ + A unique ID for the event. + """ + + created_at: typing.Optional[str] = pydantic.Field(default=None) + """ + Timestamp of when the event was created, in RFC 3339 format. + """ + + data: typing.Optional[TransferOrderUpdatedEventData] = pydantic.Field(default=None) + """ + Data associated with the event. + """ + + 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/transfer_order_updated_event_data.py b/src/square/types/transfer_order_updated_event_data.py new file mode 100644 index 00000000..3c0c177f --- /dev/null +++ b/src/square/types/transfer_order_updated_event_data.py @@ -0,0 +1,34 @@ +# 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 .transfer_order_updated_event_object import TransferOrderUpdatedEventObject + + +class TransferOrderUpdatedEventData(UncheckedBaseModel): + type: typing.Optional[str] = pydantic.Field(default=None) + """ + Name of the affected object’s type, `"transfer_order"`. + """ + + id: typing.Optional[str] = pydantic.Field(default=None) + """ + ID of the affected transfer_order. + """ + + object: typing.Optional[TransferOrderUpdatedEventObject] = pydantic.Field(default=None) + """ + An object containing the updated transfer_order. + """ + + 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/transfer_order_updated_event_object.py b/src/square/types/transfer_order_updated_event_object.py new file mode 100644 index 00000000..d29e8489 --- /dev/null +++ b/src/square/types/transfer_order_updated_event_object.py @@ -0,0 +1,24 @@ +# 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 .transfer_order import TransferOrder + + +class TransferOrderUpdatedEventObject(UncheckedBaseModel): + transfer_order: typing.Optional[TransferOrder] = pydantic.Field(default=None) + """ + The updated transfer_order. + """ + + 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/update_transfer_order_data.py b/src/square/types/update_transfer_order_data.py new file mode 100644 index 00000000..56e35fac --- /dev/null +++ b/src/square/types/update_transfer_order_data.py @@ -0,0 +1,55 @@ +# 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 .update_transfer_order_line_data import UpdateTransferOrderLineData + + +class UpdateTransferOrderData(UncheckedBaseModel): + """ + Data model for updating a transfer order. All fields are optional. + """ + + source_location_id: typing.Optional[str] = pydantic.Field(default=None) + """ + The source [Location](entity:Location) that will send the items. Must be an active location + in your Square account with sufficient inventory of the requested items. + """ + + destination_location_id: typing.Optional[str] = pydantic.Field(default=None) + """ + The destination [Location](entity:Location) that will receive the items. Must be an active location + in your Square account. + """ + + expected_at: typing.Optional[str] = pydantic.Field(default=None) + """ + Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z"). + """ + + notes: typing.Optional[str] = pydantic.Field(default=None) + """ + Optional notes about the transfer + """ + + tracking_number: typing.Optional[str] = pydantic.Field(default=None) + """ + Shipment tracking number + """ + + line_items: typing.Optional[typing.List[UpdateTransferOrderLineData]] = pydantic.Field(default=None) + """ + List of items being transferred + """ + + 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/update_transfer_order_line_data.py b/src/square/types/update_transfer_order_line_data.py new file mode 100644 index 00000000..a2b3bc8b --- /dev/null +++ b/src/square/types/update_transfer_order_line_data.py @@ -0,0 +1,44 @@ +# 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 + + +class UpdateTransferOrderLineData(UncheckedBaseModel): + """ + Represents a line item update in a transfer order + """ + + uid: typing.Optional[str] = pydantic.Field(default=None) + """ + Line item id being updated. Required for updating/removing existing line items, but should not be set for new line items. + """ + + item_variation_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Catalog item variation being transferred + + Required for new line items, but otherwise is not updatable. + """ + + quantity_ordered: typing.Optional[str] = pydantic.Field(default=None) + """ + Total quantity ordered + """ + + remove: typing.Optional[bool] = pydantic.Field(default=None) + """ + Flag to remove the line item during update. Must include `uid` in removal 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/update_transfer_order_response.py b/src/square/types/update_transfer_order_response.py new file mode 100644 index 00000000..c76abd76 --- /dev/null +++ b/src/square/types/update_transfer_order_response.py @@ -0,0 +1,34 @@ +# 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 +from .transfer_order import TransferOrder + + +class UpdateTransferOrderResponse(UncheckedBaseModel): + """ + Response for updating a transfer order + """ + + transfer_order: typing.Optional[TransferOrder] = pydantic.Field(default=None) + """ + The updated transfer order + """ + + 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/v1transactions/client.py b/src/square/v1transactions/client.py index e1f8218f..1fb8e5ff 100644 --- a/src/square/v1transactions/client.py +++ b/src/square/v1transactions/client.py @@ -72,6 +72,9 @@ def v1list_orders( ) client.v1transactions.v1list_orders( location_id="location_id", + order="DESC", + limit=1, + batch_token="batch_token", ) """ _response = self._raw_client.v1list_orders( @@ -253,6 +256,9 @@ async def v1list_orders( async def main() -> None: await client.v1transactions.v1list_orders( location_id="location_id", + order="DESC", + limit=1, + batch_token="batch_token", ) diff --git a/src/square/webhooks/__init__.py b/src/square/webhooks/__init__.py index 46a5c175..022f9d17 100644 --- a/src/square/webhooks/__init__.py +++ b/src/square/webhooks/__init__.py @@ -2,6 +2,33 @@ # isort: skip_file -from . import event_types, subscriptions +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import event_types, subscriptions +_dynamic_imports: typing.Dict[str, str] = {"event_types": ".event_types", "subscriptions": ".subscriptions"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["event_types", "subscriptions"] diff --git a/src/square/webhooks/client.py b/src/square/webhooks/client.py index 36f91997..ab1deaf3 100644 --- a/src/square/webhooks/client.py +++ b/src/square/webhooks/client.py @@ -1,17 +1,23 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + +import typing + from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from .event_types.client import AsyncEventTypesClient, EventTypesClient from .raw_client import AsyncRawWebhooksClient, RawWebhooksClient -from .subscriptions.client import AsyncSubscriptionsClient, SubscriptionsClient + +if typing.TYPE_CHECKING: + from .event_types.client import AsyncEventTypesClient, EventTypesClient + from .subscriptions.client import AsyncSubscriptionsClient, SubscriptionsClient class WebhooksClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawWebhooksClient(client_wrapper=client_wrapper) - self.event_types = EventTypesClient(client_wrapper=client_wrapper) - - self.subscriptions = SubscriptionsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._event_types: typing.Optional[EventTypesClient] = None + self._subscriptions: typing.Optional[SubscriptionsClient] = None @property def with_raw_response(self) -> RawWebhooksClient: @@ -24,13 +30,29 @@ def with_raw_response(self) -> RawWebhooksClient: """ return self._raw_client + @property + def event_types(self): + if self._event_types is None: + from .event_types.client import EventTypesClient # noqa: E402 + + self._event_types = EventTypesClient(client_wrapper=self._client_wrapper) + return self._event_types + + @property + def subscriptions(self): + if self._subscriptions is None: + from .subscriptions.client import SubscriptionsClient # noqa: E402 + + self._subscriptions = SubscriptionsClient(client_wrapper=self._client_wrapper) + return self._subscriptions + class AsyncWebhooksClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawWebhooksClient(client_wrapper=client_wrapper) - self.event_types = AsyncEventTypesClient(client_wrapper=client_wrapper) - - self.subscriptions = AsyncSubscriptionsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._event_types: typing.Optional[AsyncEventTypesClient] = None + self._subscriptions: typing.Optional[AsyncSubscriptionsClient] = None @property def with_raw_response(self) -> AsyncRawWebhooksClient: @@ -42,3 +64,19 @@ def with_raw_response(self) -> AsyncRawWebhooksClient: AsyncRawWebhooksClient """ return self._raw_client + + @property + def event_types(self): + if self._event_types is None: + from .event_types.client import AsyncEventTypesClient # noqa: E402 + + self._event_types = AsyncEventTypesClient(client_wrapper=self._client_wrapper) + return self._event_types + + @property + def subscriptions(self): + if self._subscriptions is None: + from .subscriptions.client import AsyncSubscriptionsClient # noqa: E402 + + self._subscriptions = AsyncSubscriptionsClient(client_wrapper=self._client_wrapper) + return self._subscriptions diff --git a/src/square/webhooks/event_types/client.py b/src/square/webhooks/event_types/client.py index d28fee11..1fd60550 100644 --- a/src/square/webhooks/event_types/client.py +++ b/src/square/webhooks/event_types/client.py @@ -49,7 +49,9 @@ def list( client = Square( token="YOUR_TOKEN", ) - client.webhooks.event_types.list() + client.webhooks.event_types.list( + api_version="api_version", + ) """ _response = self._raw_client.list(api_version=api_version, request_options=request_options) return _response.data @@ -101,7 +103,9 @@ async def list( async def main() -> None: - await client.webhooks.event_types.list() + await client.webhooks.event_types.list( + api_version="api_version", + ) asyncio.run(main()) diff --git a/src/square/webhooks/subscriptions/client.py b/src/square/webhooks/subscriptions/client.py index eb3e4174..d08f8f11 100644 --- a/src/square/webhooks/subscriptions/client.py +++ b/src/square/webhooks/subscriptions/client.py @@ -85,7 +85,12 @@ def list( client = Square( token="YOUR_TOKEN", ) - response = client.webhooks.subscriptions.list() + response = client.webhooks.subscriptions.list( + cursor="cursor", + include_disabled=True, + sort_order="DESC", + limit=1, + ) for item in response: yield item # alternatively, you can paginate page-by-page @@ -414,7 +419,12 @@ async def list( async def main() -> None: - response = await client.webhooks.subscriptions.list() + response = await client.webhooks.subscriptions.list( + cursor="cursor", + include_disabled=True, + sort_order="DESC", + limit=1, + ) async for item in response: yield item diff --git a/tests/utils/test_query_encoding.py b/tests/utils/test_query_encoding.py index ad7b0ba0..eedb28a4 100644 --- a/tests/utils/test_query_encoding.py +++ b/tests/utils/test_query_encoding.py @@ -1,6 +1,5 @@ # This file was auto-generated by Fern from our API Definition. - from square.core.query_encoder import encode_query