Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,703 changes: 2,470 additions & 233 deletions .mock/definition/__package__.yml

Large diffs are not rendered by default.

35 changes: 25 additions & 10 deletions .mock/definition/catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ service:
absent_at_location_ids:
- absent_at_location_ids
image_id: image_id
item_data:
name: Tea
description: Hot Leaf Juice
tax_ids:
- HURXQOOAIC4IZSI2BEXQRYFY
categories:
- type: CATEGORY
id: BJNQCF2FJ6S6UIDT65ABHLRX
ordinal: 0
- type: ITEM
id: AA27W3M2GGTF3H6AVPNB77CK
updated_at: '2016-11-16T22:25:24.878Z'
Expand All @@ -236,11 +245,11 @@ service:
tax_ids:
- HURXQOOAIC4IZSI2BEXQRYFY
categories:
- type: ITEM
- type: CATEGORY
id: BJNQCF2FJ6S6UIDT65ABHLRX
ordinal: 0
related_objects:
- type: CATEGORY
- type: ITEM
id: BJNQCF2FJ6S6UIDT65ABHLRX
updated_at: '2016-11-16T22:25:24.878Z'
version: 1479335124878
Expand Down Expand Up @@ -408,13 +417,13 @@ service:
idempotency_key: 789ff020-f723-43a9-b4b5-43b5dc1fa3dc
batches:
- objects:
- type: ITEM
- type: IMAGE
id: '#Tea'
present_at_all_locations: true
- type: ITEM
- type: IMAGE
id: '#Coffee'
present_at_all_locations: true
- type: CATEGORY
- type: ITEM
id: '#Beverages'
present_at_all_locations: true
- type: TAX
Expand Down Expand Up @@ -458,7 +467,7 @@ service:
- HP5VNYPKZKTNCKZ2Z5NPUH6A
product_type: REGULAR
categories:
- type: ITEM
- type: CATEGORY
id: XCS4SCGN4WQYE2VU4U3TKXEH
ordinal: -2251731094208512
description_html: <p><strong>Hot</strong> Leaf Juice</p>
Expand Down Expand Up @@ -487,7 +496,7 @@ service:
- HP5VNYPKZKTNCKZ2Z5NPUH6A
product_type: REGULAR
categories:
- type: ITEM
- type: CATEGORY
id: XCS4SCGN4WQYE2VU4U3TKXEH
ordinal: -2251662374731776
description_html: <p>Hot <em>Bean Juice</em></p>
Expand All @@ -508,6 +517,12 @@ service:
absent_at_location_ids:
- absent_at_location_ids
image_id: image_id
ordinal: 1000000
category_data:
name: Beverages
category_type: REGULAR_CATEGORY
is_top_level: true
online_visibility: true
- type: TAX
id: HP5VNYPKZKTNCKZ2Z5NPUH6A
updated_at: '2023-11-30T19:24:35.4Z'
Expand Down Expand Up @@ -687,7 +702,7 @@ service:
field: field
cursor: cursor
objects:
- type: CATEGORY
- type: ITEM
id: 5ZYQZZ2IECPVJ2IJ5KQPRDC3
updated_at: '2017-02-21T14:50:26.495Z'
version: 1487688626495
Expand Down Expand Up @@ -934,7 +949,7 @@ service:
- ZXITPM6RWHZ7GZ7EIP3YKECM
product_type: REGULAR
categories:
- type: ITEM
- type: CATEGORY
id: E7CLE5RZZ744BHWVQQEAHI2C
ordinal: 0
- type: ITEM
Expand All @@ -959,7 +974,7 @@ service:
- ZXITPM6RWHZ7GZ7EIP3YKECM
product_type: REGULAR
categories:
- type: ITEM
- type: CATEGORY
id: E7CLE5RZZ744BHWVQQEAHI2C
ordinal: 0
related_objects:
Expand Down
35 changes: 33 additions & 2 deletions .mock/definition/catalog/object.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ service:
- request:
idempotency_key: af3d1afc-7212-4300-b463-0bfc5314a5ae
object:
type: ITEM
type: IMAGE
id: '#Cocoa'
response:
body:
Expand Down Expand Up @@ -259,8 +259,39 @@ service:
absent_at_location_ids:
- absent_at_location_ids
image_id: image_id
item_data:
name: Tea
description: Hot Leaf Juice
abbreviation: abbreviation
label_color: label_color
is_taxable: true
category_id: category_id
tax_ids:
- HURXQOOAIC4IZSI2BEXQRYFY
modifier_list_info:
- modifier_list_id: modifier_list_id
product_type: REGULAR
skip_modifier_screen: true
item_options:
- {}
ecom_uri: ecom_uri
ecom_image_uris:
- ecom_image_uris
image_ids:
- image_ids
sort_name: sort_name
categories:
- type: CATEGORY
id: BJNQCF2FJ6S6UIDT65ABHLRX
ordinal: 0
description_html: description_html
description_plaintext: description_plaintext
channels:
- channels
is_archived: true
is_alcoholic: true
related_objects:
- type: CATEGORY
- type: ITEM
id: BJNQCF2FJ6S6UIDT65ABHLRX
updated_at: '2016-11-16T22:25:24.878Z'
version: 1479335124878
Expand Down
2 changes: 1 addition & 1 deletion .mock/definition/invoices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ service:
body:
properties:
request:
type: optional<unknown>
type: optional<root.CreateInvoiceAttachmentRequestData>
content-type: application/json; charset=utf-8
image_file:
type: optional<file>
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,27 @@ for page in response.iter_pages():
yield page
```

## File Uploads

Files are uploaded with the [File](./src/square/core/file.py) type, which is constructed as a tuple in
a variety of formats. You can customize the filename and `Content-Type` of the individual `multipart/form-data`
part like so:

```python
invoice_pdf = client.invoices.create_invoice_attachment(
invoice_id="inv:0-ChA4-3sU9GPd-uOC3HgvFjMWEL4N",
image_file=(
os.path.basename(pdf_filepath), # The filename to include in the `multipart/form-data` part.
open(pdf_filepath, "rb"), # The file stream, read as binary data.
"application/pdf" # The Content-Type for this particular file.
),
request={
"idempotency_key": str(uuid.uuid4()),
"description": f"Invoice-{pdf_filepath}",
}
)
```

## Exception Handling

When the API returns a non-success status code (4xx or 5xx response), a subclass of
Expand Down
36 changes: 18 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "squareup"

[tool.poetry]
name = "squareup"
version = "42.0.0.20250416"
version = "42.1.0.20250416"
description = ""
readme = "README.md"
authors = []
Expand Down
10 changes: 5 additions & 5 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2653,17 +2653,17 @@ client.catalog.batch_upsert(
{
"objects": [
{
"type": "ITEM",
"type": "IMAGE",
"id": "#Tea",
"present_at_all_locations": True,
},
{
"type": "ITEM",
"type": "IMAGE",
"id": "#Coffee",
"present_at_all_locations": True,
},
{
"type": "CATEGORY",
"type": "ITEM",
"id": "#Beverages",
"present_at_all_locations": True,
},
Expand Down Expand Up @@ -8571,7 +8571,7 @@ client.invoices.create_invoice_attachment(
<dl>
<dd>

**request:** `typing.Optional[typing.Optional[typing.Any]]`
**request:** `typing.Optional[CreateInvoiceAttachmentRequestDataParams]`

</dd>
</dl>
Expand Down Expand Up @@ -17988,7 +17988,7 @@ client = Square(
)
client.catalog.object.upsert(
idempotency_key="af3d1afc-7212-4300-b463-0bfc5314a5ae",
object={"type": "ITEM", "id": "#Cocoa"},
object={"type": "IMAGE", "id": "#Cocoa"},
)

```
Expand Down
12 changes: 6 additions & 6 deletions src/square/catalog/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ def batch_upsert(
{
"objects": [
{
"type": "ITEM",
"type": "IMAGE",
"id": "#Tea",
"present_at_all_locations": True,
},
{
"type": "ITEM",
"type": "IMAGE",
"id": "#Coffee",
"present_at_all_locations": True,
},
{
"type": "CATEGORY",
"type": "ITEM",
"id": "#Beverages",
"present_at_all_locations": True,
},
Expand Down Expand Up @@ -1034,17 +1034,17 @@ async def main() -> None:
{
"objects": [
{
"type": "ITEM",
"type": "IMAGE",
"id": "#Tea",
"present_at_all_locations": True,
},
{
"type": "ITEM",
"type": "IMAGE",
"id": "#Coffee",
"present_at_all_locations": True,
},
{
"type": "CATEGORY",
"type": "ITEM",
"id": "#Beverages",
"present_at_all_locations": True,
},
Expand Down
4 changes: 2 additions & 2 deletions src/square/catalog/object/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def upsert(
)
client.catalog.object.upsert(
idempotency_key="af3d1afc-7212-4300-b463-0bfc5314a5ae",
object={"type": "ITEM", "id": "#Cocoa"},
object={"type": "IMAGE", "id": "#Cocoa"},
)
"""
response = self._raw_client.upsert(
Expand Down Expand Up @@ -284,7 +284,7 @@ async def upsert(
async def main() -> None:
await client.catalog.object.upsert(
idempotency_key="af3d1afc-7212-4300-b463-0bfc5314a5ae",
object={"type": "ITEM", "id": "#Cocoa"},
object={"type": "IMAGE", "id": "#Cocoa"},
)


Expand Down
4 changes: 2 additions & 2 deletions src/square/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def __init__(

def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"User-Agent": "squareup/42.0.0.20250416",
"User-Agent": "squareup/42.1.0.20250416",
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "squareup",
"X-Fern-SDK-Version": "42.0.0.20250416",
"X-Fern-SDK-Version": "42.1.0.20250416",
}
token = self._get_token()
if token is not None:
Expand Down
Loading