Skip to content
Open
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 changes: 1 addition & 1 deletion .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"enable-forward-compatible-enums": true,
"publish-to": "central"
},
"sdkVersion": "46.1.0.20260520"
"sdkVersion": "46.2.0.20260520"
}
3 changes: 3 additions & 0 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ legacy-sdk
src/test/java/com/squareup/square/integration
src/main/java/com/squareup/square/core/SquareApiException.java
src/main/java/com/squareup/square/utilities/WebhooksHelper.java
src/main/java/com/squareup/square/utilities/ReportingHelper.java
src/main/java/com/squareup/square/utilities/LoadAndWaitOptions.java
src/test/java/com/squareup/square/utilities/ReportingHelperTest.java
src/test/resources/testdata
.github/workflows/ci.yml
.fern/replay.lock
Expand Down
80 changes: 75 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The Square Java library provides convenient access to the Square APIs from Java.
- [Base Url](#base-url)
- [Exception Handling](#exception-handling)
- [Webhook Signature Verification](#webhook-signature-verification)
- [Reporting API](#reporting-api)
- [Reference](#reference)
- [Legacy Sdk](#legacy-sdk)
- [Advanced](#advanced)
Expand Down Expand Up @@ -56,7 +57,7 @@ Add the dependency in your `pom.xml` file:
<dependency>
<groupId>com.squareup</groupId>
<artifactId>square</artifactId>
<version>46.1.0.20260520</version>
<version>46.2.0.20260520</version>
</dependency>
```

Expand Down Expand Up @@ -326,6 +327,75 @@ boolean isValid = WebhooksHelper.verifySignature(
);
```

## Reporting API

The [Reporting API](https://developer.squareup.com/docs/reporting-api/overview) lets you query aggregated reporting
data. Call `reporting().getMetadata()` first to discover the available cubes, measures, and dimensions, then run a query
with `reporting().load(...)`.

```java
import com.squareup.square.SquareClient;
import com.squareup.square.types.LoadRequest;
import com.squareup.square.types.LoadResponse;
import com.squareup.square.types.MetadataResponse;
import com.squareup.square.types.Query;
import java.util.Collections;

SquareClient client = SquareClient.builder().token("YOUR_TOKEN").build();

// Discover what you can query.
MetadataResponse metadata = client.reporting().getMetadata();

// Run a query against the discovered schema.
LoadResponse response = client.reporting()
.load(LoadRequest.builder()
.query(Query.builder()
.measures(Collections.singletonList("Orders.count"))
.build())
.build());
```

`load` is asynchronous: while a query is still being computed, the API returns an HTTP `200` whose body is
`{ "error": "Continue wait" }` instead of results, and the client is expected to re-send the identical request — with
backoff — until the results are ready. The `ReportingHelper.loadAndWait` utility owns that polling loop for you and
returns the resolved results (never the `"Continue wait"` sentinel):

```java
import com.squareup.square.types.LoadRequest;
import com.squareup.square.types.LoadResponse;
import com.squareup.square.types.Query;
import com.squareup.square.utilities.ReportingHelper;
import java.util.Collections;

LoadResponse response = ReportingHelper.loadAndWait(
client,
LoadRequest.builder()
.query(Query.builder()
.measures(Collections.singletonList("Orders.count"))
.build())
.build());

System.out.println(response.getResults());
```

By default it polls up to 20 times with exponential backoff (2s → 20s). Tune the behavior via `LoadAndWaitOptions`;
the poll loop also honors thread interruption, so cancelling the calling thread (or its `Future`) aborts an in-flight
wait:

```java
import com.squareup.square.utilities.LoadAndWaitOptions;

LoadResponse response = ReportingHelper.loadAndWait(
client,
request,
LoadAndWaitOptions.builder()
.maxAttempts(10) // default 20
.initialDelayMs(1000) // default 2000
.maxDelayMs(20000) // default 20000
.backoffFactor(2) // default 2
.build());
```

## Reference

A full reference for this library is available [here](https://github.com/square/square-java-sdk/blob/HEAD/./reference.md).
Expand Down Expand Up @@ -361,8 +431,8 @@ Gradle:

```groovy
dependencies {
implementation 'com.squareup:square:46.1.0.20260520'
implementation 'com.squareup:square-legacy:46.1.0.20260520'
implementation 'com.squareup:square:46.2.0.20260520'
implementation 'com.squareup:square-legacy:46.2.0.20260520'
}
```

Expand All @@ -372,12 +442,12 @@ Maven:
<dependency>
<groupId>com.squareup</groupId>
<artifactId>square</artifactId>
<version>46.1.0.20260520</version>
<version>46.2.0.20260520</version>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>square-legacy</artifactId>
<version>46.1.0.20260520</version>
<version>46.2.0.20260520</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ java {

group = 'com.squareup'

version = '46.1.0.20260520'
version = '46.2.0.20260520'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -78,7 +78,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.squareup'
artifactId = 'square'
version = '46.1.0.20260520'
version = '46.2.0.20260520'
from components.java
pom {
name = 'square'
Expand Down
114 changes: 114 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -16877,6 +16877,120 @@ client.vendors().update(
</dl>


</dd>
</dl>
</details>

## Reporting
<details><summary><code>client.reporting.getMetadata() -> MetadataResponse</code></summary>
<dl>
<dd>

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

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`.
</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```java
client.reporting().getMetadata();
```
</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.reporting.load(request) -> LoadResponse</code></summary>
<dl>
<dd>

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

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.
</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```java
client.reporting().load(
LoadRequest
.builder()
.build()
);
```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**queryType:** `Optional<String>`

</dd>
</dl>

<dl>
<dd>

**cache:** `Optional<CacheMode>`

</dd>
</dl>

<dl>
<dd>

**query:** `Optional<Query>`

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>
Expand Down
Loading
Loading