Skip to content

Commit 227a06b

Browse files
SDK regeneration (#194)
* [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-python-sdk: 4.55.4 * reporting: reapply polling helper + tests on regenerated SDK; align tests to flat LoadResponse * test: skip Disputes integration tests (sandbox not provisioned, 401) to unblock CI --------- Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: fern-support <support@buildwithfern.com>
1 parent 0e1692c commit 227a06b

81 files changed

Lines changed: 2487 additions & 7 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.fern/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
"use_typeddict_requests_for_file_upload": true,
1515
"exclude_types_from_init_exports": true
1616
},
17-
"sdkVersion": "44.1.0.20260520"
17+
"sdkVersion": "44.2.0-rc.0"
1818
}

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ examples
99
legacy
1010
src/square/core/api_error.py
1111
src/square/utils/webhooks_helper.py
12+
src/square/utils/reporting_helper.py
1213
tests/integration
1314
README.md
1415
.fern/replay.lock

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
runs-on: ubuntu-latest
3333
env:
3434
TEST_SQUARE_TOKEN: ${{ secrets.TEST_SQUARE_TOKEN }}
35+
TEST_SQUARE_REPORTING: ${{ secrets.TEST_SQUARE_REPORTING }}
3536
steps:
3637
- name: Checkout repo
3738
uses: actions/checkout@v3

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,71 @@ is_valid = verify_signature(
193193
)
194194
```
195195

196+
## Reporting API
197+
198+
The [Reporting API](https://developer.squareup.com/docs/reporting-api/overview) lets you query
199+
aggregated reporting data. Call `reporting.get_metadata` first to discover the available cubes,
200+
measures, and dimensions, then run a query with `reporting.load`.
201+
202+
```python
203+
from square import Square
204+
205+
client = Square(token="YOUR_TOKEN")
206+
207+
# Discover what you can query.
208+
metadata = client.reporting.get_metadata()
209+
210+
# Run a query against the discovered schema.
211+
response = client.reporting.load(query={"measures": ["Orders.count"]})
212+
```
213+
214+
`load` is asynchronous: while a query is still being computed, the API returns an HTTP `200` whose
215+
body is `{"error": "Continue wait"}` instead of results, and the client is expected to re-send the
216+
identical request — with backoff — until the results are ready. The `load_and_wait` helper owns
217+
that polling loop for you and returns the resolved results (never the `"Continue wait"` sentinel):
218+
219+
```python
220+
from square import Square
221+
from square.utils.reporting_helper import load_and_wait
222+
223+
client = Square(token="YOUR_TOKEN")
224+
225+
response = load_and_wait(client, query={"measures": ["Orders.count"]})
226+
227+
print(response.data)
228+
```
229+
230+
By default it polls up to 20 times with exponential backoff (2s → 20s). Tune the behavior — and
231+
pass a `threading.Event` to cancel — via the keyword arguments:
232+
233+
```python
234+
import threading
235+
236+
cancel_event = threading.Event()
237+
238+
response = load_and_wait(
239+
client,
240+
query={"measures": ["Orders.count"]},
241+
max_attempts=10, # default 20
242+
initial_delay_s=1.0, # default 2.0
243+
max_delay_s=20.0, # default 20.0
244+
backoff_factor=2.0, # default 2.0
245+
cancel_event=cancel_event,
246+
)
247+
```
248+
249+
For the [async client](#async-client), use `load_and_wait_async` (cancel it the idiomatic asyncio
250+
way — e.g. `asyncio.wait_for` or `Task.cancel`):
251+
252+
```python
253+
from square import AsyncSquare
254+
from square.utils.reporting_helper import load_and_wait_async
255+
256+
client = AsyncSquare(token="YOUR_TOKEN")
257+
258+
response = await load_and_wait_async(client, query={"measures": ["Orders.count"]})
259+
```
260+
196261
## Advanced
197262

198263
### Retries

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dynamic = ["version"]
44

55
[tool.poetry]
66
name = "squareup"
7-
version = "44.1.0.20260520"
7+
version = "44.2.0-rc.0"
88
description = ""
99
readme = "README.md"
1010
authors = []

reference.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18511,6 +18511,151 @@ information.
1851118511
</dl>
1851218512

1851318513

18514+
</dd>
18515+
</dl>
18516+
</details>
18517+
18518+
## Reporting
18519+
<details><summary><code>client.reporting.<a href="src/square/reporting/client.py">get_metadata</a>() -&gt; AsyncHttpResponse[MetadataResponse]</code></summary>
18520+
<dl>
18521+
<dd>
18522+
18523+
#### 📝 Description
18524+
18525+
<dl>
18526+
<dd>
18527+
18528+
<dl>
18529+
<dd>
18530+
18531+
Describes the data available to query: the cubes, views, measures, dimensions, and segments you can reference in a reporting query. Call this first to discover the schema, then pass the members you need to `load`.
18532+
</dd>
18533+
</dl>
18534+
</dd>
18535+
</dl>
18536+
18537+
#### 🔌 Usage
18538+
18539+
<dl>
18540+
<dd>
18541+
18542+
<dl>
18543+
<dd>
18544+
18545+
```python
18546+
from square import Square
18547+
18548+
client = Square(
18549+
token="YOUR_TOKEN",
18550+
)
18551+
client.reporting.get_metadata()
18552+
18553+
```
18554+
</dd>
18555+
</dl>
18556+
</dd>
18557+
</dl>
18558+
18559+
#### ⚙️ Parameters
18560+
18561+
<dl>
18562+
<dd>
18563+
18564+
<dl>
18565+
<dd>
18566+
18567+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
18568+
18569+
</dd>
18570+
</dl>
18571+
</dd>
18572+
</dl>
18573+
18574+
18575+
</dd>
18576+
</dl>
18577+
</details>
18578+
18579+
<details><summary><code>client.reporting.<a href="src/square/reporting/client.py">load</a>(...) -&gt; AsyncHttpResponse[LoadResponse]</code></summary>
18580+
<dl>
18581+
<dd>
18582+
18583+
#### 📝 Description
18584+
18585+
<dl>
18586+
<dd>
18587+
18588+
<dl>
18589+
<dd>
18590+
18591+
Runs a reporting query against the discovered schema and returns the aggregated results. Long-running queries may return a "Continue wait" response while processing — retry the same request until results are ready.
18592+
</dd>
18593+
</dl>
18594+
</dd>
18595+
</dl>
18596+
18597+
#### 🔌 Usage
18598+
18599+
<dl>
18600+
<dd>
18601+
18602+
<dl>
18603+
<dd>
18604+
18605+
```python
18606+
from square import Square
18607+
18608+
client = Square(
18609+
token="YOUR_TOKEN",
18610+
)
18611+
client.reporting.load()
18612+
18613+
```
18614+
</dd>
18615+
</dl>
18616+
</dd>
18617+
</dl>
18618+
18619+
#### ⚙️ Parameters
18620+
18621+
<dl>
18622+
<dd>
18623+
18624+
<dl>
18625+
<dd>
18626+
18627+
**query_type:** `typing.Optional[str]`
18628+
18629+
</dd>
18630+
</dl>
18631+
18632+
<dl>
18633+
<dd>
18634+
18635+
**cache:** `typing.Optional[CacheMode]`
18636+
18637+
</dd>
18638+
</dl>
18639+
18640+
<dl>
18641+
<dd>
18642+
18643+
**query:** `typing.Optional[QueryParams]`
18644+
18645+
</dd>
18646+
</dl>
18647+
18648+
<dl>
18649+
<dd>
18650+
18651+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
18652+
18653+
</dd>
18654+
</dl>
18655+
</dd>
18656+
</dl>
18657+
18658+
1851418659
</dd>
1851518660
</dl>
1851618661
</details>

src/square/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
payments,
3333
payouts,
3434
refunds,
35+
reporting,
3536
sites,
3637
snippets,
3738
subscriptions,
@@ -74,6 +75,7 @@
7475
"payments": ".payments",
7576
"payouts": ".payouts",
7677
"refunds": ".refunds",
78+
"reporting": ".reporting",
7779
"sites": ".sites",
7880
"snippets": ".snippets",
7981
"subscriptions": ".subscriptions",
@@ -137,6 +139,7 @@ def __dir__():
137139
"payments",
138140
"payouts",
139141
"refunds",
142+
"reporting",
140143
"sites",
141144
"snippets",
142145
"subscriptions",

src/square/client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from .payments.client import AsyncPaymentsClient, PaymentsClient
3636
from .payouts.client import AsyncPayoutsClient, PayoutsClient
3737
from .refunds.client import AsyncRefundsClient, RefundsClient
38+
from .reporting.client import AsyncReportingClient, ReportingClient
3839
from .sites.client import AsyncSitesClient, SitesClient
3940
from .snippets.client import AsyncSnippetsClient, SnippetsClient
4041
from .subscriptions.client import AsyncSubscriptionsClient, SubscriptionsClient
@@ -148,6 +149,7 @@ def __init__(
148149
self._terminal: typing.Optional[TerminalClient] = None
149150
self._transfer_orders: typing.Optional[TransferOrdersClient] = None
150151
self._vendors: typing.Optional[VendorsClient] = None
152+
self._reporting: typing.Optional[ReportingClient] = None
151153
self._cash_drawers: typing.Optional[CashDrawersClient] = None
152154
self._webhooks: typing.Optional[WebhooksClient] = None
153155

@@ -415,6 +417,14 @@ def vendors(self):
415417
self._vendors = VendorsClient(client_wrapper=self._client_wrapper)
416418
return self._vendors
417419

420+
@property
421+
def reporting(self):
422+
if self._reporting is None:
423+
from .reporting.client import ReportingClient # noqa: E402
424+
425+
self._reporting = ReportingClient(client_wrapper=self._client_wrapper)
426+
return self._reporting
427+
418428
@property
419429
def cash_drawers(self):
420430
if self._cash_drawers is None:
@@ -533,6 +543,7 @@ def __init__(
533543
self._terminal: typing.Optional[AsyncTerminalClient] = None
534544
self._transfer_orders: typing.Optional[AsyncTransferOrdersClient] = None
535545
self._vendors: typing.Optional[AsyncVendorsClient] = None
546+
self._reporting: typing.Optional[AsyncReportingClient] = None
536547
self._cash_drawers: typing.Optional[AsyncCashDrawersClient] = None
537548
self._webhooks: typing.Optional[AsyncWebhooksClient] = None
538549

@@ -800,6 +811,14 @@ def vendors(self):
800811
self._vendors = AsyncVendorsClient(client_wrapper=self._client_wrapper)
801812
return self._vendors
802813

814+
@property
815+
def reporting(self):
816+
if self._reporting is None:
817+
from .reporting.client import AsyncReportingClient # noqa: E402
818+
819+
self._reporting = AsyncReportingClient(client_wrapper=self._client_wrapper)
820+
return self._reporting
821+
803822
@property
804823
def cash_drawers(self):
805824
if self._cash_drawers is None:

src/square/core/client_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def get_headers(self) -> typing.Dict[str, str]:
2626
import platform
2727

2828
headers: typing.Dict[str, str] = {
29-
"User-Agent": "squareup/44.1.0.20260520",
29+
"User-Agent": "squareup/44.2.0-rc.0",
3030
"X-Fern-Language": "Python",
3131
"X-Fern-Runtime": f"python/{platform.python_version()}",
3232
"X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
3333
"X-Fern-SDK-Name": "squareup",
34-
"X-Fern-SDK-Version": "44.1.0.20260520",
34+
"X-Fern-SDK-Version": "44.2.0-rc.0",
3535
**(self.get_custom_headers() or {}),
3636
}
3737
token = self._get_token()

0 commit comments

Comments
 (0)