diff --git a/.fern/metadata.json b/.fern/metadata.json index b808b571..8361b736 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -13,5 +13,5 @@ "enable-forward-compatible-enums": true, "publish-to": "central" }, - "sdkVersion": "46.1.0.20260520" + "sdkVersion": "46.2.0.20260520" } \ No newline at end of file diff --git a/.fernignore b/.fernignore index c234b7f8..a058569e 100644 --- a/.fernignore +++ b/.fernignore @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d86befd..579ce9b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,7 @@ jobs: run: ./gradlew test -x :legacy-sdk:test env: TEST_SQUARE_TOKEN: ${{ secrets.TEST_SQUARE_TOKEN }} + TEST_SQUARE_REPORTING: ${{ secrets.TEST_SQUARE_REPORTING }} publish: needs: [ compile ] if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') diff --git a/README.md b/README.md index 6d9b3d4b..0c0b6286 100644 --- a/README.md +++ b/README.md @@ -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) @@ -56,7 +57,7 @@ Add the dependency in your `pom.xml` file: com.squareup square - 46.1.0.20260520 + 46.2.0.20260520 ``` @@ -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). @@ -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' } ``` @@ -372,12 +442,12 @@ Maven: com.squareup square - 46.1.0.20260520 + 46.2.0.20260520 com.squareup square-legacy - 46.1.0.20260520 + 46.2.0.20260520 ``` diff --git a/build.gradle b/build.gradle index 92366215..62dbd350 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ java { group = 'com.squareup' -version = '46.1.0.20260520' +version = '46.2.0.20260520' jar { dependsOn(":generatePomFileForMavenPublication") @@ -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' diff --git a/reference.md b/reference.md index b516def7..d7c2bd78 100644 --- a/reference.md +++ b/reference.md @@ -16877,6 +16877,120 @@ client.vendors().update( + + + + +## Reporting +
client.reporting.getMetadata() -> MetadataResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.reporting().getMetadata(); +``` +
+
+
+
+ + +
+
+
+ +
client.reporting.load(request) -> LoadResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.reporting().load( + LoadRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**queryType:** `Optional` + +
+
+ +
+
+ +**cache:** `Optional` + +
+
+ +
+
+ +**query:** `Optional` + +
+
+
+
+ +
diff --git a/src/main/java/com/squareup/square/AsyncRawReportingClient.java b/src/main/java/com/squareup/square/AsyncRawReportingClient.java new file mode 100644 index 00000000..264c01ac --- /dev/null +++ b/src/main/java/com/squareup/square/AsyncRawReportingClient.java @@ -0,0 +1,174 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.squareup.square.core.ClientOptions; +import com.squareup.square.core.MediaTypes; +import com.squareup.square.core.ObjectMappers; +import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SquareApiException; +import com.squareup.square.core.SquareClientHttpResponse; +import com.squareup.square.core.SquareException; +import com.squareup.square.types.LoadRequest; +import com.squareup.square.types.LoadResponse; +import com.squareup.square.types.MetadataResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawReportingClient { + protected final ClientOptions clientOptions; + + public AsyncRawReportingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * 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. + */ + public CompletableFuture> getMetadata() { + return getMetadata(null); + } + + /** + * 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. + */ + public CompletableFuture> getMetadata(RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("reporting/v1/meta"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, MetadataResponse.class), + response)); + return; + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new SquareException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new SquareException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * 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. + */ + public CompletableFuture> load() { + return load(LoadRequest.builder().build()); + } + + /** + * 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. + */ + public CompletableFuture> load(RequestOptions requestOptions) { + return load(LoadRequest.builder().build(), requestOptions); + } + + /** + * 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. + */ + public CompletableFuture> load(LoadRequest request) { + return load(request, null); + } + + /** + * 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. + */ + public CompletableFuture> load( + LoadRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("reporting/v1/load"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new SquareException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, LoadResponse.class), response)); + return; + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new SquareException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new SquareException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/squareup/square/AsyncReportingClient.java b/src/main/java/com/squareup/square/AsyncReportingClient.java new file mode 100644 index 00000000..8f2dc3a2 --- /dev/null +++ b/src/main/java/com/squareup/square/AsyncReportingClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square; + +import com.squareup.square.core.ClientOptions; +import com.squareup.square.core.RequestOptions; +import com.squareup.square.types.LoadRequest; +import com.squareup.square.types.LoadResponse; +import com.squareup.square.types.MetadataResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncReportingClient { + protected final ClientOptions clientOptions; + + private final AsyncRawReportingClient rawClient; + + public AsyncReportingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawReportingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawReportingClient withRawResponse() { + return this.rawClient; + } + + /** + * 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. + */ + public CompletableFuture getMetadata() { + return this.rawClient.getMetadata().thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture getMetadata(RequestOptions requestOptions) { + return this.rawClient.getMetadata(requestOptions).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture load() { + return this.rawClient.load().thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture load(RequestOptions requestOptions) { + return this.rawClient.load(requestOptions).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture load(LoadRequest request) { + return this.rawClient.load(request).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture load(LoadRequest request, RequestOptions requestOptions) { + return this.rawClient.load(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/squareup/square/AsyncSquareClient.java b/src/main/java/com/squareup/square/AsyncSquareClient.java index 0d903b97..f82027b8 100644 --- a/src/main/java/com/squareup/square/AsyncSquareClient.java +++ b/src/main/java/com/squareup/square/AsyncSquareClient.java @@ -78,6 +78,8 @@ public class AsyncSquareClient { protected final Supplier vendorsClient; + protected final Supplier reportingClient; + protected final Supplier cashDrawersClient; protected final Supplier webhooksClient; @@ -117,6 +119,7 @@ public AsyncSquareClient(ClientOptions clientOptions) { this.terminalClient = Suppliers.memoize(() -> new AsyncTerminalClient(clientOptions)); this.transferOrdersClient = Suppliers.memoize(() -> new AsyncTransferOrdersClient(clientOptions)); this.vendorsClient = Suppliers.memoize(() -> new AsyncVendorsClient(clientOptions)); + this.reportingClient = Suppliers.memoize(() -> new AsyncReportingClient(clientOptions)); this.cashDrawersClient = Suppliers.memoize(() -> new AsyncCashDrawersClient(clientOptions)); this.webhooksClient = Suppliers.memoize(() -> new AsyncWebhooksClient(clientOptions)); } @@ -253,6 +256,10 @@ public AsyncVendorsClient vendors() { return this.vendorsClient.get(); } + public AsyncReportingClient reporting() { + return this.reportingClient.get(); + } + public AsyncCashDrawersClient cashDrawers() { return this.cashDrawersClient.get(); } diff --git a/src/main/java/com/squareup/square/RawReportingClient.java b/src/main/java/com/squareup/square/RawReportingClient.java new file mode 100644 index 00000000..bcc83dac --- /dev/null +++ b/src/main/java/com/squareup/square/RawReportingClient.java @@ -0,0 +1,142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.squareup.square.core.ClientOptions; +import com.squareup.square.core.MediaTypes; +import com.squareup.square.core.ObjectMappers; +import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SquareApiException; +import com.squareup.square.core.SquareClientHttpResponse; +import com.squareup.square.core.SquareException; +import com.squareup.square.types.LoadRequest; +import com.squareup.square.types.LoadResponse; +import com.squareup.square.types.MetadataResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawReportingClient { + protected final ClientOptions clientOptions; + + public RawReportingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * 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. + */ + public SquareClientHttpResponse getMetadata() { + return getMetadata(null); + } + + /** + * 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. + */ + public SquareClientHttpResponse getMetadata(RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("reporting/v1/meta"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, MetadataResponse.class), response); + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new SquareApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + /** + * 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. + */ + public SquareClientHttpResponse load() { + return load(LoadRequest.builder().build()); + } + + /** + * 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. + */ + public SquareClientHttpResponse load(RequestOptions requestOptions) { + return load(LoadRequest.builder().build(), requestOptions); + } + + /** + * 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. + */ + public SquareClientHttpResponse load(LoadRequest request) { + return load(request, null); + } + + /** + * 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. + */ + public SquareClientHttpResponse load(LoadRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("reporting/v1/load"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new SquareException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, LoadResponse.class), response); + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new SquareApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/squareup/square/ReportingClient.java b/src/main/java/com/squareup/square/ReportingClient.java new file mode 100644 index 00000000..f822d3ea --- /dev/null +++ b/src/main/java/com/squareup/square/ReportingClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square; + +import com.squareup.square.core.ClientOptions; +import com.squareup.square.core.RequestOptions; +import com.squareup.square.types.LoadRequest; +import com.squareup.square.types.LoadResponse; +import com.squareup.square.types.MetadataResponse; + +public class ReportingClient { + protected final ClientOptions clientOptions; + + private final RawReportingClient rawClient; + + public ReportingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawReportingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawReportingClient withRawResponse() { + return this.rawClient; + } + + /** + * 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. + */ + public MetadataResponse getMetadata() { + return this.rawClient.getMetadata().body(); + } + + /** + * 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. + */ + public MetadataResponse getMetadata(RequestOptions requestOptions) { + return this.rawClient.getMetadata(requestOptions).body(); + } + + /** + * 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. + */ + public LoadResponse load() { + return this.rawClient.load().body(); + } + + /** + * 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. + */ + public LoadResponse load(RequestOptions requestOptions) { + return this.rawClient.load(requestOptions).body(); + } + + /** + * 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. + */ + public LoadResponse load(LoadRequest request) { + return this.rawClient.load(request).body(); + } + + /** + * 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. + */ + public LoadResponse load(LoadRequest request, RequestOptions requestOptions) { + return this.rawClient.load(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/squareup/square/SquareClient.java b/src/main/java/com/squareup/square/SquareClient.java index e0a7ef23..dee4f5fa 100644 --- a/src/main/java/com/squareup/square/SquareClient.java +++ b/src/main/java/com/squareup/square/SquareClient.java @@ -78,6 +78,8 @@ public class SquareClient { protected final Supplier vendorsClient; + protected final Supplier reportingClient; + protected final Supplier cashDrawersClient; protected final Supplier webhooksClient; @@ -117,6 +119,7 @@ public SquareClient(ClientOptions clientOptions) { this.terminalClient = Suppliers.memoize(() -> new TerminalClient(clientOptions)); this.transferOrdersClient = Suppliers.memoize(() -> new TransferOrdersClient(clientOptions)); this.vendorsClient = Suppliers.memoize(() -> new VendorsClient(clientOptions)); + this.reportingClient = Suppliers.memoize(() -> new ReportingClient(clientOptions)); this.cashDrawersClient = Suppliers.memoize(() -> new CashDrawersClient(clientOptions)); this.webhooksClient = Suppliers.memoize(() -> new WebhooksClient(clientOptions)); } @@ -253,6 +256,10 @@ public VendorsClient vendors() { return this.vendorsClient.get(); } + public ReportingClient reporting() { + return this.reportingClient.get(); + } + public CashDrawersClient cashDrawers() { return this.cashDrawersClient.get(); } diff --git a/src/main/java/com/squareup/square/core/ClientOptions.java b/src/main/java/com/squareup/square/core/ClientOptions.java index f1d3f7d7..e31249e9 100644 --- a/src/main/java/com/squareup/square/core/ClientOptions.java +++ b/src/main/java/com/squareup/square/core/ClientOptions.java @@ -38,10 +38,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.squareup:square/46.1.0.20260520"); + put("User-Agent", "com.squareup:square/46.2.0.20260520"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.square.fern:api-sdk"); - put("X-Fern-SDK-Version", "46.1.0.20260520"); + put("X-Fern-SDK-Version", "46.2.0.20260520"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/squareup/square/types/CacheMode.java b/src/main/java/com/squareup/square/types/CacheMode.java new file mode 100644 index 00000000..9edef9db --- /dev/null +++ b/src/main/java/com/squareup/square/types/CacheMode.java @@ -0,0 +1,103 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CacheMode { + public static final CacheMode MUST_REVALIDATE = new CacheMode(Value.MUST_REVALIDATE, "must-revalidate"); + + public static final CacheMode NO_CACHE = new CacheMode(Value.NO_CACHE, "no-cache"); + + public static final CacheMode STALE_WHILE_REVALIDATE = + new CacheMode(Value.STALE_WHILE_REVALIDATE, "stale-while-revalidate"); + + public static final CacheMode STALE_IF_SLOW = new CacheMode(Value.STALE_IF_SLOW, "stale-if-slow"); + + private final Value value; + + private final String string; + + CacheMode(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof CacheMode && this.string.equals(((CacheMode) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case MUST_REVALIDATE: + return visitor.visitMustRevalidate(); + case NO_CACHE: + return visitor.visitNoCache(); + case STALE_WHILE_REVALIDATE: + return visitor.visitStaleWhileRevalidate(); + case STALE_IF_SLOW: + return visitor.visitStaleIfSlow(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CacheMode valueOf(String value) { + switch (value) { + case "must-revalidate": + return MUST_REVALIDATE; + case "no-cache": + return NO_CACHE; + case "stale-while-revalidate": + return STALE_WHILE_REVALIDATE; + case "stale-if-slow": + return STALE_IF_SLOW; + default: + return new CacheMode(Value.UNKNOWN, value); + } + } + + public enum Value { + STALE_IF_SLOW, + + STALE_WHILE_REVALIDATE, + + MUST_REVALIDATE, + + NO_CACHE, + + UNKNOWN + } + + public interface Visitor { + T visitStaleIfSlow(); + + T visitStaleWhileRevalidate(); + + T visitMustRevalidate(); + + T visitNoCache(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/squareup/square/types/Cube.java b/src/main/java/com/squareup/square/types/Cube.java new file mode 100644 index 00000000..85eb9fe6 --- /dev/null +++ b/src/main/java/com/squareup/square/types/Cube.java @@ -0,0 +1,512 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Cube.Builder.class) +public final class Cube { + private final String name; + + private final Optional title; + + private final CubeType type; + + private final Optional> meta; + + private final Optional description; + + private final List measures; + + private final List dimensions; + + private final List segments; + + private final Optional> joins; + + private final Optional> folders; + + private final Optional> nestedFolders; + + private final Optional> hierarchies; + + private final Map additionalProperties; + + private Cube( + String name, + Optional title, + CubeType type, + Optional> meta, + Optional description, + List measures, + List dimensions, + List segments, + Optional> joins, + Optional> folders, + Optional> nestedFolders, + Optional> hierarchies, + Map additionalProperties) { + this.name = name; + this.title = title; + this.type = type; + this.meta = meta; + this.description = description; + this.measures = measures; + this.dimensions = dimensions; + this.segments = segments; + this.joins = joins; + this.folders = folders; + this.nestedFolders = nestedFolders; + this.hierarchies = hierarchies; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + @JsonProperty("type") + public CubeType getType() { + return type; + } + + @JsonProperty("meta") + public Optional> getMeta() { + return meta; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("measures") + public List getMeasures() { + return measures; + } + + @JsonProperty("dimensions") + public List getDimensions() { + return dimensions; + } + + @JsonProperty("segments") + public List getSegments() { + return segments; + } + + @JsonProperty("joins") + public Optional> getJoins() { + return joins; + } + + @JsonProperty("folders") + public Optional> getFolders() { + return folders; + } + + @JsonProperty("nestedFolders") + public Optional> getNestedFolders() { + return nestedFolders; + } + + @JsonProperty("hierarchies") + public Optional> getHierarchies() { + return hierarchies; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Cube && equalTo((Cube) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Cube other) { + return name.equals(other.name) + && title.equals(other.title) + && type.equals(other.type) + && meta.equals(other.meta) + && description.equals(other.description) + && measures.equals(other.measures) + && dimensions.equals(other.dimensions) + && segments.equals(other.segments) + && joins.equals(other.joins) + && folders.equals(other.folders) + && nestedFolders.equals(other.nestedFolders) + && hierarchies.equals(other.hierarchies); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.title, + this.type, + this.meta, + this.description, + this.measures, + this.dimensions, + this.segments, + this.joins, + this.folders, + this.nestedFolders, + this.hierarchies); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + TypeStage name(@NotNull String name); + + Builder from(Cube other); + } + + public interface TypeStage { + _FinalStage type(@NotNull CubeType type); + } + + public interface _FinalStage { + Cube build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage title(Optional title); + + _FinalStage title(String title); + + _FinalStage meta(Optional> meta); + + _FinalStage meta(Map meta); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage measures(List measures); + + _FinalStage addMeasures(Measure measures); + + _FinalStage addAllMeasures(List measures); + + _FinalStage dimensions(List dimensions); + + _FinalStage addDimensions(Dimension dimensions); + + _FinalStage addAllDimensions(List dimensions); + + _FinalStage segments(List segments); + + _FinalStage addSegments(Segment segments); + + _FinalStage addAllSegments(List segments); + + _FinalStage joins(Optional> joins); + + _FinalStage joins(List joins); + + _FinalStage folders(Optional> folders); + + _FinalStage folders(List folders); + + _FinalStage nestedFolders(Optional> nestedFolders); + + _FinalStage nestedFolders(List nestedFolders); + + _FinalStage hierarchies(Optional> hierarchies); + + _FinalStage hierarchies(List hierarchies); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, TypeStage, _FinalStage { + private String name; + + private CubeType type; + + private Optional> hierarchies = Optional.empty(); + + private Optional> nestedFolders = Optional.empty(); + + private Optional> folders = Optional.empty(); + + private Optional> joins = Optional.empty(); + + private List segments = new ArrayList<>(); + + private List dimensions = new ArrayList<>(); + + private List measures = new ArrayList<>(); + + private Optional description = Optional.empty(); + + private Optional> meta = Optional.empty(); + + private Optional title = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Cube other) { + name(other.getName()); + title(other.getTitle()); + type(other.getType()); + meta(other.getMeta()); + description(other.getDescription()); + measures(other.getMeasures()); + dimensions(other.getDimensions()); + segments(other.getSegments()); + joins(other.getJoins()); + folders(other.getFolders()); + nestedFolders(other.getNestedFolders()); + hierarchies(other.getHierarchies()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public TypeStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("type") + public _FinalStage type(@NotNull CubeType type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage hierarchies(List hierarchies) { + this.hierarchies = Optional.ofNullable(hierarchies); + return this; + } + + @java.lang.Override + @JsonSetter(value = "hierarchies", nulls = Nulls.SKIP) + public _FinalStage hierarchies(Optional> hierarchies) { + this.hierarchies = hierarchies; + return this; + } + + @java.lang.Override + public _FinalStage nestedFolders(List nestedFolders) { + this.nestedFolders = Optional.ofNullable(nestedFolders); + return this; + } + + @java.lang.Override + @JsonSetter(value = "nestedFolders", nulls = Nulls.SKIP) + public _FinalStage nestedFolders(Optional> nestedFolders) { + this.nestedFolders = nestedFolders; + return this; + } + + @java.lang.Override + public _FinalStage folders(List folders) { + this.folders = Optional.ofNullable(folders); + return this; + } + + @java.lang.Override + @JsonSetter(value = "folders", nulls = Nulls.SKIP) + public _FinalStage folders(Optional> folders) { + this.folders = folders; + return this; + } + + @java.lang.Override + public _FinalStage joins(List joins) { + this.joins = Optional.ofNullable(joins); + return this; + } + + @java.lang.Override + @JsonSetter(value = "joins", nulls = Nulls.SKIP) + public _FinalStage joins(Optional> joins) { + this.joins = joins; + return this; + } + + @java.lang.Override + public _FinalStage addAllSegments(List segments) { + if (segments != null) { + this.segments.addAll(segments); + } + return this; + } + + @java.lang.Override + public _FinalStage addSegments(Segment segments) { + this.segments.add(segments); + return this; + } + + @java.lang.Override + @JsonSetter(value = "segments", nulls = Nulls.SKIP) + public _FinalStage segments(List segments) { + this.segments.clear(); + if (segments != null) { + this.segments.addAll(segments); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllDimensions(List dimensions) { + if (dimensions != null) { + this.dimensions.addAll(dimensions); + } + return this; + } + + @java.lang.Override + public _FinalStage addDimensions(Dimension dimensions) { + this.dimensions.add(dimensions); + return this; + } + + @java.lang.Override + @JsonSetter(value = "dimensions", nulls = Nulls.SKIP) + public _FinalStage dimensions(List dimensions) { + this.dimensions.clear(); + if (dimensions != null) { + this.dimensions.addAll(dimensions); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllMeasures(List measures) { + if (measures != null) { + this.measures.addAll(measures); + } + return this; + } + + @java.lang.Override + public _FinalStage addMeasures(Measure measures) { + this.measures.add(measures); + return this; + } + + @java.lang.Override + @JsonSetter(value = "measures", nulls = Nulls.SKIP) + public _FinalStage measures(List measures) { + this.measures.clear(); + if (measures != null) { + this.measures.addAll(measures); + } + return this; + } + + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public _FinalStage meta(Map meta) { + this.meta = Optional.ofNullable(meta); + return this; + } + + @java.lang.Override + @JsonSetter(value = "meta", nulls = Nulls.SKIP) + public _FinalStage meta(Optional> meta) { + this.meta = meta; + return this; + } + + @java.lang.Override + public _FinalStage title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + return this; + } + + @java.lang.Override + public Cube build() { + return new Cube( + name, + title, + type, + meta, + description, + measures, + dimensions, + segments, + joins, + folders, + nestedFolders, + hierarchies, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/CubeJoin.java b/src/main/java/com/squareup/square/types/CubeJoin.java new file mode 100644 index 00000000..1bb67d79 --- /dev/null +++ b/src/main/java/com/squareup/square/types/CubeJoin.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CubeJoin.Builder.class) +public final class CubeJoin { + private final String name; + + private final String relationship; + + private final Map additionalProperties; + + private CubeJoin(String name, String relationship, Map additionalProperties) { + this.name = name; + this.relationship = relationship; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("relationship") + public String getRelationship() { + return relationship; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CubeJoin && equalTo((CubeJoin) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CubeJoin other) { + return name.equals(other.name) && relationship.equals(other.relationship); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.relationship); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + RelationshipStage name(@NotNull String name); + + Builder from(CubeJoin other); + } + + public interface RelationshipStage { + _FinalStage relationship(@NotNull String relationship); + } + + public interface _FinalStage { + CubeJoin build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, RelationshipStage, _FinalStage { + private String name; + + private String relationship; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CubeJoin other) { + name(other.getName()); + relationship(other.getRelationship()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public RelationshipStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("relationship") + public _FinalStage relationship(@NotNull String relationship) { + this.relationship = Objects.requireNonNull(relationship, "relationship must not be null"); + return this; + } + + @java.lang.Override + public CubeJoin build() { + return new CubeJoin(name, relationship, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/CubeType.java b/src/main/java/com/squareup/square/types/CubeType.java new file mode 100644 index 00000000..75d6386f --- /dev/null +++ b/src/main/java/com/squareup/square/types/CubeType.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CubeType { + public static final CubeType VIEW = new CubeType(Value.VIEW, "view"); + + public static final CubeType CUBE = new CubeType(Value.CUBE, "cube"); + + private final Value value; + + private final String string; + + CubeType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof CubeType && this.string.equals(((CubeType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case VIEW: + return visitor.visitView(); + case CUBE: + return visitor.visitCube(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CubeType valueOf(String value) { + switch (value) { + case "view": + return VIEW; + case "cube": + return CUBE; + default: + return new CubeType(Value.UNKNOWN, value); + } + } + + public enum Value { + CUBE, + + VIEW, + + UNKNOWN + } + + public interface Visitor { + T visitCube(); + + T visitView(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/squareup/square/types/CustomNumericFormat.java b/src/main/java/com/squareup/square/types/CustomNumericFormat.java new file mode 100644 index 00000000..9dac6ed9 --- /dev/null +++ b/src/main/java/com/squareup/square/types/CustomNumericFormat.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CustomNumericFormat.Builder.class) +public final class CustomNumericFormat { + private final String value; + + private final Optional alias; + + private final Map additionalProperties; + + private CustomNumericFormat(String value, Optional alias, Map additionalProperties) { + this.value = value; + this.alias = alias; + this.additionalProperties = additionalProperties; + } + + /** + * @return Type of the format (must be 'custom-numeric') + */ + @JsonProperty("type") + public String getType() { + return "custom-numeric"; + } + + /** + * @return d3-format specifier string (e.g., '.2f', ',.0f', '$,.2f', '.0%', '.2s'). See https://d3js.org/d3-format + */ + @JsonProperty("value") + public String getValue() { + return value; + } + + /** + * @return Name of the predefined format (e.g., 'percent_2', 'currency_1'). Present only when a named format was used. + */ + @JsonProperty("alias") + public Optional getAlias() { + return alias; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CustomNumericFormat && equalTo((CustomNumericFormat) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CustomNumericFormat other) { + return value.equals(other.value) && alias.equals(other.alias); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value, this.alias); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ValueStage builder() { + return new Builder(); + } + + public interface ValueStage { + /** + *

d3-format specifier string (e.g., '.2f', ',.0f', '$,.2f', '.0%', '.2s'). See https://d3js.org/d3-format

+ */ + _FinalStage value(@NotNull String value); + + Builder from(CustomNumericFormat other); + } + + public interface _FinalStage { + CustomNumericFormat build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Name of the predefined format (e.g., 'percent_2', 'currency_1'). Present only when a named format was used.

+ */ + _FinalStage alias(Optional alias); + + _FinalStage alias(String alias); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ValueStage, _FinalStage { + private String value; + + private Optional alias = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CustomNumericFormat other) { + value(other.getValue()); + alias(other.getAlias()); + return this; + } + + /** + *

d3-format specifier string (e.g., '.2f', ',.0f', '$,.2f', '.0%', '.2s'). See https://d3js.org/d3-format

+ *

d3-format specifier string (e.g., '.2f', ',.0f', '$,.2f', '.0%', '.2s'). See https://d3js.org/d3-format

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("value") + public _FinalStage value(@NotNull String value) { + this.value = Objects.requireNonNull(value, "value must not be null"); + return this; + } + + /** + *

Name of the predefined format (e.g., 'percent_2', 'currency_1'). Present only when a named format was used.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage alias(String alias) { + this.alias = Optional.ofNullable(alias); + return this; + } + + /** + *

Name of the predefined format (e.g., 'percent_2', 'currency_1'). Present only when a named format was used.

+ */ + @java.lang.Override + @JsonSetter(value = "alias", nulls = Nulls.SKIP) + public _FinalStage alias(Optional alias) { + this.alias = alias; + return this; + } + + @java.lang.Override + public CustomNumericFormat build() { + return new CustomNumericFormat(value, alias, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/CustomTimeFormat.java b/src/main/java/com/squareup/square/types/CustomTimeFormat.java new file mode 100644 index 00000000..d6723feb --- /dev/null +++ b/src/main/java/com/squareup/square/types/CustomTimeFormat.java @@ -0,0 +1,137 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CustomTimeFormat.Builder.class) +public final class CustomTimeFormat { + private final String value; + + private final Map additionalProperties; + + private CustomTimeFormat(String value, Map additionalProperties) { + this.value = value; + this.additionalProperties = additionalProperties; + } + + /** + * @return Type of the format (must be 'custom-time') + */ + @JsonProperty("type") + public String getType() { + return "custom-time"; + } + + /** + * @return POSIX strftime format string (IEEE Std 1003.1 / POSIX.1) with d3-time-format extensions (e.g., '%Y-%m-%d', '%d/%m/%Y %H:%M:%S'). See https://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html and https://d3js.org/d3-time-format + */ + @JsonProperty("value") + public String getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CustomTimeFormat && equalTo((CustomTimeFormat) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CustomTimeFormat other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ValueStage builder() { + return new Builder(); + } + + public interface ValueStage { + /** + *

POSIX strftime format string (IEEE Std 1003.1 / POSIX.1) with d3-time-format extensions (e.g., '%Y-%m-%d', '%d/%m/%Y %H:%M:%S'). See https://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html and https://d3js.org/d3-time-format

+ */ + _FinalStage value(@NotNull String value); + + Builder from(CustomTimeFormat other); + } + + public interface _FinalStage { + CustomTimeFormat build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ValueStage, _FinalStage { + private String value; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CustomTimeFormat other) { + value(other.getValue()); + return this; + } + + /** + *

POSIX strftime format string (IEEE Std 1003.1 / POSIX.1) with d3-time-format extensions (e.g., '%Y-%m-%d', '%d/%m/%Y %H:%M:%S'). See https://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html and https://d3js.org/d3-time-format

+ *

POSIX strftime format string (IEEE Std 1003.1 / POSIX.1) with d3-time-format extensions (e.g., '%Y-%m-%d', '%d/%m/%Y %H:%M:%S'). See https://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html and https://d3js.org/d3-time-format

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("value") + public _FinalStage value(@NotNull String value) { + this.value = Objects.requireNonNull(value, "value must not be null"); + return this; + } + + @java.lang.Override + public CustomTimeFormat build() { + return new CustomTimeFormat(value, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/Dimension.java b/src/main/java/com/squareup/square/types/Dimension.java new file mode 100644 index 00000000..a85fe8e0 --- /dev/null +++ b/src/main/java/com/squareup/square/types/Dimension.java @@ -0,0 +1,543 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Dimension.Builder.class) +public final class Dimension { + private final String name; + + private final Optional title; + + private final Optional shortTitle; + + private final Optional description; + + private final String type; + + private final Optional aliasMember; + + private final Optional> granularities; + + private final Optional> meta; + + private final Optional format; + + private final Optional formatDescription; + + private final Optional currency; + + private final Optional order; + + private final Optional key; + + private final Map additionalProperties; + + private Dimension( + String name, + Optional title, + Optional shortTitle, + Optional description, + String type, + Optional aliasMember, + Optional> granularities, + Optional> meta, + Optional format, + Optional formatDescription, + Optional currency, + Optional order, + Optional key, + Map additionalProperties) { + this.name = name; + this.title = title; + this.shortTitle = shortTitle; + this.description = description; + this.type = type; + this.aliasMember = aliasMember; + this.granularities = granularities; + this.meta = meta; + this.format = format; + this.formatDescription = formatDescription; + this.currency = currency; + this.order = order; + this.key = key; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + @JsonProperty("shortTitle") + public Optional getShortTitle() { + return shortTitle; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * @return When dimension is defined in View, it keeps the original path: Cube.dimension + */ + @JsonProperty("aliasMember") + public Optional getAliasMember() { + return aliasMember; + } + + @JsonProperty("granularities") + public Optional> getGranularities() { + return granularities; + } + + @JsonProperty("meta") + public Optional> getMeta() { + return meta; + } + + @JsonProperty("format") + public Optional getFormat() { + return format; + } + + @JsonProperty("formatDescription") + public Optional getFormatDescription() { + return formatDescription; + } + + /** + * @return ISO 4217 currency code in uppercase (3 characters, e.g. USD, EUR) + */ + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + + @JsonProperty("order") + public Optional getOrder() { + return order; + } + + /** + * @return Key reference for the dimension + */ + @JsonProperty("key") + public Optional getKey() { + return key; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Dimension && equalTo((Dimension) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Dimension other) { + return name.equals(other.name) + && title.equals(other.title) + && shortTitle.equals(other.shortTitle) + && description.equals(other.description) + && type.equals(other.type) + && aliasMember.equals(other.aliasMember) + && granularities.equals(other.granularities) + && meta.equals(other.meta) + && format.equals(other.format) + && formatDescription.equals(other.formatDescription) + && currency.equals(other.currency) + && order.equals(other.order) + && key.equals(other.key); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.title, + this.shortTitle, + this.description, + this.type, + this.aliasMember, + this.granularities, + this.meta, + this.format, + this.formatDescription, + this.currency, + this.order, + this.key); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + TypeStage name(@NotNull String name); + + Builder from(Dimension other); + } + + public interface TypeStage { + _FinalStage type(@NotNull String type); + } + + public interface _FinalStage { + Dimension build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage title(Optional title); + + _FinalStage title(String title); + + _FinalStage shortTitle(Optional shortTitle); + + _FinalStage shortTitle(String shortTitle); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + /** + *

When dimension is defined in View, it keeps the original path: Cube.dimension

+ */ + _FinalStage aliasMember(Optional aliasMember); + + _FinalStage aliasMember(String aliasMember); + + _FinalStage granularities(Optional> granularities); + + _FinalStage granularities(List granularities); + + _FinalStage meta(Optional> meta); + + _FinalStage meta(Map meta); + + _FinalStage format(Optional format); + + _FinalStage format(Format format); + + _FinalStage formatDescription(Optional formatDescription); + + _FinalStage formatDescription(FormatDescription formatDescription); + + /** + *

ISO 4217 currency code in uppercase (3 characters, e.g. USD, EUR)

+ */ + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + + _FinalStage order(Optional order); + + _FinalStage order(DimensionOrder order); + + /** + *

Key reference for the dimension

+ */ + _FinalStage key(Optional key); + + _FinalStage key(String key); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, TypeStage, _FinalStage { + private String name; + + private String type; + + private Optional key = Optional.empty(); + + private Optional order = Optional.empty(); + + private Optional currency = Optional.empty(); + + private Optional formatDescription = Optional.empty(); + + private Optional format = Optional.empty(); + + private Optional> meta = Optional.empty(); + + private Optional> granularities = Optional.empty(); + + private Optional aliasMember = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional shortTitle = Optional.empty(); + + private Optional title = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Dimension other) { + name(other.getName()); + title(other.getTitle()); + shortTitle(other.getShortTitle()); + description(other.getDescription()); + type(other.getType()); + aliasMember(other.getAliasMember()); + granularities(other.getGranularities()); + meta(other.getMeta()); + format(other.getFormat()); + formatDescription(other.getFormatDescription()); + currency(other.getCurrency()); + order(other.getOrder()); + key(other.getKey()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public TypeStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("type") + public _FinalStage type(@NotNull String type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + /** + *

Key reference for the dimension

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage key(String key) { + this.key = Optional.ofNullable(key); + return this; + } + + /** + *

Key reference for the dimension

+ */ + @java.lang.Override + @JsonSetter(value = "key", nulls = Nulls.SKIP) + public _FinalStage key(Optional key) { + this.key = key; + return this; + } + + @java.lang.Override + public _FinalStage order(DimensionOrder order) { + this.order = Optional.ofNullable(order); + return this; + } + + @java.lang.Override + @JsonSetter(value = "order", nulls = Nulls.SKIP) + public _FinalStage order(Optional order) { + this.order = order; + return this; + } + + /** + *

ISO 4217 currency code in uppercase (3 characters, e.g. USD, EUR)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage currency(String currency) { + this.currency = Optional.ofNullable(currency); + return this; + } + + /** + *

ISO 4217 currency code in uppercase (3 characters, e.g. USD, EUR)

+ */ + @java.lang.Override + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public _FinalStage currency(Optional currency) { + this.currency = currency; + return this; + } + + @java.lang.Override + public _FinalStage formatDescription(FormatDescription formatDescription) { + this.formatDescription = Optional.ofNullable(formatDescription); + return this; + } + + @java.lang.Override + @JsonSetter(value = "formatDescription", nulls = Nulls.SKIP) + public _FinalStage formatDescription(Optional formatDescription) { + this.formatDescription = formatDescription; + return this; + } + + @java.lang.Override + public _FinalStage format(Format format) { + this.format = Optional.ofNullable(format); + return this; + } + + @java.lang.Override + @JsonSetter(value = "format", nulls = Nulls.SKIP) + public _FinalStage format(Optional format) { + this.format = format; + return this; + } + + @java.lang.Override + public _FinalStage meta(Map meta) { + this.meta = Optional.ofNullable(meta); + return this; + } + + @java.lang.Override + @JsonSetter(value = "meta", nulls = Nulls.SKIP) + public _FinalStage meta(Optional> meta) { + this.meta = meta; + return this; + } + + @java.lang.Override + public _FinalStage granularities(List granularities) { + this.granularities = Optional.ofNullable(granularities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "granularities", nulls = Nulls.SKIP) + public _FinalStage granularities(Optional> granularities) { + this.granularities = granularities; + return this; + } + + /** + *

When dimension is defined in View, it keeps the original path: Cube.dimension

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage aliasMember(String aliasMember) { + this.aliasMember = Optional.ofNullable(aliasMember); + return this; + } + + /** + *

When dimension is defined in View, it keeps the original path: Cube.dimension

+ */ + @java.lang.Override + @JsonSetter(value = "aliasMember", nulls = Nulls.SKIP) + public _FinalStage aliasMember(Optional aliasMember) { + this.aliasMember = aliasMember; + return this; + } + + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public _FinalStage shortTitle(String shortTitle) { + this.shortTitle = Optional.ofNullable(shortTitle); + return this; + } + + @java.lang.Override + @JsonSetter(value = "shortTitle", nulls = Nulls.SKIP) + public _FinalStage shortTitle(Optional shortTitle) { + this.shortTitle = shortTitle; + return this; + } + + @java.lang.Override + public _FinalStage title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + return this; + } + + @java.lang.Override + public Dimension build() { + return new Dimension( + name, + title, + shortTitle, + description, + type, + aliasMember, + granularities, + meta, + format, + formatDescription, + currency, + order, + key, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/DimensionGranularity.java b/src/main/java/com/squareup/square/types/DimensionGranularity.java new file mode 100644 index 00000000..0eaa4603 --- /dev/null +++ b/src/main/java/com/squareup/square/types/DimensionGranularity.java @@ -0,0 +1,266 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DimensionGranularity.Builder.class) +public final class DimensionGranularity { + private final String name; + + private final String title; + + private final Optional interval; + + private final Optional sql; + + private final Optional offset; + + private final Optional origin; + + private final Map additionalProperties; + + private DimensionGranularity( + String name, + String title, + Optional interval, + Optional sql, + Optional offset, + Optional origin, + Map additionalProperties) { + this.name = name; + this.title = title; + this.interval = interval; + this.sql = sql; + this.offset = offset; + this.origin = origin; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("title") + public String getTitle() { + return title; + } + + @JsonProperty("interval") + public Optional getInterval() { + return interval; + } + + @JsonProperty("sql") + public Optional getSql() { + return sql; + } + + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("origin") + public Optional getOrigin() { + return origin; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DimensionGranularity && equalTo((DimensionGranularity) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DimensionGranularity other) { + return name.equals(other.name) + && title.equals(other.title) + && interval.equals(other.interval) + && sql.equals(other.sql) + && offset.equals(other.offset) + && origin.equals(other.origin); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.title, this.interval, this.sql, this.offset, this.origin); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + TitleStage name(@NotNull String name); + + Builder from(DimensionGranularity other); + } + + public interface TitleStage { + _FinalStage title(@NotNull String title); + } + + public interface _FinalStage { + DimensionGranularity build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage interval(Optional interval); + + _FinalStage interval(String interval); + + _FinalStage sql(Optional sql); + + _FinalStage sql(String sql); + + _FinalStage offset(Optional offset); + + _FinalStage offset(String offset); + + _FinalStage origin(Optional origin); + + _FinalStage origin(String origin); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, TitleStage, _FinalStage { + private String name; + + private String title; + + private Optional origin = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional sql = Optional.empty(); + + private Optional interval = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DimensionGranularity other) { + name(other.getName()); + title(other.getTitle()); + interval(other.getInterval()); + sql(other.getSql()); + offset(other.getOffset()); + origin(other.getOrigin()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public TitleStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("title") + public _FinalStage title(@NotNull String title) { + this.title = Objects.requireNonNull(title, "title must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage origin(String origin) { + this.origin = Optional.ofNullable(origin); + return this; + } + + @java.lang.Override + @JsonSetter(value = "origin", nulls = Nulls.SKIP) + public _FinalStage origin(Optional origin) { + this.origin = origin; + return this; + } + + @java.lang.Override + public _FinalStage offset(String offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @java.lang.Override + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public _FinalStage offset(Optional offset) { + this.offset = offset; + return this; + } + + @java.lang.Override + public _FinalStage sql(String sql) { + this.sql = Optional.ofNullable(sql); + return this; + } + + @java.lang.Override + @JsonSetter(value = "sql", nulls = Nulls.SKIP) + public _FinalStage sql(Optional sql) { + this.sql = sql; + return this; + } + + @java.lang.Override + public _FinalStage interval(String interval) { + this.interval = Optional.ofNullable(interval); + return this; + } + + @java.lang.Override + @JsonSetter(value = "interval", nulls = Nulls.SKIP) + public _FinalStage interval(Optional interval) { + this.interval = interval; + return this; + } + + @java.lang.Override + public DimensionGranularity build() { + return new DimensionGranularity(name, title, interval, sql, offset, origin, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/DimensionOrder.java b/src/main/java/com/squareup/square/types/DimensionOrder.java new file mode 100644 index 00000000..b1768241 --- /dev/null +++ b/src/main/java/com/squareup/square/types/DimensionOrder.java @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class DimensionOrder { + public static final DimensionOrder ASC = new DimensionOrder(Value.ASC, "asc"); + + public static final DimensionOrder DESC = new DimensionOrder(Value.DESC, "desc"); + + private final Value value; + + private final String string; + + DimensionOrder(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof DimensionOrder && this.string.equals(((DimensionOrder) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ASC: + return visitor.visitAsc(); + case DESC: + return visitor.visitDesc(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DimensionOrder valueOf(String value) { + switch (value) { + case "asc": + return ASC; + case "desc": + return DESC; + default: + return new DimensionOrder(Value.UNKNOWN, value); + } + } + + public enum Value { + ASC, + + DESC, + + UNKNOWN + } + + public interface Visitor { + T visitAsc(); + + T visitDesc(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/squareup/square/types/Folder.java b/src/main/java/com/squareup/square/types/Folder.java new file mode 100644 index 00000000..053be07c --- /dev/null +++ b/src/main/java/com/squareup/square/types/Folder.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Folder.Builder.class) +public final class Folder { + private final String name; + + private final List members; + + private final Map additionalProperties; + + private Folder(String name, List members, Map additionalProperties) { + this.name = name; + this.members = members; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("members") + public List getMembers() { + return members; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Folder && equalTo((Folder) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Folder other) { + return name.equals(other.name) && members.equals(other.members); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.members); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + + Builder from(Folder other); + } + + public interface _FinalStage { + Folder build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage members(List members); + + _FinalStage addMembers(String members); + + _FinalStage addAllMembers(List members); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, _FinalStage { + private String name; + + private List members = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Folder other) { + name(other.getName()); + members(other.getMembers()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllMembers(List members) { + if (members != null) { + this.members.addAll(members); + } + return this; + } + + @java.lang.Override + public _FinalStage addMembers(String members) { + this.members.add(members); + return this; + } + + @java.lang.Override + @JsonSetter(value = "members", nulls = Nulls.SKIP) + public _FinalStage members(List members) { + this.members.clear(); + if (members != null) { + this.members.addAll(members); + } + return this; + } + + @java.lang.Override + public Folder build() { + return new Folder(name, members, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/Format.java b/src/main/java/com/squareup/square/types/Format.java new file mode 100644 index 00000000..d12e5fd0 --- /dev/null +++ b/src/main/java/com/squareup/square/types/Format.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.squareup.square.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = Format.Deserializer.class) +public final class Format { + private final Object value; + + private final int type; + + private Format(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((SimpleFormat) this.value); + } else if (this.type == 1) { + return visitor.visit((LinkFormat) this.value); + } else if (this.type == 2) { + return visitor.visit((CustomTimeFormat) this.value); + } else if (this.type == 3) { + return visitor.visit((CustomNumericFormat) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Format && equalTo((Format) other); + } + + private boolean equalTo(Format other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static Format of(SimpleFormat value) { + return new Format(value, 0); + } + + public static Format of(LinkFormat value) { + return new Format(value, 1); + } + + public static Format of(CustomTimeFormat value) { + return new Format(value, 2); + } + + public static Format of(CustomNumericFormat value) { + return new Format(value, 3); + } + + public interface Visitor { + T visit(SimpleFormat value); + + T visit(LinkFormat value); + + T visit(CustomTimeFormat value); + + T visit(CustomNumericFormat value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(Format.class); + } + + @java.lang.Override + public Format deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, SimpleFormat.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, LinkFormat.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CustomTimeFormat.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CustomNumericFormat.class)); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/squareup/square/types/FormatDescription.java b/src/main/java/com/squareup/square/types/FormatDescription.java new file mode 100644 index 00000000..9b123eb4 --- /dev/null +++ b/src/main/java/com/squareup/square/types/FormatDescription.java @@ -0,0 +1,206 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = FormatDescription.Builder.class) +public final class FormatDescription { + private final String name; + + private final String specifier; + + private final Optional currency; + + private final Map additionalProperties; + + private FormatDescription( + String name, String specifier, Optional currency, Map additionalProperties) { + this.name = name; + this.specifier = specifier; + this.currency = currency; + this.additionalProperties = additionalProperties; + } + + /** + * @return Predefined format name (e.g., 'percent_2', 'currency_1') or a base name like 'number', or 'custom' for ad-hoc specifiers + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return d3-format specifier string (e.g., '.2f', ',.0f', '$,.2f'). See https://d3js.org/d3-format + */ + @JsonProperty("specifier") + public String getSpecifier() { + return specifier; + } + + /** + * @return ISO 4217 currency code in uppercase (e.g. USD, EUR). Present when a currency format is used. + */ + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FormatDescription && equalTo((FormatDescription) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FormatDescription other) { + return name.equals(other.name) && specifier.equals(other.specifier) && currency.equals(other.currency); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.specifier, this.currency); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + /** + *

Predefined format name (e.g., 'percent_2', 'currency_1') or a base name like 'number', or 'custom' for ad-hoc specifiers

+ */ + SpecifierStage name(@NotNull String name); + + Builder from(FormatDescription other); + } + + public interface SpecifierStage { + /** + *

d3-format specifier string (e.g., '.2f', ',.0f', '$,.2f'). See https://d3js.org/d3-format

+ */ + _FinalStage specifier(@NotNull String specifier); + } + + public interface _FinalStage { + FormatDescription build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

ISO 4217 currency code in uppercase (e.g. USD, EUR). Present when a currency format is used.

+ */ + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, SpecifierStage, _FinalStage { + private String name; + + private String specifier; + + private Optional currency = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FormatDescription other) { + name(other.getName()); + specifier(other.getSpecifier()); + currency(other.getCurrency()); + return this; + } + + /** + *

Predefined format name (e.g., 'percent_2', 'currency_1') or a base name like 'number', or 'custom' for ad-hoc specifiers

+ *

Predefined format name (e.g., 'percent_2', 'currency_1') or a base name like 'number', or 'custom' for ad-hoc specifiers

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public SpecifierStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + /** + *

d3-format specifier string (e.g., '.2f', ',.0f', '$,.2f'). See https://d3js.org/d3-format

+ *

d3-format specifier string (e.g., '.2f', ',.0f', '$,.2f'). See https://d3js.org/d3-format

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("specifier") + public _FinalStage specifier(@NotNull String specifier) { + this.specifier = Objects.requireNonNull(specifier, "specifier must not be null"); + return this; + } + + /** + *

ISO 4217 currency code in uppercase (e.g. USD, EUR). Present when a currency format is used.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage currency(String currency) { + this.currency = Optional.ofNullable(currency); + return this; + } + + /** + *

ISO 4217 currency code in uppercase (e.g. USD, EUR). Present when a currency format is used.

+ */ + @java.lang.Override + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public _FinalStage currency(Optional currency) { + this.currency = currency; + return this; + } + + @java.lang.Override + public FormatDescription build() { + return new FormatDescription(name, specifier, currency, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/Hierarchy.java b/src/main/java/com/squareup/square/types/Hierarchy.java new file mode 100644 index 00000000..6829727f --- /dev/null +++ b/src/main/java/com/squareup/square/types/Hierarchy.java @@ -0,0 +1,240 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Hierarchy.Builder.class) +public final class Hierarchy { + private final String name; + + private final Optional aliasMember; + + private final Optional title; + + private final List levels; + + private final Map additionalProperties; + + private Hierarchy( + String name, + Optional aliasMember, + Optional title, + List levels, + Map additionalProperties) { + this.name = name; + this.aliasMember = aliasMember; + this.title = title; + this.levels = levels; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return When hierarchy is defined in Cube, it keeps the original path: Cube.hierarchy + */ + @JsonProperty("aliasMember") + public Optional getAliasMember() { + return aliasMember; + } + + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + @JsonProperty("levels") + public List getLevels() { + return levels; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Hierarchy && equalTo((Hierarchy) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Hierarchy other) { + return name.equals(other.name) + && aliasMember.equals(other.aliasMember) + && title.equals(other.title) + && levels.equals(other.levels); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.aliasMember, this.title, this.levels); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + + Builder from(Hierarchy other); + } + + public interface _FinalStage { + Hierarchy build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

When hierarchy is defined in Cube, it keeps the original path: Cube.hierarchy

+ */ + _FinalStage aliasMember(Optional aliasMember); + + _FinalStage aliasMember(String aliasMember); + + _FinalStage title(Optional title); + + _FinalStage title(String title); + + _FinalStage levels(List levels); + + _FinalStage addLevels(String levels); + + _FinalStage addAllLevels(List levels); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, _FinalStage { + private String name; + + private List levels = new ArrayList<>(); + + private Optional title = Optional.empty(); + + private Optional aliasMember = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Hierarchy other) { + name(other.getName()); + aliasMember(other.getAliasMember()); + title(other.getTitle()); + levels(other.getLevels()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllLevels(List levels) { + if (levels != null) { + this.levels.addAll(levels); + } + return this; + } + + @java.lang.Override + public _FinalStage addLevels(String levels) { + this.levels.add(levels); + return this; + } + + @java.lang.Override + @JsonSetter(value = "levels", nulls = Nulls.SKIP) + public _FinalStage levels(List levels) { + this.levels.clear(); + if (levels != null) { + this.levels.addAll(levels); + } + return this; + } + + @java.lang.Override + public _FinalStage title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + return this; + } + + /** + *

When hierarchy is defined in Cube, it keeps the original path: Cube.hierarchy

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage aliasMember(String aliasMember) { + this.aliasMember = Optional.ofNullable(aliasMember); + return this; + } + + /** + *

When hierarchy is defined in Cube, it keeps the original path: Cube.hierarchy

+ */ + @java.lang.Override + @JsonSetter(value = "aliasMember", nulls = Nulls.SKIP) + public _FinalStage aliasMember(Optional aliasMember) { + this.aliasMember = aliasMember; + return this; + } + + @java.lang.Override + public Hierarchy build() { + return new Hierarchy(name, aliasMember, title, levels, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/JoinSubquery.java b/src/main/java/com/squareup/square/types/JoinSubquery.java new file mode 100644 index 00000000..d2841c32 --- /dev/null +++ b/src/main/java/com/squareup/square/types/JoinSubquery.java @@ -0,0 +1,188 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = JoinSubquery.Builder.class) +public final class JoinSubquery { + private final String sql; + + private final String on; + + private final String joinType; + + private final String alias; + + private final Map additionalProperties; + + private JoinSubquery( + String sql, String on, String joinType, String alias, Map additionalProperties) { + this.sql = sql; + this.on = on; + this.joinType = joinType; + this.alias = alias; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("sql") + public String getSql() { + return sql; + } + + @JsonProperty("on") + public String getOn() { + return on; + } + + @JsonProperty("joinType") + public String getJoinType() { + return joinType; + } + + @JsonProperty("alias") + public String getAlias() { + return alias; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof JoinSubquery && equalTo((JoinSubquery) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(JoinSubquery other) { + return sql.equals(other.sql) + && on.equals(other.on) + && joinType.equals(other.joinType) + && alias.equals(other.alias); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.sql, this.on, this.joinType, this.alias); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SqlStage builder() { + return new Builder(); + } + + public interface SqlStage { + OnStage sql(@NotNull String sql); + + Builder from(JoinSubquery other); + } + + public interface OnStage { + JoinTypeStage on(@NotNull String on); + } + + public interface JoinTypeStage { + AliasStage joinType(@NotNull String joinType); + } + + public interface AliasStage { + _FinalStage alias(@NotNull String alias); + } + + public interface _FinalStage { + JoinSubquery build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SqlStage, OnStage, JoinTypeStage, AliasStage, _FinalStage { + private String sql; + + private String on; + + private String joinType; + + private String alias; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(JoinSubquery other) { + sql(other.getSql()); + on(other.getOn()); + joinType(other.getJoinType()); + alias(other.getAlias()); + return this; + } + + @java.lang.Override + @JsonSetter("sql") + public OnStage sql(@NotNull String sql) { + this.sql = Objects.requireNonNull(sql, "sql must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("on") + public JoinTypeStage on(@NotNull String on) { + this.on = Objects.requireNonNull(on, "on must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("joinType") + public AliasStage joinType(@NotNull String joinType) { + this.joinType = Objects.requireNonNull(joinType, "joinType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("alias") + public _FinalStage alias(@NotNull String alias) { + this.alias = Objects.requireNonNull(alias, "alias must not be null"); + return this; + } + + @java.lang.Override + public JoinSubquery build() { + return new JoinSubquery(sql, on, joinType, alias, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/LinkFormat.java b/src/main/java/com/squareup/square/types/LinkFormat.java new file mode 100644 index 00000000..40e6dd9a --- /dev/null +++ b/src/main/java/com/squareup/square/types/LinkFormat.java @@ -0,0 +1,137 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = LinkFormat.Builder.class) +public final class LinkFormat { + private final String label; + + private final Map additionalProperties; + + private LinkFormat(String label, Map additionalProperties) { + this.label = label; + this.additionalProperties = additionalProperties; + } + + /** + * @return Label for the link + */ + @JsonProperty("label") + public String getLabel() { + return label; + } + + /** + * @return Type of the format (must be 'link') + */ + @JsonProperty("type") + public String getType() { + return "link"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LinkFormat && equalTo((LinkFormat) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LinkFormat other) { + return label.equals(other.label); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.label); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static LabelStage builder() { + return new Builder(); + } + + public interface LabelStage { + /** + *

Label for the link

+ */ + _FinalStage label(@NotNull String label); + + Builder from(LinkFormat other); + } + + public interface _FinalStage { + LinkFormat build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements LabelStage, _FinalStage { + private String label; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(LinkFormat other) { + label(other.getLabel()); + return this; + } + + /** + *

Label for the link

+ *

Label for the link

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("label") + public _FinalStage label(@NotNull String label) { + this.label = Objects.requireNonNull(label, "label must not be null"); + return this; + } + + @java.lang.Override + public LinkFormat build() { + return new LinkFormat(label, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/LoadRequest.java b/src/main/java/com/squareup/square/types/LoadRequest.java new file mode 100644 index 00000000..6d9a176c --- /dev/null +++ b/src/main/java/com/squareup/square/types/LoadRequest.java @@ -0,0 +1,153 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = LoadRequest.Builder.class) +public final class LoadRequest { + private final Optional queryType; + + private final Optional cache; + + private final Optional query; + + private final Map additionalProperties; + + private LoadRequest( + Optional queryType, + Optional cache, + Optional query, + Map additionalProperties) { + this.queryType = queryType; + this.cache = cache; + this.query = query; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("queryType") + public Optional getQueryType() { + return queryType; + } + + @JsonProperty("cache") + public Optional getCache() { + return cache; + } + + @JsonProperty("query") + public Optional getQuery() { + return query; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LoadRequest && equalTo((LoadRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LoadRequest other) { + return queryType.equals(other.queryType) && cache.equals(other.cache) && query.equals(other.query); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.queryType, this.cache, this.query); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional queryType = Optional.empty(); + + private Optional cache = Optional.empty(); + + private Optional query = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(LoadRequest other) { + queryType(other.getQueryType()); + cache(other.getCache()); + query(other.getQuery()); + return this; + } + + @JsonSetter(value = "queryType", nulls = Nulls.SKIP) + public Builder queryType(Optional queryType) { + this.queryType = queryType; + return this; + } + + public Builder queryType(String queryType) { + this.queryType = Optional.ofNullable(queryType); + return this; + } + + @JsonSetter(value = "cache", nulls = Nulls.SKIP) + public Builder cache(Optional cache) { + this.cache = cache; + return this; + } + + public Builder cache(CacheMode cache) { + this.cache = Optional.ofNullable(cache); + return this; + } + + @JsonSetter(value = "query", nulls = Nulls.SKIP) + public Builder query(Optional query) { + this.query = query; + return this; + } + + public Builder query(Query query) { + this.query = Optional.ofNullable(query); + return this; + } + + public LoadRequest build() { + return new LoadRequest(queryType, cache, query, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/LoadResponse.java b/src/main/java/com/squareup/square/types/LoadResponse.java new file mode 100644 index 00000000..b3ebee74 --- /dev/null +++ b/src/main/java/com/squareup/square/types/LoadResponse.java @@ -0,0 +1,191 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = LoadResponse.Builder.class) +public final class LoadResponse { + private final Optional> pivotQuery; + + private final Optional slowQuery; + + private final Optional queryType; + + private final List results; + + private final Map additionalProperties; + + private LoadResponse( + Optional> pivotQuery, + Optional slowQuery, + Optional queryType, + List results, + Map additionalProperties) { + this.pivotQuery = pivotQuery; + this.slowQuery = slowQuery; + this.queryType = queryType; + this.results = results; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("pivotQuery") + public Optional> getPivotQuery() { + return pivotQuery; + } + + @JsonProperty("slowQuery") + public Optional getSlowQuery() { + return slowQuery; + } + + @JsonProperty("queryType") + public Optional getQueryType() { + return queryType; + } + + @JsonProperty("results") + public List getResults() { + return results; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LoadResponse && equalTo((LoadResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LoadResponse other) { + return pivotQuery.equals(other.pivotQuery) + && slowQuery.equals(other.slowQuery) + && queryType.equals(other.queryType) + && results.equals(other.results); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pivotQuery, this.slowQuery, this.queryType, this.results); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> pivotQuery = Optional.empty(); + + private Optional slowQuery = Optional.empty(); + + private Optional queryType = Optional.empty(); + + private List results = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(LoadResponse other) { + pivotQuery(other.getPivotQuery()); + slowQuery(other.getSlowQuery()); + queryType(other.getQueryType()); + results(other.getResults()); + return this; + } + + @JsonSetter(value = "pivotQuery", nulls = Nulls.SKIP) + public Builder pivotQuery(Optional> pivotQuery) { + this.pivotQuery = pivotQuery; + return this; + } + + public Builder pivotQuery(Map pivotQuery) { + this.pivotQuery = Optional.ofNullable(pivotQuery); + return this; + } + + @JsonSetter(value = "slowQuery", nulls = Nulls.SKIP) + public Builder slowQuery(Optional slowQuery) { + this.slowQuery = slowQuery; + return this; + } + + public Builder slowQuery(Boolean slowQuery) { + this.slowQuery = Optional.ofNullable(slowQuery); + return this; + } + + @JsonSetter(value = "queryType", nulls = Nulls.SKIP) + public Builder queryType(Optional queryType) { + this.queryType = queryType; + return this; + } + + public Builder queryType(String queryType) { + this.queryType = Optional.ofNullable(queryType); + return this; + } + + @JsonSetter(value = "results", nulls = Nulls.SKIP) + public Builder results(List results) { + this.results.clear(); + if (results != null) { + this.results.addAll(results); + } + return this; + } + + public Builder addResults(LoadResult results) { + this.results.add(results); + return this; + } + + public Builder addAllResults(List results) { + if (results != null) { + this.results.addAll(results); + } + return this; + } + + public LoadResponse build() { + return new LoadResponse(pivotQuery, slowQuery, queryType, results, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/LoadResult.java b/src/main/java/com/squareup/square/types/LoadResult.java new file mode 100644 index 00000000..8681931f --- /dev/null +++ b/src/main/java/com/squareup/square/types/LoadResult.java @@ -0,0 +1,238 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = LoadResult.Builder.class) +public final class LoadResult { + private final Optional dataSource; + + private final LoadResultAnnotation annotation; + + private final LoadResultData data; + + private final Optional>> refreshKeyValues; + + private final Optional lastRefreshTime; + + private final Map additionalProperties; + + private LoadResult( + Optional dataSource, + LoadResultAnnotation annotation, + LoadResultData data, + Optional>> refreshKeyValues, + Optional lastRefreshTime, + Map additionalProperties) { + this.dataSource = dataSource; + this.annotation = annotation; + this.data = data; + this.refreshKeyValues = refreshKeyValues; + this.lastRefreshTime = lastRefreshTime; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("dataSource") + public Optional getDataSource() { + return dataSource; + } + + @JsonProperty("annotation") + public LoadResultAnnotation getAnnotation() { + return annotation; + } + + @JsonProperty("data") + public LoadResultData getData() { + return data; + } + + @JsonProperty("refreshKeyValues") + public Optional>> getRefreshKeyValues() { + return refreshKeyValues; + } + + @JsonProperty("lastRefreshTime") + public Optional getLastRefreshTime() { + return lastRefreshTime; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LoadResult && equalTo((LoadResult) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LoadResult other) { + return dataSource.equals(other.dataSource) + && annotation.equals(other.annotation) + && data.equals(other.data) + && refreshKeyValues.equals(other.refreshKeyValues) + && lastRefreshTime.equals(other.lastRefreshTime); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.dataSource, this.annotation, this.data, this.refreshKeyValues, this.lastRefreshTime); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AnnotationStage builder() { + return new Builder(); + } + + public interface AnnotationStage { + DataStage annotation(@NotNull LoadResultAnnotation annotation); + + Builder from(LoadResult other); + } + + public interface DataStage { + _FinalStage data(@NotNull LoadResultData data); + } + + public interface _FinalStage { + LoadResult build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage dataSource(Optional dataSource); + + _FinalStage dataSource(String dataSource); + + _FinalStage refreshKeyValues(Optional>> refreshKeyValues); + + _FinalStage refreshKeyValues(List> refreshKeyValues); + + _FinalStage lastRefreshTime(Optional lastRefreshTime); + + _FinalStage lastRefreshTime(String lastRefreshTime); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements AnnotationStage, DataStage, _FinalStage { + private LoadResultAnnotation annotation; + + private LoadResultData data; + + private Optional lastRefreshTime = Optional.empty(); + + private Optional>> refreshKeyValues = Optional.empty(); + + private Optional dataSource = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(LoadResult other) { + dataSource(other.getDataSource()); + annotation(other.getAnnotation()); + data(other.getData()); + refreshKeyValues(other.getRefreshKeyValues()); + lastRefreshTime(other.getLastRefreshTime()); + return this; + } + + @java.lang.Override + @JsonSetter("annotation") + public DataStage annotation(@NotNull LoadResultAnnotation annotation) { + this.annotation = Objects.requireNonNull(annotation, "annotation must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull LoadResultData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage lastRefreshTime(String lastRefreshTime) { + this.lastRefreshTime = Optional.ofNullable(lastRefreshTime); + return this; + } + + @java.lang.Override + @JsonSetter(value = "lastRefreshTime", nulls = Nulls.SKIP) + public _FinalStage lastRefreshTime(Optional lastRefreshTime) { + this.lastRefreshTime = lastRefreshTime; + return this; + } + + @java.lang.Override + public _FinalStage refreshKeyValues(List> refreshKeyValues) { + this.refreshKeyValues = Optional.ofNullable(refreshKeyValues); + return this; + } + + @java.lang.Override + @JsonSetter(value = "refreshKeyValues", nulls = Nulls.SKIP) + public _FinalStage refreshKeyValues(Optional>> refreshKeyValues) { + this.refreshKeyValues = refreshKeyValues; + return this; + } + + @java.lang.Override + public _FinalStage dataSource(String dataSource) { + this.dataSource = Optional.ofNullable(dataSource); + return this; + } + + @java.lang.Override + @JsonSetter(value = "dataSource", nulls = Nulls.SKIP) + public _FinalStage dataSource(Optional dataSource) { + this.dataSource = dataSource; + return this; + } + + @java.lang.Override + public LoadResult build() { + return new LoadResult( + dataSource, annotation, data, refreshKeyValues, lastRefreshTime, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/LoadResultAnnotation.java b/src/main/java/com/squareup/square/types/LoadResultAnnotation.java new file mode 100644 index 00000000..21c435cc --- /dev/null +++ b/src/main/java/com/squareup/square/types/LoadResultAnnotation.java @@ -0,0 +1,219 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = LoadResultAnnotation.Builder.class) +public final class LoadResultAnnotation { + private final Map measures; + + private final Map dimensions; + + private final Map segments; + + private final Map timeDimensions; + + private final Map additionalProperties; + + private LoadResultAnnotation( + Map measures, + Map dimensions, + Map segments, + Map timeDimensions, + Map additionalProperties) { + this.measures = measures; + this.dimensions = dimensions; + this.segments = segments; + this.timeDimensions = timeDimensions; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("measures") + public Map getMeasures() { + return measures; + } + + @JsonProperty("dimensions") + public Map getDimensions() { + return dimensions; + } + + @JsonProperty("segments") + public Map getSegments() { + return segments; + } + + @JsonProperty("timeDimensions") + public Map getTimeDimensions() { + return timeDimensions; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LoadResultAnnotation && equalTo((LoadResultAnnotation) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LoadResultAnnotation other) { + return measures.equals(other.measures) + && dimensions.equals(other.dimensions) + && segments.equals(other.segments) + && timeDimensions.equals(other.timeDimensions); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.measures, this.dimensions, this.segments, this.timeDimensions); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Map measures = new LinkedHashMap<>(); + + private Map dimensions = new LinkedHashMap<>(); + + private Map segments = new LinkedHashMap<>(); + + private Map timeDimensions = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(LoadResultAnnotation other) { + measures(other.getMeasures()); + dimensions(other.getDimensions()); + segments(other.getSegments()); + timeDimensions(other.getTimeDimensions()); + return this; + } + + @JsonSetter(value = "measures", nulls = Nulls.SKIP) + public Builder measures(Map measures) { + this.measures.clear(); + if (measures != null) { + this.measures.putAll(measures); + } + return this; + } + + public Builder putAllMeasures(Map measures) { + if (measures != null) { + this.measures.putAll(measures); + } + return this; + } + + public Builder measures(String key, Object value) { + this.measures.put(key, value); + return this; + } + + @JsonSetter(value = "dimensions", nulls = Nulls.SKIP) + public Builder dimensions(Map dimensions) { + this.dimensions.clear(); + if (dimensions != null) { + this.dimensions.putAll(dimensions); + } + return this; + } + + public Builder putAllDimensions(Map dimensions) { + if (dimensions != null) { + this.dimensions.putAll(dimensions); + } + return this; + } + + public Builder dimensions(String key, Object value) { + this.dimensions.put(key, value); + return this; + } + + @JsonSetter(value = "segments", nulls = Nulls.SKIP) + public Builder segments(Map segments) { + this.segments.clear(); + if (segments != null) { + this.segments.putAll(segments); + } + return this; + } + + public Builder putAllSegments(Map segments) { + if (segments != null) { + this.segments.putAll(segments); + } + return this; + } + + public Builder segments(String key, Object value) { + this.segments.put(key, value); + return this; + } + + @JsonSetter(value = "timeDimensions", nulls = Nulls.SKIP) + public Builder timeDimensions(Map timeDimensions) { + this.timeDimensions.clear(); + if (timeDimensions != null) { + this.timeDimensions.putAll(timeDimensions); + } + return this; + } + + public Builder putAllTimeDimensions(Map timeDimensions) { + if (timeDimensions != null) { + this.timeDimensions.putAll(timeDimensions); + } + return this; + } + + public Builder timeDimensions(String key, Object value) { + this.timeDimensions.put(key, value); + return this; + } + + public LoadResultAnnotation build() { + return new LoadResultAnnotation(measures, dimensions, segments, timeDimensions, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/LoadResultData.java b/src/main/java/com/squareup/square/types/LoadResultData.java new file mode 100644 index 00000000..99f4fec8 --- /dev/null +++ b/src/main/java/com/squareup/square/types/LoadResultData.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.squareup.square.core.ObjectMappers; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonDeserialize(using = LoadResultData.Deserializer.class) +public final class LoadResultData { + private final Object value; + + private final int type; + + private LoadResultData(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((List>) this.value); + } else if (this.type == 1) { + return visitor.visit((LoadResultDataCompact) this.value); + } else if (this.type == 2) { + return visitor.visit((LoadResultDataColumnar) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LoadResultData && equalTo((LoadResultData) other); + } + + private boolean equalTo(LoadResultData other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static LoadResultData of(List> value) { + return new LoadResultData(value, 0); + } + + public static LoadResultData of(LoadResultDataCompact value) { + return new LoadResultData(value, 1); + } + + public static LoadResultData of(LoadResultDataColumnar value) { + return new LoadResultData(value, 2); + } + + public interface Visitor { + T visit(List> value); + + T visit(LoadResultDataCompact value); + + T visit(LoadResultDataColumnar value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(LoadResultData.class); + } + + @java.lang.Override + public LoadResultData deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>>() {})); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, LoadResultDataCompact.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, LoadResultDataColumnar.class)); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/squareup/square/types/LoadResultDataColumnar.java b/src/main/java/com/squareup/square/types/LoadResultDataColumnar.java new file mode 100644 index 00000000..eb735159 --- /dev/null +++ b/src/main/java/com/squareup/square/types/LoadResultDataColumnar.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = LoadResultDataColumnar.Builder.class) +public final class LoadResultDataColumnar { + private final List members; + + private final List> columns; + + private final Map additionalProperties; + + private LoadResultDataColumnar( + List members, List> columns, Map additionalProperties) { + this.members = members; + this.columns = columns; + this.additionalProperties = additionalProperties; + } + + /** + * @return Ordered list of member names. Element i of columns holds the values for members[i] across all rows. + */ + @JsonProperty("members") + public List getMembers() { + return members; + } + + /** + * @return One array per member, in the same order as members. Each inner array contains the primitive value of that member for every row (null, boolean, number, string). + */ + @JsonProperty("columns") + public List> getColumns() { + return columns; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LoadResultDataColumnar && equalTo((LoadResultDataColumnar) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LoadResultDataColumnar other) { + return members.equals(other.members) && columns.equals(other.columns); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.members, this.columns); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private List members = new ArrayList<>(); + + private List> columns = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(LoadResultDataColumnar other) { + members(other.getMembers()); + columns(other.getColumns()); + return this; + } + + /** + *

Ordered list of member names. Element i of columns holds the values for members[i] across all rows.

+ */ + @JsonSetter(value = "members", nulls = Nulls.SKIP) + public Builder members(List members) { + this.members.clear(); + if (members != null) { + this.members.addAll(members); + } + return this; + } + + public Builder addMembers(String members) { + this.members.add(members); + return this; + } + + public Builder addAllMembers(List members) { + if (members != null) { + this.members.addAll(members); + } + return this; + } + + /** + *

One array per member, in the same order as members. Each inner array contains the primitive value of that member for every row (null, boolean, number, string).

+ */ + @JsonSetter(value = "columns", nulls = Nulls.SKIP) + public Builder columns(List> columns) { + this.columns.clear(); + if (columns != null) { + this.columns.addAll(columns); + } + return this; + } + + public Builder addColumns(List columns) { + this.columns.add(columns); + return this; + } + + public Builder addAllColumns(List> columns) { + if (columns != null) { + this.columns.addAll(columns); + } + return this; + } + + public LoadResultDataColumnar build() { + return new LoadResultDataColumnar(members, columns, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/LoadResultDataCompact.java b/src/main/java/com/squareup/square/types/LoadResultDataCompact.java new file mode 100644 index 00000000..cbb526df --- /dev/null +++ b/src/main/java/com/squareup/square/types/LoadResultDataCompact.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = LoadResultDataCompact.Builder.class) +public final class LoadResultDataCompact { + private final List members; + + private final List> dataset; + + private final Map additionalProperties; + + private LoadResultDataCompact( + List members, List> dataset, Map additionalProperties) { + this.members = members; + this.dataset = dataset; + this.additionalProperties = additionalProperties; + } + + /** + * @return Ordered list of member names that correspond to each cell position in dataset rows. + */ + @JsonProperty("members") + public List getMembers() { + return members; + } + + /** + * @return Array of rows, where each row is an array of primitive values (null, boolean, number, string) aligned with members. + */ + @JsonProperty("dataset") + public List> getDataset() { + return dataset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LoadResultDataCompact && equalTo((LoadResultDataCompact) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LoadResultDataCompact other) { + return members.equals(other.members) && dataset.equals(other.dataset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.members, this.dataset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private List members = new ArrayList<>(); + + private List> dataset = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(LoadResultDataCompact other) { + members(other.getMembers()); + dataset(other.getDataset()); + return this; + } + + /** + *

Ordered list of member names that correspond to each cell position in dataset rows.

+ */ + @JsonSetter(value = "members", nulls = Nulls.SKIP) + public Builder members(List members) { + this.members.clear(); + if (members != null) { + this.members.addAll(members); + } + return this; + } + + public Builder addMembers(String members) { + this.members.add(members); + return this; + } + + public Builder addAllMembers(List members) { + if (members != null) { + this.members.addAll(members); + } + return this; + } + + /** + *

Array of rows, where each row is an array of primitive values (null, boolean, number, string) aligned with members.

+ */ + @JsonSetter(value = "dataset", nulls = Nulls.SKIP) + public Builder dataset(List> dataset) { + this.dataset.clear(); + if (dataset != null) { + this.dataset.addAll(dataset); + } + return this; + } + + public Builder addDataset(List dataset) { + this.dataset.add(dataset); + return this; + } + + public Builder addAllDataset(List> dataset) { + if (dataset != null) { + this.dataset.addAll(dataset); + } + return this; + } + + public LoadResultDataCompact build() { + return new LoadResultDataCompact(members, dataset, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/Measure.java b/src/main/java/com/squareup/square/types/Measure.java new file mode 100644 index 00000000..0abd30ce --- /dev/null +++ b/src/main/java/com/squareup/square/types/Measure.java @@ -0,0 +1,465 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Measure.Builder.class) +public final class Measure { + private final String name; + + private final Optional title; + + private final Optional shortTitle; + + private final Optional description; + + private final String type; + + private final Optional aggType; + + private final Optional> meta; + + private final Optional format; + + private final Optional formatDescription; + + private final Optional currency; + + private final Optional aliasMember; + + private final Map additionalProperties; + + private Measure( + String name, + Optional title, + Optional shortTitle, + Optional description, + String type, + Optional aggType, + Optional> meta, + Optional format, + Optional formatDescription, + Optional currency, + Optional aliasMember, + Map additionalProperties) { + this.name = name; + this.title = title; + this.shortTitle = shortTitle; + this.description = description; + this.type = type; + this.aggType = aggType; + this.meta = meta; + this.format = format; + this.formatDescription = formatDescription; + this.currency = currency; + this.aliasMember = aliasMember; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + @JsonProperty("shortTitle") + public Optional getShortTitle() { + return shortTitle; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("type") + public String getType() { + return type; + } + + @JsonProperty("aggType") + public Optional getAggType() { + return aggType; + } + + @JsonProperty("meta") + public Optional> getMeta() { + return meta; + } + + @JsonProperty("format") + public Optional getFormat() { + return format; + } + + @JsonProperty("formatDescription") + public Optional getFormatDescription() { + return formatDescription; + } + + /** + * @return ISO 4217 currency code in uppercase (3 characters, e.g. USD, EUR) + */ + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + + /** + * @return When measure is defined in View, it keeps the original path: Cube.measure + */ + @JsonProperty("aliasMember") + public Optional getAliasMember() { + return aliasMember; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Measure && equalTo((Measure) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Measure other) { + return name.equals(other.name) + && title.equals(other.title) + && shortTitle.equals(other.shortTitle) + && description.equals(other.description) + && type.equals(other.type) + && aggType.equals(other.aggType) + && meta.equals(other.meta) + && format.equals(other.format) + && formatDescription.equals(other.formatDescription) + && currency.equals(other.currency) + && aliasMember.equals(other.aliasMember); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.title, + this.shortTitle, + this.description, + this.type, + this.aggType, + this.meta, + this.format, + this.formatDescription, + this.currency, + this.aliasMember); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + TypeStage name(@NotNull String name); + + Builder from(Measure other); + } + + public interface TypeStage { + _FinalStage type(@NotNull String type); + } + + public interface _FinalStage { + Measure build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage title(Optional title); + + _FinalStage title(String title); + + _FinalStage shortTitle(Optional shortTitle); + + _FinalStage shortTitle(String shortTitle); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage aggType(Optional aggType); + + _FinalStage aggType(String aggType); + + _FinalStage meta(Optional> meta); + + _FinalStage meta(Map meta); + + _FinalStage format(Optional format); + + _FinalStage format(Format format); + + _FinalStage formatDescription(Optional formatDescription); + + _FinalStage formatDescription(FormatDescription formatDescription); + + /** + *

ISO 4217 currency code in uppercase (3 characters, e.g. USD, EUR)

+ */ + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + + /** + *

When measure is defined in View, it keeps the original path: Cube.measure

+ */ + _FinalStage aliasMember(Optional aliasMember); + + _FinalStage aliasMember(String aliasMember); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, TypeStage, _FinalStage { + private String name; + + private String type; + + private Optional aliasMember = Optional.empty(); + + private Optional currency = Optional.empty(); + + private Optional formatDescription = Optional.empty(); + + private Optional format = Optional.empty(); + + private Optional> meta = Optional.empty(); + + private Optional aggType = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional shortTitle = Optional.empty(); + + private Optional title = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Measure other) { + name(other.getName()); + title(other.getTitle()); + shortTitle(other.getShortTitle()); + description(other.getDescription()); + type(other.getType()); + aggType(other.getAggType()); + meta(other.getMeta()); + format(other.getFormat()); + formatDescription(other.getFormatDescription()); + currency(other.getCurrency()); + aliasMember(other.getAliasMember()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public TypeStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("type") + public _FinalStage type(@NotNull String type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + /** + *

When measure is defined in View, it keeps the original path: Cube.measure

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage aliasMember(String aliasMember) { + this.aliasMember = Optional.ofNullable(aliasMember); + return this; + } + + /** + *

When measure is defined in View, it keeps the original path: Cube.measure

+ */ + @java.lang.Override + @JsonSetter(value = "aliasMember", nulls = Nulls.SKIP) + public _FinalStage aliasMember(Optional aliasMember) { + this.aliasMember = aliasMember; + return this; + } + + /** + *

ISO 4217 currency code in uppercase (3 characters, e.g. USD, EUR)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage currency(String currency) { + this.currency = Optional.ofNullable(currency); + return this; + } + + /** + *

ISO 4217 currency code in uppercase (3 characters, e.g. USD, EUR)

+ */ + @java.lang.Override + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public _FinalStage currency(Optional currency) { + this.currency = currency; + return this; + } + + @java.lang.Override + public _FinalStage formatDescription(FormatDescription formatDescription) { + this.formatDescription = Optional.ofNullable(formatDescription); + return this; + } + + @java.lang.Override + @JsonSetter(value = "formatDescription", nulls = Nulls.SKIP) + public _FinalStage formatDescription(Optional formatDescription) { + this.formatDescription = formatDescription; + return this; + } + + @java.lang.Override + public _FinalStage format(Format format) { + this.format = Optional.ofNullable(format); + return this; + } + + @java.lang.Override + @JsonSetter(value = "format", nulls = Nulls.SKIP) + public _FinalStage format(Optional format) { + this.format = format; + return this; + } + + @java.lang.Override + public _FinalStage meta(Map meta) { + this.meta = Optional.ofNullable(meta); + return this; + } + + @java.lang.Override + @JsonSetter(value = "meta", nulls = Nulls.SKIP) + public _FinalStage meta(Optional> meta) { + this.meta = meta; + return this; + } + + @java.lang.Override + public _FinalStage aggType(String aggType) { + this.aggType = Optional.ofNullable(aggType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "aggType", nulls = Nulls.SKIP) + public _FinalStage aggType(Optional aggType) { + this.aggType = aggType; + return this; + } + + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public _FinalStage shortTitle(String shortTitle) { + this.shortTitle = Optional.ofNullable(shortTitle); + return this; + } + + @java.lang.Override + @JsonSetter(value = "shortTitle", nulls = Nulls.SKIP) + public _FinalStage shortTitle(Optional shortTitle) { + this.shortTitle = shortTitle; + return this; + } + + @java.lang.Override + public _FinalStage title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + return this; + } + + @java.lang.Override + public Measure build() { + return new Measure( + name, + title, + shortTitle, + description, + type, + aggType, + meta, + format, + formatDescription, + currency, + aliasMember, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/MetadataResponse.java b/src/main/java/com/squareup/square/types/MetadataResponse.java new file mode 100644 index 00000000..9e57a7cc --- /dev/null +++ b/src/main/java/com/squareup/square/types/MetadataResponse.java @@ -0,0 +1,129 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = MetadataResponse.Builder.class) +public final class MetadataResponse { + private final Optional> cubes; + + private final Optional compilerId; + + private final Map additionalProperties; + + private MetadataResponse( + Optional> cubes, Optional compilerId, Map additionalProperties) { + this.cubes = cubes; + this.compilerId = compilerId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("cubes") + public Optional> getCubes() { + return cubes; + } + + @JsonProperty("compilerId") + public Optional getCompilerId() { + return compilerId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MetadataResponse && equalTo((MetadataResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MetadataResponse other) { + return cubes.equals(other.cubes) && compilerId.equals(other.compilerId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.cubes, this.compilerId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> cubes = Optional.empty(); + + private Optional compilerId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(MetadataResponse other) { + cubes(other.getCubes()); + compilerId(other.getCompilerId()); + return this; + } + + @JsonSetter(value = "cubes", nulls = Nulls.SKIP) + public Builder cubes(Optional> cubes) { + this.cubes = cubes; + return this; + } + + public Builder cubes(List cubes) { + this.cubes = Optional.ofNullable(cubes); + return this; + } + + @JsonSetter(value = "compilerId", nulls = Nulls.SKIP) + public Builder compilerId(Optional compilerId) { + this.compilerId = compilerId; + return this; + } + + public Builder compilerId(String compilerId) { + this.compilerId = Optional.ofNullable(compilerId); + return this; + } + + public MetadataResponse build() { + return new MetadataResponse(cubes, compilerId, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/NestedFolder.java b/src/main/java/com/squareup/square/types/NestedFolder.java new file mode 100644 index 00000000..df4223f9 --- /dev/null +++ b/src/main/java/com/squareup/square/types/NestedFolder.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = NestedFolder.Builder.class) +public final class NestedFolder { + private final String name; + + private final List members; + + private final Map additionalProperties; + + private NestedFolder(String name, List members, Map additionalProperties) { + this.name = name; + this.members = members; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("members") + public List getMembers() { + return members; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NestedFolder && equalTo((NestedFolder) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NestedFolder other) { + return name.equals(other.name) && members.equals(other.members); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.members); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + + Builder from(NestedFolder other); + } + + public interface _FinalStage { + NestedFolder build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage members(List members); + + _FinalStage addMembers(String members); + + _FinalStage addAllMembers(List members); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, _FinalStage { + private String name; + + private List members = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(NestedFolder other) { + name(other.getName()); + members(other.getMembers()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllMembers(List members) { + if (members != null) { + this.members.addAll(members); + } + return this; + } + + @java.lang.Override + public _FinalStage addMembers(String members) { + this.members.add(members); + return this; + } + + @java.lang.Override + @JsonSetter(value = "members", nulls = Nulls.SKIP) + public _FinalStage members(List members) { + this.members.clear(); + if (members != null) { + this.members.addAll(members); + } + return this; + } + + @java.lang.Override + public NestedFolder build() { + return new NestedFolder(name, members, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/Query.java b/src/main/java/com/squareup/square/types/Query.java new file mode 100644 index 00000000..3b875878 --- /dev/null +++ b/src/main/java/com/squareup/square/types/Query.java @@ -0,0 +1,423 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Query.Builder.class) +public final class Query { + private final Optional> measures; + + private final Optional> dimensions; + + private final Optional> segments; + + private final Optional> timeDimensions; + + private final Optional>> order; + + private final Optional limit; + + private final Optional offset; + + private final Optional> filters; + + private final Optional ungrouped; + + private final Optional> subqueryJoins; + + private final Optional>> joinHints; + + private final Optional timezone; + + private final Optional responseFormat; + + private final Map additionalProperties; + + private Query( + Optional> measures, + Optional> dimensions, + Optional> segments, + Optional> timeDimensions, + Optional>> order, + Optional limit, + Optional offset, + Optional> filters, + Optional ungrouped, + Optional> subqueryJoins, + Optional>> joinHints, + Optional timezone, + Optional responseFormat, + Map additionalProperties) { + this.measures = measures; + this.dimensions = dimensions; + this.segments = segments; + this.timeDimensions = timeDimensions; + this.order = order; + this.limit = limit; + this.offset = offset; + this.filters = filters; + this.ungrouped = ungrouped; + this.subqueryJoins = subqueryJoins; + this.joinHints = joinHints; + this.timezone = timezone; + this.responseFormat = responseFormat; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("measures") + public Optional> getMeasures() { + return measures; + } + + @JsonProperty("dimensions") + public Optional> getDimensions() { + return dimensions; + } + + @JsonProperty("segments") + public Optional> getSegments() { + return segments; + } + + @JsonProperty("timeDimensions") + public Optional> getTimeDimensions() { + return timeDimensions; + } + + @JsonProperty("order") + public Optional>> getOrder() { + return order; + } + + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("filters") + public Optional> getFilters() { + return filters; + } + + @JsonProperty("ungrouped") + public Optional getUngrouped() { + return ungrouped; + } + + @JsonProperty("subqueryJoins") + public Optional> getSubqueryJoins() { + return subqueryJoins; + } + + @JsonProperty("joinHints") + public Optional>> getJoinHints() { + return joinHints; + } + + @JsonProperty("timezone") + public Optional getTimezone() { + return timezone; + } + + @JsonProperty("responseFormat") + public Optional getResponseFormat() { + return responseFormat; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Query && equalTo((Query) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Query other) { + return measures.equals(other.measures) + && dimensions.equals(other.dimensions) + && segments.equals(other.segments) + && timeDimensions.equals(other.timeDimensions) + && order.equals(other.order) + && limit.equals(other.limit) + && offset.equals(other.offset) + && filters.equals(other.filters) + && ungrouped.equals(other.ungrouped) + && subqueryJoins.equals(other.subqueryJoins) + && joinHints.equals(other.joinHints) + && timezone.equals(other.timezone) + && responseFormat.equals(other.responseFormat); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.measures, + this.dimensions, + this.segments, + this.timeDimensions, + this.order, + this.limit, + this.offset, + this.filters, + this.ungrouped, + this.subqueryJoins, + this.joinHints, + this.timezone, + this.responseFormat); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> measures = Optional.empty(); + + private Optional> dimensions = Optional.empty(); + + private Optional> segments = Optional.empty(); + + private Optional> timeDimensions = Optional.empty(); + + private Optional>> order = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional> filters = Optional.empty(); + + private Optional ungrouped = Optional.empty(); + + private Optional> subqueryJoins = Optional.empty(); + + private Optional>> joinHints = Optional.empty(); + + private Optional timezone = Optional.empty(); + + private Optional responseFormat = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Query other) { + measures(other.getMeasures()); + dimensions(other.getDimensions()); + segments(other.getSegments()); + timeDimensions(other.getTimeDimensions()); + order(other.getOrder()); + limit(other.getLimit()); + offset(other.getOffset()); + filters(other.getFilters()); + ungrouped(other.getUngrouped()); + subqueryJoins(other.getSubqueryJoins()); + joinHints(other.getJoinHints()); + timezone(other.getTimezone()); + responseFormat(other.getResponseFormat()); + return this; + } + + @JsonSetter(value = "measures", nulls = Nulls.SKIP) + public Builder measures(Optional> measures) { + this.measures = measures; + return this; + } + + public Builder measures(List measures) { + this.measures = Optional.ofNullable(measures); + return this; + } + + @JsonSetter(value = "dimensions", nulls = Nulls.SKIP) + public Builder dimensions(Optional> dimensions) { + this.dimensions = dimensions; + return this; + } + + public Builder dimensions(List dimensions) { + this.dimensions = Optional.ofNullable(dimensions); + return this; + } + + @JsonSetter(value = "segments", nulls = Nulls.SKIP) + public Builder segments(Optional> segments) { + this.segments = segments; + return this; + } + + public Builder segments(List segments) { + this.segments = Optional.ofNullable(segments); + return this; + } + + @JsonSetter(value = "timeDimensions", nulls = Nulls.SKIP) + public Builder timeDimensions(Optional> timeDimensions) { + this.timeDimensions = timeDimensions; + return this; + } + + public Builder timeDimensions(List timeDimensions) { + this.timeDimensions = Optional.ofNullable(timeDimensions); + return this; + } + + @JsonSetter(value = "order", nulls = Nulls.SKIP) + public Builder order(Optional>> order) { + this.order = order; + return this; + } + + public Builder order(List> order) { + this.order = Optional.ofNullable(order); + return this; + } + + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "filters", nulls = Nulls.SKIP) + public Builder filters(Optional> filters) { + this.filters = filters; + return this; + } + + public Builder filters(List filters) { + this.filters = Optional.ofNullable(filters); + return this; + } + + @JsonSetter(value = "ungrouped", nulls = Nulls.SKIP) + public Builder ungrouped(Optional ungrouped) { + this.ungrouped = ungrouped; + return this; + } + + public Builder ungrouped(Boolean ungrouped) { + this.ungrouped = Optional.ofNullable(ungrouped); + return this; + } + + @JsonSetter(value = "subqueryJoins", nulls = Nulls.SKIP) + public Builder subqueryJoins(Optional> subqueryJoins) { + this.subqueryJoins = subqueryJoins; + return this; + } + + public Builder subqueryJoins(List subqueryJoins) { + this.subqueryJoins = Optional.ofNullable(subqueryJoins); + return this; + } + + @JsonSetter(value = "joinHints", nulls = Nulls.SKIP) + public Builder joinHints(Optional>> joinHints) { + this.joinHints = joinHints; + return this; + } + + public Builder joinHints(List> joinHints) { + this.joinHints = Optional.ofNullable(joinHints); + return this; + } + + @JsonSetter(value = "timezone", nulls = Nulls.SKIP) + public Builder timezone(Optional timezone) { + this.timezone = timezone; + return this; + } + + public Builder timezone(String timezone) { + this.timezone = Optional.ofNullable(timezone); + return this; + } + + @JsonSetter(value = "responseFormat", nulls = Nulls.SKIP) + public Builder responseFormat(Optional responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + public Builder responseFormat(ResponseFormat responseFormat) { + this.responseFormat = Optional.ofNullable(responseFormat); + return this; + } + + public Query build() { + return new Query( + measures, + dimensions, + segments, + timeDimensions, + order, + limit, + offset, + filters, + ungrouped, + subqueryJoins, + joinHints, + timezone, + responseFormat, + additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/QueryFilter.java b/src/main/java/com/squareup/square/types/QueryFilter.java new file mode 100644 index 00000000..2e54e546 --- /dev/null +++ b/src/main/java/com/squareup/square/types/QueryFilter.java @@ -0,0 +1,107 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.squareup.square.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = QueryFilter.Deserializer.class) +public final class QueryFilter { + private final Object value; + + private final int type; + + private QueryFilter(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((QueryFilterCondition) this.value); + } else if (this.type == 1) { + return visitor.visit((QueryFilterOr) this.value); + } else if (this.type == 2) { + return visitor.visit((QueryFilterAnd) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof QueryFilter && equalTo((QueryFilter) other); + } + + private boolean equalTo(QueryFilter other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static QueryFilter of(QueryFilterCondition value) { + return new QueryFilter(value, 0); + } + + public static QueryFilter of(QueryFilterOr value) { + return new QueryFilter(value, 1); + } + + public static QueryFilter of(QueryFilterAnd value) { + return new QueryFilter(value, 2); + } + + public interface Visitor { + T visit(QueryFilterCondition value); + + T visit(QueryFilterOr value); + + T visit(QueryFilterAnd value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(QueryFilter.class); + } + + @java.lang.Override + public QueryFilter deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, QueryFilterCondition.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, QueryFilterOr.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, QueryFilterAnd.class)); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/squareup/square/types/QueryFilterAnd.java b/src/main/java/com/squareup/square/types/QueryFilterAnd.java new file mode 100644 index 00000000..0eb27368 --- /dev/null +++ b/src/main/java/com/squareup/square/types/QueryFilterAnd.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = QueryFilterAnd.Builder.class) +public final class QueryFilterAnd { + private final Optional>> and; + + private final Map additionalProperties; + + private QueryFilterAnd(Optional>> and, Map additionalProperties) { + this.and = and; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("and") + public Optional>> getAnd() { + return and; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof QueryFilterAnd && equalTo((QueryFilterAnd) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(QueryFilterAnd other) { + return and.equals(other.and); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.and); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional>> and = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(QueryFilterAnd other) { + and(other.getAnd()); + return this; + } + + @JsonSetter(value = "and", nulls = Nulls.SKIP) + public Builder and(Optional>> and) { + this.and = and; + return this; + } + + public Builder and(List> and) { + this.and = Optional.ofNullable(and); + return this; + } + + public QueryFilterAnd build() { + return new QueryFilterAnd(and, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/QueryFilterCondition.java b/src/main/java/com/squareup/square/types/QueryFilterCondition.java new file mode 100644 index 00000000..49a38027 --- /dev/null +++ b/src/main/java/com/squareup/square/types/QueryFilterCondition.java @@ -0,0 +1,154 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = QueryFilterCondition.Builder.class) +public final class QueryFilterCondition { + private final Optional member; + + private final Optional operator; + + private final Optional> values; + + private final Map additionalProperties; + + private QueryFilterCondition( + Optional member, + Optional operator, + Optional> values, + Map additionalProperties) { + this.member = member; + this.operator = operator; + this.values = values; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("member") + public Optional getMember() { + return member; + } + + @JsonProperty("operator") + public Optional getOperator() { + return operator; + } + + @JsonProperty("values") + public Optional> getValues() { + return values; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof QueryFilterCondition && equalTo((QueryFilterCondition) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(QueryFilterCondition other) { + return member.equals(other.member) && operator.equals(other.operator) && values.equals(other.values); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.member, this.operator, this.values); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional member = Optional.empty(); + + private Optional operator = Optional.empty(); + + private Optional> values = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(QueryFilterCondition other) { + member(other.getMember()); + operator(other.getOperator()); + values(other.getValues()); + return this; + } + + @JsonSetter(value = "member", nulls = Nulls.SKIP) + public Builder member(Optional member) { + this.member = member; + return this; + } + + public Builder member(String member) { + this.member = Optional.ofNullable(member); + return this; + } + + @JsonSetter(value = "operator", nulls = Nulls.SKIP) + public Builder operator(Optional operator) { + this.operator = operator; + return this; + } + + public Builder operator(String operator) { + this.operator = Optional.ofNullable(operator); + return this; + } + + @JsonSetter(value = "values", nulls = Nulls.SKIP) + public Builder values(Optional> values) { + this.values = values; + return this; + } + + public Builder values(List values) { + this.values = Optional.ofNullable(values); + return this; + } + + public QueryFilterCondition build() { + return new QueryFilterCondition(member, operator, values, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/QueryFilterOr.java b/src/main/java/com/squareup/square/types/QueryFilterOr.java new file mode 100644 index 00000000..b0c59bbc --- /dev/null +++ b/src/main/java/com/squareup/square/types/QueryFilterOr.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = QueryFilterOr.Builder.class) +public final class QueryFilterOr { + private final Optional>> or; + + private final Map additionalProperties; + + private QueryFilterOr(Optional>> or, Map additionalProperties) { + this.or = or; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("or") + public Optional>> getOr() { + return or; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof QueryFilterOr && equalTo((QueryFilterOr) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(QueryFilterOr other) { + return or.equals(other.or); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.or); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional>> or = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(QueryFilterOr other) { + or(other.getOr()); + return this; + } + + @JsonSetter(value = "or", nulls = Nulls.SKIP) + public Builder or(Optional>> or) { + this.or = or; + return this; + } + + public Builder or(List> or) { + this.or = Optional.ofNullable(or); + return this; + } + + public QueryFilterOr build() { + return new QueryFilterOr(or, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/ReportingError.java b/src/main/java/com/squareup/square/types/ReportingError.java new file mode 100644 index 00000000..fa87f13a --- /dev/null +++ b/src/main/java/com/squareup/square/types/ReportingError.java @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReportingError.Builder.class) +public final class ReportingError { + private final String error; + + private final Map additionalProperties; + + private ReportingError(String error, Map additionalProperties) { + this.error = error; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("error") + public String getError() { + return error; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReportingError && equalTo((ReportingError) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReportingError other) { + return error.equals(other.error); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.error); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ErrorStage builder() { + return new Builder(); + } + + public interface ErrorStage { + _FinalStage error(@NotNull String error); + + Builder from(ReportingError other); + } + + public interface _FinalStage { + ReportingError build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ErrorStage, _FinalStage { + private String error; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReportingError other) { + error(other.getError()); + return this; + } + + @java.lang.Override + @JsonSetter("error") + public _FinalStage error(@NotNull String error) { + this.error = Objects.requireNonNull(error, "error must not be null"); + return this; + } + + @java.lang.Override + public ReportingError build() { + return new ReportingError(error, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/ResponseFormat.java b/src/main/java/com/squareup/square/types/ResponseFormat.java new file mode 100644 index 00000000..5e81b87a --- /dev/null +++ b/src/main/java/com/squareup/square/types/ResponseFormat.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ResponseFormat { + public static final ResponseFormat COLUMNAR = new ResponseFormat(Value.COLUMNAR, "columnar"); + + public static final ResponseFormat DEFAULT = new ResponseFormat(Value.DEFAULT, "default"); + + public static final ResponseFormat COMPACT = new ResponseFormat(Value.COMPACT, "compact"); + + private final Value value; + + private final String string; + + ResponseFormat(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ResponseFormat && this.string.equals(((ResponseFormat) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case COLUMNAR: + return visitor.visitColumnar(); + case DEFAULT: + return visitor.visitDefault(); + case COMPACT: + return visitor.visitCompact(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ResponseFormat valueOf(String value) { + switch (value) { + case "columnar": + return COLUMNAR; + case "default": + return DEFAULT; + case "compact": + return COMPACT; + default: + return new ResponseFormat(Value.UNKNOWN, value); + } + } + + public enum Value { + DEFAULT, + + COMPACT, + + COLUMNAR, + + UNKNOWN + } + + public interface Visitor { + T visitDefault(); + + T visitCompact(); + + T visitColumnar(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/squareup/square/types/Segment.java b/src/main/java/com/squareup/square/types/Segment.java new file mode 100644 index 00000000..b2138dd0 --- /dev/null +++ b/src/main/java/com/squareup/square/types/Segment.java @@ -0,0 +1,230 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Segment.Builder.class) +public final class Segment { + private final String name; + + private final String title; + + private final Optional description; + + private final String shortTitle; + + private final Optional> meta; + + private final Map additionalProperties; + + private Segment( + String name, + String title, + Optional description, + String shortTitle, + Optional> meta, + Map additionalProperties) { + this.name = name; + this.title = title; + this.description = description; + this.shortTitle = shortTitle; + this.meta = meta; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("title") + public String getTitle() { + return title; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("shortTitle") + public String getShortTitle() { + return shortTitle; + } + + @JsonProperty("meta") + public Optional> getMeta() { + return meta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Segment && equalTo((Segment) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Segment other) { + return name.equals(other.name) + && title.equals(other.title) + && description.equals(other.description) + && shortTitle.equals(other.shortTitle) + && meta.equals(other.meta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.title, this.description, this.shortTitle, this.meta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + TitleStage name(@NotNull String name); + + Builder from(Segment other); + } + + public interface TitleStage { + ShortTitleStage title(@NotNull String title); + } + + public interface ShortTitleStage { + _FinalStage shortTitle(@NotNull String shortTitle); + } + + public interface _FinalStage { + Segment build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage meta(Optional> meta); + + _FinalStage meta(Map meta); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, TitleStage, ShortTitleStage, _FinalStage { + private String name; + + private String title; + + private String shortTitle; + + private Optional> meta = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Segment other) { + name(other.getName()); + title(other.getTitle()); + description(other.getDescription()); + shortTitle(other.getShortTitle()); + meta(other.getMeta()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public TitleStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("title") + public ShortTitleStage title(@NotNull String title) { + this.title = Objects.requireNonNull(title, "title must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("shortTitle") + public _FinalStage shortTitle(@NotNull String shortTitle) { + this.shortTitle = Objects.requireNonNull(shortTitle, "shortTitle must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage meta(Map meta) { + this.meta = Optional.ofNullable(meta); + return this; + } + + @java.lang.Override + @JsonSetter(value = "meta", nulls = Nulls.SKIP) + public _FinalStage meta(Optional> meta) { + this.meta = meta; + return this; + } + + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public Segment build() { + return new Segment(name, title, description, shortTitle, meta, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/types/SimpleFormat.java b/src/main/java/com/squareup/square/types/SimpleFormat.java new file mode 100644 index 00000000..a5647d14 --- /dev/null +++ b/src/main/java/com/squareup/square/types/SimpleFormat.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class SimpleFormat { + public static final SimpleFormat NUMBER = new SimpleFormat(Value.NUMBER, "number"); + + public static final SimpleFormat CURRENCY = new SimpleFormat(Value.CURRENCY, "currency"); + + public static final SimpleFormat ID = new SimpleFormat(Value.ID, "id"); + + public static final SimpleFormat LINK = new SimpleFormat(Value.LINK, "link"); + + public static final SimpleFormat IMAGE_URL = new SimpleFormat(Value.IMAGE_URL, "imageUrl"); + + public static final SimpleFormat PERCENT = new SimpleFormat(Value.PERCENT, "percent"); + + private final Value value; + + private final String string; + + SimpleFormat(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof SimpleFormat && this.string.equals(((SimpleFormat) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMBER: + return visitor.visitNumber(); + case CURRENCY: + return visitor.visitCurrency(); + case ID: + return visitor.visitId(); + case LINK: + return visitor.visitLink(); + case IMAGE_URL: + return visitor.visitImageUrl(); + case PERCENT: + return visitor.visitPercent(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SimpleFormat valueOf(String value) { + switch (value) { + case "number": + return NUMBER; + case "currency": + return CURRENCY; + case "id": + return ID; + case "link": + return LINK; + case "imageUrl": + return IMAGE_URL; + case "percent": + return PERCENT; + default: + return new SimpleFormat(Value.UNKNOWN, value); + } + } + + public enum Value { + PERCENT, + + CURRENCY, + + NUMBER, + + IMAGE_URL, + + ID, + + LINK, + + UNKNOWN + } + + public interface Visitor { + T visitPercent(); + + T visitCurrency(); + + T visitNumber(); + + T visitImageUrl(); + + T visitId(); + + T visitLink(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/squareup/square/types/TimeDimension.java b/src/main/java/com/squareup/square/types/TimeDimension.java new file mode 100644 index 00000000..8d8cafd0 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TimeDimension.java @@ -0,0 +1,182 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.squareup.square.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.squareup.square.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TimeDimension.Builder.class) +public final class TimeDimension { + private final String dimension; + + private final Optional granularity; + + private final Optional> dateRange; + + private final Map additionalProperties; + + private TimeDimension( + String dimension, + Optional granularity, + Optional> dateRange, + Map additionalProperties) { + this.dimension = dimension; + this.granularity = granularity; + this.dateRange = dateRange; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("dimension") + public String getDimension() { + return dimension; + } + + @JsonProperty("granularity") + public Optional getGranularity() { + return granularity; + } + + @JsonProperty("dateRange") + public Optional> getDateRange() { + return dateRange; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TimeDimension && equalTo((TimeDimension) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TimeDimension other) { + return dimension.equals(other.dimension) + && granularity.equals(other.granularity) + && dateRange.equals(other.dateRange); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.dimension, this.granularity, this.dateRange); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DimensionStage builder() { + return new Builder(); + } + + public interface DimensionStage { + _FinalStage dimension(@NotNull String dimension); + + Builder from(TimeDimension other); + } + + public interface _FinalStage { + TimeDimension build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage granularity(Optional granularity); + + _FinalStage granularity(String granularity); + + _FinalStage dateRange(Optional> dateRange); + + _FinalStage dateRange(Map dateRange); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DimensionStage, _FinalStage { + private String dimension; + + private Optional> dateRange = Optional.empty(); + + private Optional granularity = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TimeDimension other) { + dimension(other.getDimension()); + granularity(other.getGranularity()); + dateRange(other.getDateRange()); + return this; + } + + @java.lang.Override + @JsonSetter("dimension") + public _FinalStage dimension(@NotNull String dimension) { + this.dimension = Objects.requireNonNull(dimension, "dimension must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage dateRange(Map dateRange) { + this.dateRange = Optional.ofNullable(dateRange); + return this; + } + + @java.lang.Override + @JsonSetter(value = "dateRange", nulls = Nulls.SKIP) + public _FinalStage dateRange(Optional> dateRange) { + this.dateRange = dateRange; + return this; + } + + @java.lang.Override + public _FinalStage granularity(String granularity) { + this.granularity = Optional.ofNullable(granularity); + return this; + } + + @java.lang.Override + @JsonSetter(value = "granularity", nulls = Nulls.SKIP) + public _FinalStage granularity(Optional granularity) { + this.granularity = granularity; + return this; + } + + @java.lang.Override + public TimeDimension build() { + return new TimeDimension(dimension, granularity, dateRange, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/squareup/square/utilities/LoadAndWaitOptions.java b/src/main/java/com/squareup/square/utilities/LoadAndWaitOptions.java new file mode 100644 index 00000000..ec44489c --- /dev/null +++ b/src/main/java/com/squareup/square/utilities/LoadAndWaitOptions.java @@ -0,0 +1,114 @@ +package com.squareup.square.utilities; + +import com.squareup.square.core.RequestOptions; + +/** + * Polling/backoff configuration for {@link ReportingHelper#loadAndWait(com.squareup.square.SquareClient, + * com.squareup.square.types.LoadRequest, LoadAndWaitOptions)}. + * + *

Defaults poll up to 20 times with exponential backoff (2s → 20s). Build with {@link #builder()}. + */ +public final class LoadAndWaitOptions { + private final int maxAttempts; + + private final long initialDelayMs; + + private final long maxDelayMs; + + private final double backoffFactor; + + private final RequestOptions requestOptions; + + private LoadAndWaitOptions( + int maxAttempts, + long initialDelayMs, + long maxDelayMs, + double backoffFactor, + RequestOptions requestOptions) { + this.maxAttempts = maxAttempts; + this.initialDelayMs = initialDelayMs; + this.maxDelayMs = maxDelayMs; + this.backoffFactor = backoffFactor; + this.requestOptions = requestOptions; + } + + /** Maximum poll attempts before giving up. Default 20. */ + public int getMaxAttempts() { + return maxAttempts; + } + + /** Delay before the first retry, in milliseconds. Default 2000. */ + public long getInitialDelayMs() { + return initialDelayMs; + } + + /** Upper bound on the backoff delay, in milliseconds. Default 20000. */ + public long getMaxDelayMs() { + return maxDelayMs; + } + + /** Multiplier applied to the delay after each attempt. Default 2. */ + public double getBackoffFactor() { + return backoffFactor; + } + + /** Forwarded to each underlying {@code client.reporting().load} call. May be {@code null}. */ + public RequestOptions getRequestOptions() { + return requestOptions; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private int maxAttempts = 20; + + private long initialDelayMs = 2000; + + private long maxDelayMs = 20000; + + private double backoffFactor = 2; + + private RequestOptions requestOptions = null; + + private Builder() {} + + /** Maximum poll attempts before giving up. Default 20. */ + public Builder maxAttempts(int maxAttempts) { + this.maxAttempts = maxAttempts; + return this; + } + + /** Delay before the first retry, in milliseconds. Default 2000. */ + public Builder initialDelayMs(long initialDelayMs) { + this.initialDelayMs = initialDelayMs; + return this; + } + + /** Upper bound on the backoff delay, in milliseconds. Default 20000. */ + public Builder maxDelayMs(long maxDelayMs) { + this.maxDelayMs = maxDelayMs; + return this; + } + + /** Multiplier applied to the delay after each attempt. Default 2. */ + public Builder backoffFactor(double backoffFactor) { + this.backoffFactor = backoffFactor; + return this; + } + + /** Forwarded to each underlying {@code client.reporting().load} call. */ + public Builder requestOptions(RequestOptions requestOptions) { + this.requestOptions = requestOptions; + return this; + } + + public LoadAndWaitOptions build() { + if (maxAttempts < 1) { + throw new IllegalArgumentException("maxAttempts must be at least 1"); + } + return new LoadAndWaitOptions(maxAttempts, initialDelayMs, maxDelayMs, backoffFactor, requestOptions); + } + } +} diff --git a/src/main/java/com/squareup/square/utilities/ReportingHelper.java b/src/main/java/com/squareup/square/utilities/ReportingHelper.java new file mode 100644 index 00000000..6330cad5 --- /dev/null +++ b/src/main/java/com/squareup/square/utilities/ReportingHelper.java @@ -0,0 +1,110 @@ +package com.squareup.square.utilities; + +import com.squareup.square.SquareClient; +import com.squareup.square.core.SquareException; +import com.squareup.square.types.LoadRequest; +import com.squareup.square.types.LoadResponse; + +/** + * Utility to help with the Square Reporting API. + * + *

The /reporting/v1/load endpoint is asynchronous: a query that is still being computed comes back as an + * HTTP 200 whose body is {"error": "Continue wait"} rather than the results. Clients are expected to + * re-send the identical request, with backoff, until real results arrive. {@link #loadAndWait} owns that retry loop. + */ +public final class ReportingHelper { + /** + * Sentinel returned by the Reporting API on an HTTP 200 while a /v1/load query is still processing. It + * is NOT an error — the request should be retried. + */ + private static final String CONTINUE_WAIT = "Continue wait"; + + private ReportingHelper() {} + + /** + * Runs a reporting query with an empty request body and the default polling options. See + * {@link #loadAndWait(SquareClient, LoadRequest, LoadAndWaitOptions)}. + */ + public static LoadResponse loadAndWait(SquareClient client) { + return loadAndWait( + client, + LoadRequest.builder().build(), + LoadAndWaitOptions.builder().build()); + } + + /** + * Runs a reporting query with the default polling options. See + * {@link #loadAndWait(SquareClient, LoadRequest, LoadAndWaitOptions)}. + */ + public static LoadResponse loadAndWait(SquareClient client, LoadRequest request) { + return loadAndWait(client, request, LoadAndWaitOptions.builder().build()); + } + + /** + * Runs a reporting query and transparently polls until it resolves, returning the final {@link LoadResponse}. + * Re-sends the identical request with exponential backoff while the API answers "Continue wait". + * + *

The poll loop honors thread interruption: interrupting the calling thread (for example via + * {@link java.util.concurrent.Future#cancel(boolean)}) aborts an in-flight wait and throws a {@link SquareException}. + * + * @param client a configured {@link SquareClient} + * @param request the reporting query (same shape as client.reporting().load) + * @param options polling/backoff configuration + * @return the resolved {@code LoadResponse} (never the "Continue wait" sentinel) + * @throws SquareException if the query does not resolve within {@code maxAttempts}, or the calling thread is + * interrupted while waiting + */ + public static LoadResponse loadAndWait(SquareClient client, LoadRequest request, LoadAndWaitOptions options) { + if (client == null) { + throw new IllegalArgumentException("client must not be null"); + } + LoadRequest query = request == null ? LoadRequest.builder().build() : request; + return poll(() -> client.reporting().load(query, options.getRequestOptions()), options); + } + + /** + * The core polling loop, decoupled from {@link SquareClient} so it can be exercised without a network. Visible for + * testing. + */ + static LoadResponse poll(LoadCall call, LoadAndWaitOptions options) { + long delayMs = options.getInitialDelayMs(); + for (int attempt = 1; attempt <= options.getMaxAttempts(); attempt++) { + LoadResponse response = call.load(); + if (!isContinueWait(response)) { + return response; + } + if (attempt == options.getMaxAttempts()) { + break; + } + sleep(delayMs); + delayMs = Math.min((long) (delayMs * options.getBackoffFactor()), options.getMaxDelayMs()); + } + throw new SquareException(String.format( + "Reporting query did not complete after %d attempts (\"%s\").", + options.getMaxAttempts(), CONTINUE_WAIT)); + } + + /** + * A "Continue wait" body deserializes into a {@link LoadResponse} (validation is skipped and unknown keys pass + * through) with the {@code error} sentinel preserved on {@link LoadResponse#getAdditionalProperties()} and + * {@code results} absent. That's the retry signal. + */ + private static boolean isContinueWait(LoadResponse response) { + return CONTINUE_WAIT.equals(response.getAdditionalProperties().get("error")); + } + + private static void sleep(long ms) { + try { + Thread.sleep(ms); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new SquareException("Reporting query polling was aborted.", e); + } + } + + /** A single invocation of {@code reporting().load}. Visible for testing. */ + @FunctionalInterface + interface LoadCall { + LoadResponse load(); + } +} diff --git a/src/test/java/com/squareup/square/integration/ReportingTest.java b/src/test/java/com/squareup/square/integration/ReportingTest.java new file mode 100644 index 00000000..95f8175f --- /dev/null +++ b/src/test/java/com/squareup/square/integration/ReportingTest.java @@ -0,0 +1,136 @@ +package com.squareup.square.integration; + +import static org.junit.jupiter.api.Assertions.*; + +import com.squareup.square.SquareClient; +import com.squareup.square.core.Environment; +import com.squareup.square.types.Cube; +import com.squareup.square.types.LoadRequest; +import com.squareup.square.types.LoadResponse; +import com.squareup.square.types.Measure; +import com.squareup.square.types.MetadataResponse; +import com.squareup.square.types.Query; +import com.squareup.square.utilities.LoadAndWaitOptions; +import com.squareup.square.utilities.ReportingHelper; +import java.util.Collections; +import java.util.List; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +/** + * Live smoke test for the Reporting API. + * + *

The Reporting API is a beta, bespoke offering served ONLY from production + * (connect.squareup.com/reporting) — it is not routed on sandbox (returns 404 there). Validating it live therefore + * needs a production, reporting-provisioned access token. CI's {@code TEST_SQUARE_TOKEN} is sandbox-only (it 401s + * against prod), so this suite is gated behind {@code TEST_SQUARE_REPORTING} — which IS that prod, reporting-provisioned + * token — and skips by default when it is unset, keeping CI green. The endpoints are read-only (schema discovery + + * queries). The polling logic is covered without a live account in {@code ReportingHelperTest}. + * + *

Run it against a real prod account: + * + *

{@code
+ * TEST_SQUARE_REPORTING= ./gradlew test --tests '*ReportingTest'
+ * # override the host with TEST_SQUARE_BASE_URL= if reporting moves.
+ * }
+ */ +public final class ReportingTest { + private static SquareClient client; + + @BeforeAll + static void setUp() { + // Skip the entire suite (rather than fail) unless explicitly opted in. + // A missing CI secret resolves to an empty string (not absent), so treat blank as unset. + String reportingToken = System.getenv("TEST_SQUARE_REPORTING"); + Assumptions.assumeTrue( + reportingToken != null && !reportingToken.isBlank(), + "Set TEST_SQUARE_REPORTING= to run the reporting integration suite."); + client = createReportingClient(); + } + + private static SquareClient createReportingClient() { + // The reporting suite authenticates with TEST_SQUARE_REPORTING — a production, reporting-provisioned + // access token (distinct from the sandbox TEST_SQUARE_TOKEN used by the other integration tests). + String token = System.getenv("TEST_SQUARE_REPORTING"); + if (token == null || token.isEmpty()) { + throw new IllegalArgumentException( + "TEST_SQUARE_REPORTING must be set to run the reporting integration suite."); + } + // Reporting only exists on production; allow overriding the host via TEST_SQUARE_BASE_URL. + String baseUrl = System.getenv("TEST_SQUARE_BASE_URL"); + Environment environment = baseUrl != null ? Environment.custom(baseUrl) : Environment.PRODUCTION; + // Make the live target unambiguous in the test output (useful when triaging CI). + System.out.println("[reporting] base URL: " + environment.getUrl() + " -> " + environment.getUrl() + + "/reporting/v1/{meta,load}"); + return SquareClient.builder().token(token).environment(environment).build(); + } + + /** Resolves the first queryable measure from the live schema, e.g. "Orders.count". */ + private static String firstMeasureName() { + MetadataResponse metadata = client.reporting().getMetadata(); + List cubes = metadata.getCubes().orElse(Collections.emptyList()); + for (Cube cube : cubes) { + for (Measure measure : cube.getMeasures()) { + if (measure.getName() != null) { + return measure.getName(); + } + } + } + throw new IllegalStateException("No cubes/measures are available on the reporting schema for this account."); + } + + @Test + public void getMetadataReturnsQueryableSchema() { + MetadataResponse metadata = client.reporting().getMetadata(); + + List cubes = metadata.getCubes().orElse(Collections.emptyList()); + assertFalse(cubes.isEmpty(), "Expected at least one cube on the reporting schema."); + System.out.println("Reporting schema: " + cubes.size() + " cube(s); first = " + + cubes.get(0).getName()); + } + + @Test + public void loadReturnsResultsOrContinueWaitSentinel() { + String measure = firstMeasureName(); + LoadRequest request = LoadRequest.builder() + .query(Query.builder() + .measures(Collections.singletonList(measure)) + .build()) + .build(); + + LoadResponse response = client.reporting().load(request); + + Object sentinel = response.getAdditionalProperties().get("error"); + if (sentinel != null) { + // Documented async behavior: a still-processing query comes back as HTTP 200 + // with { "error": "Continue wait" } instead of results. + assertEquals("Continue wait", sentinel); + } else { + assertNotNull(response.getResults()); + } + } + + @Test + public void loadAndWaitResolvesQueryWithoutSurfacingContinueWait() { + String measure = firstMeasureName(); + LoadRequest request = LoadRequest.builder() + .query(Query.builder() + .measures(Collections.singletonList(measure)) + .build()) + .build(); + + LoadResponse response = ReportingHelper.loadAndWait( + client, + request, + LoadAndWaitOptions.builder() + .maxAttempts(20) + .initialDelayMs(2_000) + .maxDelayMs(20_000) + .build()); + + // The polling helper must never hand back the raw "Continue wait" sentinel. + assertNull(response.getAdditionalProperties().get("error")); + assertNotNull(response.getResults()); + } +} diff --git a/src/test/java/com/squareup/square/utilities/ReportingHelperTest.java b/src/test/java/com/squareup/square/utilities/ReportingHelperTest.java new file mode 100644 index 00000000..12cba467 --- /dev/null +++ b/src/test/java/com/squareup/square/utilities/ReportingHelperTest.java @@ -0,0 +1,107 @@ +package com.squareup.square.utilities; + +import static org.junit.jupiter.api.Assertions.*; + +import com.squareup.square.core.ObjectMappers; +import com.squareup.square.core.SquareException; +import com.squareup.square.types.LoadResponse; +import java.util.concurrent.atomic.AtomicInteger; +import org.junit.jupiter.api.Test; + +/** + * The Reporting API answers a still-processing /v1/load query with an HTTP 200 whose body is + * {"error": "Continue wait"}. {@link ReportingHelper#loadAndWait} owns the retry loop around that sentinel. + * These tests exercise the loop without a network by scripting the underlying {@code load} call, plus one test that + * proves the sentinel actually survives the generated client's deserialization. + */ +public final class ReportingHelperTest { + private static final String CONTINUE_WAIT = "Continue wait"; + + private static final LoadResponse CONTINUE_WAIT_RESPONSE = + LoadResponse.builder().additionalProperty("error", CONTINUE_WAIT).build(); + + private static final LoadResponse RESOLVED_RESPONSE = + LoadResponse.builder().queryType("regularQuery").build(); + + /** A scripted {@code load} that returns each response in turn, then repeats the last one. */ + private static ReportingHelper.LoadCall scripted(AtomicInteger calls, LoadResponse... sequence) { + return () -> { + int i = calls.getAndIncrement(); + return sequence[Math.min(i, sequence.length - 1)]; + }; + } + + private static LoadAndWaitOptions fastOptions(int maxAttempts) { + return LoadAndWaitOptions.builder() + .initialDelayMs(1) + .maxDelayMs(1) + .maxAttempts(maxAttempts) + .build(); + } + + @Test + public void pollsPastContinueWaitAndReturnsResolvedResult() { + AtomicInteger calls = new AtomicInteger(); + ReportingHelper.LoadCall call = + scripted(calls, CONTINUE_WAIT_RESPONSE, CONTINUE_WAIT_RESPONSE, RESOLVED_RESPONSE); + + LoadResponse response = ReportingHelper.poll(call, fastOptions(5)); + + // The helper must never hand back the raw sentinel. + assertNull(response.getAdditionalProperties().get("error")); + assertEquals(3, calls.get()); + } + + @Test + public void returnsImmediatelyWhenFirstResponseHasResults() { + AtomicInteger calls = new AtomicInteger(); + ReportingHelper.LoadCall call = scripted(calls, RESOLVED_RESPONSE); + + LoadResponse response = ReportingHelper.poll(call, fastOptions(5)); + + assertNull(response.getAdditionalProperties().get("error")); + assertEquals(1, calls.get()); + } + + @Test + public void throwsOnceMaxAttemptsExhaustedWhileStillContinueWait() { + AtomicInteger calls = new AtomicInteger(); + ReportingHelper.LoadCall call = scripted(calls, CONTINUE_WAIT_RESPONSE); // never resolves + + SquareException ex = assertThrows(SquareException.class, () -> ReportingHelper.poll(call, fastOptions(3))); + + assertTrue(ex.getMessage().contains("did not complete after 3 attempts")); + assertEquals(3, calls.get()); + } + + @Test + public void honorsThreadInterruptionMidPoll() { + AtomicInteger calls = new AtomicInteger(); + ReportingHelper.LoadCall call = scripted(calls, CONTINUE_WAIT_RESPONSE); // would otherwise poll forever + LoadAndWaitOptions options = LoadAndWaitOptions.builder() + .initialDelayMs(60_000) + .maxAttempts(10) + .build(); + + // Arm interruption so the first backoff sleep aborts immediately. + Thread.currentThread().interrupt(); + try { + SquareException ex = assertThrows(SquareException.class, () -> ReportingHelper.poll(call, options)); + assertTrue(ex.getMessage().contains("aborted")); + } finally { + // Clear the interrupt flag so it does not leak into other tests. + Thread.interrupted(); + } + } + + @Test + public void treatsRealDeserializerContinueWaitBodyAsRetrySignal() throws Exception { + // The crux of the design: the generated reporting.load deserializes the body with unknown-key passthrough, + // so the "error" sentinel survives onto a LoadResponse (in additionalProperties) and "results" stays empty. + // If this ever stops being true, loadAndWait would mistake "Continue wait" for a real result. + LoadResponse parsed = ObjectMappers.JSON_MAPPER.readValue("{\"error\":\"Continue wait\"}", LoadResponse.class); + + assertEquals(CONTINUE_WAIT, parsed.getAdditionalProperties().get("error")); + assertTrue(parsed.getResults().isEmpty()); + } +}