From 62d31e976c8c6c04b9056cf74da729fd2a78ca4f Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 16 Oct 2025 15:52:03 +0000 Subject: [PATCH] SDK regeneration --- README.md | 10 +- build.gradle | 4 +- reference.md | 1282 ++++++++++++++++- .../squareup/square/AsyncCatalogClient.java | 14 +- .../squareup/square/AsyncChannelsClient.java | 63 + .../squareup/square/AsyncCustomersClient.java | 7 +- .../squareup/square/AsyncInventoryClient.java | 14 +- .../squareup/square/AsyncInvoicesClient.java | 5 +- .../squareup/square/AsyncLoyaltyClient.java | 9 +- .../squareup/square/AsyncOrdersClient.java | 10 +- .../square/AsyncRawCatalogClient.java | 56 +- .../square/AsyncRawChannelsClient.java | 250 ++++ .../square/AsyncRawCustomersClient.java | 28 +- .../square/AsyncRawInventoryClient.java | 58 +- .../square/AsyncRawInvoicesClient.java | 26 +- .../square/AsyncRawLoyaltyClient.java | 34 +- .../squareup/square/AsyncRawOrdersClient.java | 32 +- .../square/AsyncRawSubscriptionsClient.java | 30 +- .../square/AsyncRawTeamMembersClient.java | 34 +- .../square/AsyncRawTransferOrdersClient.java | 749 ++++++++++ .../square/AsyncRawVendorsClient.java | 33 +- .../squareup/square/AsyncSquareClient.java | 14 + .../square/AsyncSquareClientBuilder.java | 2 +- .../square/AsyncSubscriptionsClient.java | 8 +- .../square/AsyncTeamMembersClient.java | 9 +- .../square/AsyncTransferOrdersClient.java | 307 ++++ .../squareup/square/AsyncVendorsClient.java | 9 +- .../com/squareup/square/CatalogClient.java | 16 +- .../com/squareup/square/ChannelsClient.java | 61 + .../com/squareup/square/CustomersClient.java | 7 +- .../com/squareup/square/InventoryClient.java | 14 +- .../com/squareup/square/InvoicesClient.java | 5 +- .../com/squareup/square/LoyaltyClient.java | 10 +- .../com/squareup/square/OrdersClient.java | 9 +- .../com/squareup/square/RawCatalogClient.java | 36 +- .../squareup/square/RawChannelsClient.java | 197 +++ .../squareup/square/RawCustomersClient.java | 18 +- .../squareup/square/RawInventoryClient.java | 40 +- .../squareup/square/RawInvoicesClient.java | 16 +- .../com/squareup/square/RawLoyaltyClient.java | 23 +- .../com/squareup/square/RawOrdersClient.java | 23 +- .../square/RawSubscriptionsClient.java | 19 +- .../squareup/square/RawTeamMembersClient.java | 23 +- .../square/RawTransferOrdersClient.java | 617 ++++++++ .../com/squareup/square/RawVendorsClient.java | 23 +- .../com/squareup/square/SquareClient.java | 14 + .../squareup/square/SquareClientBuilder.java | 2 +- .../squareup/square/SubscriptionsClient.java | 8 +- .../squareup/square/TeamMembersClient.java | 9 +- .../squareup/square/TransferOrdersClient.java | 299 ++++ .../com/squareup/square/VendorsClient.java | 9 +- .../squareup/square/core/ClientOptions.java | 4 +- .../square/labor/AsyncRawShiftsClient.java | 32 +- .../square/labor/AsyncShiftsClient.java | 10 +- .../square/labor/RawShiftsClient.java | 23 +- .../squareup/square/labor/ShiftsClient.java | 9 +- .../square/loyalty/AccountsClient.java | 10 +- .../square/loyalty/AsyncAccountsClient.java | 9 +- .../loyalty/AsyncRawAccountsClient.java | 35 +- .../square/loyalty/AsyncRawRewardsClient.java | 34 +- .../square/loyalty/AsyncRewardsClient.java | 9 +- .../square/loyalty/RawAccountsClient.java | 24 +- .../square/loyalty/RawRewardsClient.java | 23 +- .../square/loyalty/RewardsClient.java | 10 +- .../types/CancelPromotionsRequest.java | 78 +- .../programs/types/GetPromotionsRequest.java | 78 +- .../square/terminal/ActionsClient.java | 10 +- .../square/terminal/AsyncActionsClient.java | 9 +- .../square/terminal/AsyncCheckoutsClient.java | 9 +- .../terminal/AsyncRawActionsClient.java | 34 +- .../terminal/AsyncRawCheckoutsClient.java | 35 +- .../terminal/AsyncRawRefundsClient.java | 35 +- .../square/terminal/AsyncRefundsClient.java | 9 +- .../square/terminal/CheckoutsClient.java | 9 +- .../square/terminal/RawActionsClient.java | 23 +- .../square/terminal/RawCheckoutsClient.java | 25 +- .../square/terminal/RawRefundsClient.java | 23 +- .../square/terminal/RefundsClient.java | 10 +- .../types/BulkRetrieveChannelsRequest.java | 104 ++ .../types/BulkRetrieveChannelsResponse.java | 139 ++ .../types/CancelTransferOrderRequest.java | 199 +++ .../types/CancelTransferOrderResponse.java | 133 ++ .../com/squareup/square/types/Channel.java | 351 +++++ .../squareup/square/types/ChannelStatus.java | 83 ++ .../square/types/CreateTransferOrderData.java | 535 +++++++ .../types/CreateTransferOrderLineData.java | 171 +++ .../types/CreateTransferOrderRequest.java | 151 ++ .../types/CreateTransferOrderResponse.java | 133 ++ .../square/types/CustomAttribute.java | 34 +- .../types/DeleteTransferOrderResponse.java | 102 ++ .../types/DeleteTransferOrdersRequest.java | 187 +++ .../square/types/GetChannelsRequest.java | 113 ++ .../types/GetTransferOrdersRequest.java | 113 ++ .../square/types/ListChannelsRequest.java | 328 +++++ .../square/types/ListChannelsResponse.java | 162 +++ .../types/ReceiveTransferOrderRequest.java | 231 +++ .../types/ReceiveTransferOrderResponse.java | 133 ++ .../com/squareup/square/types/Reference.java | 131 ++ .../squareup/square/types/ReferenceType.java | 218 +++ .../square/types/RetrieveChannelResponse.java | 131 ++ .../types/RetrieveTransferOrderResponse.java | 133 ++ .../types/SearchTransferOrdersRequest.java | 161 +++ .../types/SearchTransferOrdersResponse.java | 164 +++ .../types/StartTransferOrderRequest.java | 199 +++ .../types/StartTransferOrderResponse.java | 133 ++ .../squareup/square/types/TransferOrder.java | 714 +++++++++ .../types/TransferOrderCreatedEvent.java | 286 ++++ .../types/TransferOrderCreatedEventData.java | 184 +++ .../TransferOrderCreatedEventObject.java | 102 ++ .../types/TransferOrderDeletedEvent.java | 286 ++++ .../types/TransferOrderDeletedEventData.java | 204 +++ .../square/types/TransferOrderFilter.java | 229 +++ .../types/TransferOrderGoodsReceipt.java | 152 ++ .../TransferOrderGoodsReceiptLineItem.java | 343 +++++ .../square/types/TransferOrderLine.java | 410 ++++++ .../square/types/TransferOrderQuery.java | 132 ++ .../square/types/TransferOrderSort.java | 136 ++ .../square/types/TransferOrderSortField.java | 84 ++ .../square/types/TransferOrderStatus.java | 114 ++ .../types/TransferOrderUpdatedEvent.java | 286 ++++ .../types/TransferOrderUpdatedEventData.java | 184 +++ .../TransferOrderUpdatedEventObject.java | 102 ++ .../square/types/UpdateTransferOrderData.java | 394 +++++ .../types/UpdateTransferOrderLineData.java | 278 ++++ .../types/UpdateTransferOrderRequest.java | 232 +++ .../types/UpdateTransferOrderResponse.java | 133 ++ 126 files changed, 14439 insertions(+), 432 deletions(-) create mode 100644 src/main/java/com/squareup/square/AsyncChannelsClient.java create mode 100644 src/main/java/com/squareup/square/AsyncRawChannelsClient.java create mode 100644 src/main/java/com/squareup/square/AsyncRawTransferOrdersClient.java create mode 100644 src/main/java/com/squareup/square/AsyncTransferOrdersClient.java create mode 100644 src/main/java/com/squareup/square/ChannelsClient.java create mode 100644 src/main/java/com/squareup/square/RawChannelsClient.java create mode 100644 src/main/java/com/squareup/square/RawTransferOrdersClient.java create mode 100644 src/main/java/com/squareup/square/TransferOrdersClient.java create mode 100644 src/main/java/com/squareup/square/types/BulkRetrieveChannelsRequest.java create mode 100644 src/main/java/com/squareup/square/types/BulkRetrieveChannelsResponse.java create mode 100644 src/main/java/com/squareup/square/types/CancelTransferOrderRequest.java create mode 100644 src/main/java/com/squareup/square/types/CancelTransferOrderResponse.java create mode 100644 src/main/java/com/squareup/square/types/Channel.java create mode 100644 src/main/java/com/squareup/square/types/ChannelStatus.java create mode 100644 src/main/java/com/squareup/square/types/CreateTransferOrderData.java create mode 100644 src/main/java/com/squareup/square/types/CreateTransferOrderLineData.java create mode 100644 src/main/java/com/squareup/square/types/CreateTransferOrderRequest.java create mode 100644 src/main/java/com/squareup/square/types/CreateTransferOrderResponse.java create mode 100644 src/main/java/com/squareup/square/types/DeleteTransferOrderResponse.java create mode 100644 src/main/java/com/squareup/square/types/DeleteTransferOrdersRequest.java create mode 100644 src/main/java/com/squareup/square/types/GetChannelsRequest.java create mode 100644 src/main/java/com/squareup/square/types/GetTransferOrdersRequest.java create mode 100644 src/main/java/com/squareup/square/types/ListChannelsRequest.java create mode 100644 src/main/java/com/squareup/square/types/ListChannelsResponse.java create mode 100644 src/main/java/com/squareup/square/types/ReceiveTransferOrderRequest.java create mode 100644 src/main/java/com/squareup/square/types/ReceiveTransferOrderResponse.java create mode 100644 src/main/java/com/squareup/square/types/Reference.java create mode 100644 src/main/java/com/squareup/square/types/ReferenceType.java create mode 100644 src/main/java/com/squareup/square/types/RetrieveChannelResponse.java create mode 100644 src/main/java/com/squareup/square/types/RetrieveTransferOrderResponse.java create mode 100644 src/main/java/com/squareup/square/types/SearchTransferOrdersRequest.java create mode 100644 src/main/java/com/squareup/square/types/SearchTransferOrdersResponse.java create mode 100644 src/main/java/com/squareup/square/types/StartTransferOrderRequest.java create mode 100644 src/main/java/com/squareup/square/types/StartTransferOrderResponse.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrder.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderCreatedEvent.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderCreatedEventData.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderCreatedEventObject.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderDeletedEvent.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderDeletedEventData.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderFilter.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderGoodsReceipt.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderGoodsReceiptLineItem.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderLine.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderQuery.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderSort.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderSortField.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderStatus.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderUpdatedEvent.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderUpdatedEventData.java create mode 100644 src/main/java/com/squareup/square/types/TransferOrderUpdatedEventObject.java create mode 100644 src/main/java/com/squareup/square/types/UpdateTransferOrderData.java create mode 100644 src/main/java/com/squareup/square/types/UpdateTransferOrderLineData.java create mode 100644 src/main/java/com/squareup/square/types/UpdateTransferOrderRequest.java create mode 100644 src/main/java/com/squareup/square/types/UpdateTransferOrderResponse.java diff --git a/README.md b/README.md index 9ff27443..da5c11ec 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Add the dependency in your `pom.xml` file: com.squareup square - 45.0.0.20250924 + 45.1.0.20251016 ``` @@ -336,8 +336,8 @@ Gradle: ```groovy dependencies { - implementation 'com.squareup:square:45.0.0.20250924' - implementation 'com.squareup:square-legacy:45.0.0.20250924' + implementation 'com.squareup:square:45.1.0.20251016' + implementation 'com.squareup:square-legacy:45.1.0.20251016' } ``` @@ -347,12 +347,12 @@ Maven: com.squareup square - 45.0.0.20250924 + 45.1.0.20251016 com.squareup square-legacy - 45.0.0.20250924 + 45.1.0.20251016 ``` diff --git a/build.gradle b/build.gradle index b5f723c1..ed6b345e 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ java { group = 'com.squareup' -version = '45.0.0.20250924' +version = '45.1.0.20251016' jar { dependsOn(":generatePomFileForMavenPublication") @@ -78,7 +78,7 @@ publishing { maven(MavenPublication) { groupId = 'com.squareup' artifactId = 'square' - version = '45.0.0.20250924' + version = '45.1.0.20251016' from components.java pom { name = 'square' diff --git a/reference.md b/reference.md index 4d998d2e..b341cd67 100644 --- a/reference.md +++ b/reference.md @@ -505,6 +505,9 @@ client.v1Transactions().v1ListOrders( V1ListOrdersRequest .builder() .locationId("location_id") + .order(SortOrder.DESC) + .limit(1) + .batchToken("batch_token") .build() ); ``` @@ -844,6 +847,9 @@ Returns a list of [BankAccount](entity:BankAccount) objects linked to a Square a client.bankAccounts().list( ListBankAccountsRequest .builder() + .cursor("cursor") + .limit(1) + .locationId("location_id") .build() ); ``` @@ -1057,6 +1063,13 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` client.bookings().list( ListBookingsRequest .builder() + .limit(1) + .cursor("cursor") + .customerId("customer_id") + .teamMemberId("team_member_id") + .locationId("location_id") + .startAtMin("start_at_min") + .startAtMax("start_at_max") .build() ); ``` @@ -1777,6 +1790,11 @@ A max of 25 cards will be returned. client.cards().list( ListCardsRequest .builder() + .cursor("cursor") + .customerId("customer_id") + .includeDisabled(true) + .referenceId("reference_id") + .sortOrder(SortOrder.DESC) .build() ); ``` @@ -2512,6 +2530,9 @@ and set the `include_deleted_objects` attribute value to `true`. client.catalog().list( ListCatalogRequest .builder() + .cursor("cursor") + .types("types") + .catalogVersion(1000000L) .build() ); ``` @@ -3158,6 +3179,225 @@ At least one of `taxes_to_enable` or `taxes_to_disable` must be specified. + + + + +## Channels +
client.channels.list() -> ListChannelsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.channels().list( + ListChannelsRequest + .builder() + .referenceType(ReferenceType.UNKNOWN_TYPE) + .referenceId("reference_id") + .status(ChannelStatus.ACTIVE) + .cursor("cursor") + .limit(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**referenceType:** `Optional` — Type of reference associated to channel + +
+
+ +
+
+ +**referenceId:** `Optional` — id of reference associated to channel + +
+
+ +
+
+ +**status:** `Optional` — Status of channel + +
+
+ +
+
+ +**cursor:** `Optional` — Cursor to fetch the next result + +
+
+ +
+
+ +**limit:** `Optional` + +Maximum number of results to return. +When not provided the returned results will be cap at 100 channels. + +
+
+
+
+ + +
+
+
+ +
client.channels.bulkRetrieve(request) -> BulkRetrieveChannelsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.channels().bulkRetrieve( + BulkRetrieveChannelsRequest + .builder() + .channelIds( + Arrays.asList("CH_9C03D0B59", "CH_6X139B5MN", "NOT_EXISTING") + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**channelIds:** `List` + +
+
+
+
+ + +
+
+
+ +
client.channels.get(channelId) -> RetrieveChannelResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.channels().get( + GetChannelsRequest + .builder() + .channelId("channel_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**channelId:** `String` — A channel id + +
+
+
+
+ +
@@ -3197,6 +3437,11 @@ profiles can take closer to one minute or longer, especially during network inci client.customers().list( ListCustomersRequest .builder() + .cursor("cursor") + .limit(1) + .sortField(CustomerSortField.DEFAULT) + .sortOrder(SortOrder.DESC) + .count(true) .build() ); ``` @@ -4288,6 +4533,7 @@ client.customers().delete( DeleteCustomersRequest .builder() .customerId("customer_id") + .version(1000000L) .build() ); ``` @@ -4360,6 +4606,10 @@ devices are supported. client.devices().list( ListDevicesRequest .builder() + .cursor("cursor") + .sortOrder(SortOrder.DESC) + .limit(1) + .locationId("location_id") .build() ); ``` @@ -4510,6 +4760,9 @@ Returns a list of disputes associated with a particular account. client.disputes().list( ListDisputesRequest .builder() + .cursor("cursor") + .states(DisputeState.INQUIRY_EVIDENCE_REQUIRED) + .locationId("location_id") .build() ); ``` @@ -4928,6 +5181,10 @@ client.disputes().submitEvidence( client.employees().list( ListEmployeesRequest .builder() + .locationId("location_id") + .status(EmployeeStatus.ACTIVE) + .limit(1) + .cursor("cursor") .build() ); ``` @@ -5234,6 +5491,7 @@ Lists all event types that you can subscribe to as webhooks or query using the E client.events().listEventTypes( ListEventTypesRequest .builder() + .apiVersion("api_version") .build() ); ``` @@ -5294,6 +5552,11 @@ a subset of the gift cards. Results are sorted by `created_at` in ascending orde client.giftCards().list( ListGiftCardsRequest .builder() + .type("type") + .state("state") + .limit(1) + .cursor("cursor") + .customerId("customer_id") .build() ); ``` @@ -6625,6 +6888,8 @@ client.inventory().get( GetInventoryRequest .builder() .catalogObjectId("catalog_object_id") + .locationIds("location_ids") + .cursor("cursor") .build() ); ``` @@ -6720,6 +6985,8 @@ client.inventory().changes( ChangesInventoryRequest .builder() .catalogObjectId("catalog_object_id") + .locationIds("location_ids") + .cursor("cursor") .build() ); ``` @@ -6806,6 +7073,8 @@ client.invoices().list( ListInvoicesRequest .builder() .locationId("location_id") + .cursor("cursor") + .limit(1) .build() ); ``` @@ -7332,6 +7601,7 @@ client.invoices().delete( DeleteInvoicesRequest .builder() .invoiceId("invoice_id") + .version(1) .build() ); ``` @@ -9507,6 +9777,7 @@ endpoint to retrieve the merchant information. client.merchants().list( ListMerchantsRequest .builder() + .cursor(1) .build() ); ``` @@ -10804,6 +11075,21 @@ The maximum results per page is 100. client.payments().list( ListPaymentsRequest .builder() + .beginTime("begin_time") + .endTime("end_time") + .sortOrder("sort_order") + .cursor("cursor") + .locationId("location_id") + .total(1000000L) + .last4("last_4") + .cardBrand("card_brand") + .limit(1) + .isOfflinePayment(true) + .offlineBeginTime("offline_begin_time") + .offlineEndTime("offline_end_time") + .updatedAtBeginTime("updated_at_begin_time") + .updatedAtEndTime("updated_at_end_time") + .sortField(ListPaymentsRequestSortField.CREATED_AT) .build() ); ``` @@ -11799,6 +12085,13 @@ To call this endpoint, set `PAYOUTS_READ` for the OAuth scope. client.payouts().list( ListPayoutsRequest .builder() + .locationId("location_id") + .status(PayoutStatus.SENT) + .beginTime("begin_time") + .endTime("end_time") + .sortOrder(SortOrder.DESC) + .cursor("cursor") + .limit(1) .build() ); ``` @@ -11987,6 +12280,9 @@ client.payouts().listEntries( ListEntriesPayoutsRequest .builder() .payoutId("payout_id") + .sortOrder(SortOrder.DESC) + .cursor("cursor") + .limit(1) .build() ); ``` @@ -12086,6 +12382,17 @@ The maximum results per page is 100. client.refunds().list( ListRefundsRequest .builder() + .beginTime("begin_time") + .endTime("end_time") + .sortOrder("sort_order") + .cursor("cursor") + .locationId("location_id") + .status("status") + .sourceType("source_type") + .limit(1) + .updatedAtBeginTime("updated_at_begin_time") + .updatedAtEndTime("updated_at_end_time") + .sortField(ListPaymentRefundsRequestSortField.CREATED_AT) .build() ); ``` @@ -13272,6 +13579,7 @@ client.subscriptions().get( GetSubscriptionsRequest .builder() .subscriptionId("subscription_id") + .include("include") .build() ); ``` @@ -13635,6 +13943,8 @@ client.subscriptions().listEvents( ListEventsSubscriptionsRequest .builder() .subscriptionId("subscription_id") + .cursor("cursor") + .limit(1) .build() ); ``` @@ -14671,6 +14981,7 @@ Lists jobs in a seller account. Results are sorted by title in ascending order. client.team().listJobs( ListJobsRequest .builder() + .cursor("cursor") .build() ); ``` @@ -15100,8 +15411,8 @@ client.terminal().dismissTerminalRefund( -## Vendors -
client.vendors.batchCreate(request) -> BatchCreateVendorsResponse +## TransferOrders +
client.transferOrders.create(request) -> CreateTransferOrderResponse
@@ -15113,7 +15424,26 @@ client.terminal().dismissTerminalRefund(
-Creates one or more [Vendor](entity:Vendor) objects to represent suppliers to a seller. +Creates a new transfer order in [DRAFT](entity:TransferOrderStatus) status. A transfer order represents the intent +to move [CatalogItemVariation](entity:CatalogItemVariation)s from one [Location](entity:Location) to another. +The source and destination locations must be different and must belong to your Square account. + +In [DRAFT](entity:TransferOrderStatus) status, you can: +- Add or remove items +- Modify quantities +- Update shipping information +- Delete the entire order via [DeleteTransferOrder](api-endpoint:TransferOrders-DeleteTransferOrder) + +The request requires source_location_id and destination_location_id. +Inventory levels are not affected until the order is started via +[StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder). + +Common integration points: +- Sync with warehouse management systems +- Automate regular stock transfers +- Initialize transfers from inventory optimization systems + +Creates a [transfer_order.created](webhook:transfer_order.created) webhook event.
@@ -15128,34 +15458,802 @@ Creates one or more [Vendor](entity:Vendor) objects to represent suppliers to a
```java -client.vendors().batchCreate( - BatchCreateVendorsRequest +client.transferOrders().create( + CreateTransferOrderRequest .builder() - .vendors( - new HashMap() {{ - put("8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", Vendor - .builder() - .name(Optional.of("Joe's Fresh Seafood")) - .address( - Optional.of( - Address + .idempotencyKey("65cc0586-3e82-384s-b524-3885cffd52") + .transferOrder( + CreateTransferOrderData + .builder() + .sourceLocationId("EXAMPLE_SOURCE_LOCATION_ID_123") + .destinationLocationId("EXAMPLE_DEST_LOCATION_ID_456") + .expectedAt("2025-11-09T05:00:00Z") + .notes("Example transfer order for inventory redistribution between locations") + .trackingNumber("TRACK123456789") + .createdByTeamMemberId("EXAMPLE_TEAM_MEMBER_ID_789") + .lineItems( + Optional.of( + Arrays.asList( + CreateTransferOrderLineData .builder() - .addressLine1(Optional.of("505 Electric Ave")) - .addressLine2(Optional.of("Suite 600")) - .locality(Optional.of("New York")) - .administrativeDistrictLevel1(Optional.of("NY")) - .postalCode(Optional.of("10003")) - .country(Optional.of(Country.US)) + .itemVariationId("EXAMPLE_ITEM_VARIATION_ID_001") + .quantityOrdered("5") + .build(), + CreateTransferOrderLineData + .builder() + .itemVariationId("EXAMPLE_ITEM_VARIATION_ID_002") + .quantityOrdered("3") .build() ) ) - .contacts( - Optional.of( - Arrays.asList( - VendorContact - .builder() - .ordinal(1) - .name("Joe Burrow") + ) + .build() + ) + .build() +); +``` +
+
+ + + +#### ⚙️ Parameters + +
+
+ +
+
+ +**idempotencyKey:** `String` + +A unique string that identifies this CreateTransferOrder request. Keys can be +any valid string but must be unique for every CreateTransferOrder request. + +
+
+ +
+
+ +**transferOrder:** `CreateTransferOrderData` — The transfer order to create + +
+
+
+
+ + + + +
+ +
client.transferOrders.search(request) -> SearchTransferOrdersResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Searches for transfer orders using filters. Returns a paginated list of matching +[TransferOrder](entity:TransferOrder)s sorted by creation date. + +Common search scenarios: +- Find orders for a source [Location](entity:Location) +- Find orders for a destination [Location](entity:Location) +- Find orders in a particular [TransferOrderStatus](entity:TransferOrderStatus) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.transferOrders().search( + SearchTransferOrdersRequest + .builder() + .query( + TransferOrderQuery + .builder() + .filter( + TransferOrderFilter + .builder() + .sourceLocationIds( + Optional.of( + Arrays.asList("EXAMPLE_SOURCE_LOCATION_ID_123") + ) + ) + .destinationLocationIds( + Optional.of( + Arrays.asList("EXAMPLE_DEST_LOCATION_ID_456") + ) + ) + .statuses( + Optional.of( + Arrays.asList(TransferOrderStatus.STARTED, TransferOrderStatus.PARTIALLY_RECEIVED) + ) + ) + .build() + ) + .sort( + TransferOrderSort + .builder() + .field(TransferOrderSortField.UPDATED_AT) + .order(SortOrder.DESC) + .build() + ) + .build() + ) + .cursor("eyJsYXN0X3VwZGF0ZWRfYXQiOjE3NTMxMTg2NjQ4NzN9") + .limit(10) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**query:** `Optional` — The search query + +
+
+ +
+
+ +**cursor:** `Optional` — Pagination cursor from a previous search response + +
+
+ +
+
+ +**limit:** `Optional` — Maximum number of results to return (1-100) + +
+
+
+
+ + +
+
+
+ +
client.transferOrders.get(transferOrderId) -> RetrieveTransferOrderResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieves a specific [TransferOrder](entity:TransferOrder) by ID. Returns the complete +order details including: + +- Basic information (status, dates, notes) +- Line items with ordered and received quantities +- Source and destination [Location](entity:Location)s +- Tracking information (if available) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.transferOrders().get( + GetTransferOrdersRequest + .builder() + .transferOrderId("transfer_order_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transferOrderId:** `String` — The ID of the transfer order to retrieve + +
+
+
+
+ + +
+
+
+ +
client.transferOrders.update(transferOrderId, request) -> UpdateTransferOrderResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates an existing transfer order. This endpoint supports sparse updates, +allowing you to modify specific fields without affecting others. + +Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.transferOrders().update( + UpdateTransferOrderRequest + .builder() + .transferOrderId("transfer_order_id") + .idempotencyKey("f47ac10b-58cc-4372-a567-0e02b2c3d479") + .transferOrder( + UpdateTransferOrderData + .builder() + .sourceLocationId("EXAMPLE_SOURCE_LOCATION_ID_789") + .destinationLocationId("EXAMPLE_DEST_LOCATION_ID_101") + .expectedAt("2025-11-10T08:00:00Z") + .notes("Updated: Priority transfer due to low stock at destination") + .trackingNumber("TRACK987654321") + .lineItems( + Optional.of( + Arrays.asList( + UpdateTransferOrderLineData + .builder() + .uid("1") + .quantityOrdered("7") + .build(), + UpdateTransferOrderLineData + .builder() + .itemVariationId("EXAMPLE_NEW_ITEM_VARIATION_ID_003") + .quantityOrdered("2") + .build(), + UpdateTransferOrderLineData + .builder() + .uid("2") + .remove(true) + .build() + ) + ) + ) + .build() + ) + .version(1753109537351L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transferOrderId:** `String` — The ID of the transfer order to update + +
+
+ +
+
+ +**idempotencyKey:** `String` — A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores + +
+
+ +
+
+ +**transferOrder:** `UpdateTransferOrderData` — The transfer order updates to apply + +
+
+ +
+
+ +**version:** `Optional` — Version for optimistic concurrency + +
+
+
+
+ + +
+
+
+ +
client.transferOrders.delete(transferOrderId) -> DeleteTransferOrderResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Deletes a transfer order in [DRAFT](entity:TransferOrderStatus) status. +Only draft orders can be deleted. Once an order is started via +[StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder), it can no longer be deleted. + +Creates a [transfer_order.deleted](webhook:transfer_order.deleted) webhook event. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.transferOrders().delete( + DeleteTransferOrdersRequest + .builder() + .transferOrderId("transfer_order_id") + .version(1000000L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transferOrderId:** `String` — The ID of the transfer order to delete + +
+
+ +
+
+ +**version:** `Optional` — Version for optimistic concurrency + +
+
+
+
+ + +
+
+
+ +
client.transferOrders.cancel(transferOrderId, request) -> CancelTransferOrderResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Cancels a transfer order in [STARTED](entity:TransferOrderStatus) or +[PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. Any unreceived quantities will no +longer be receivable and will be immediately returned to the source [Location](entity:Location)'s inventory. + +Common reasons for cancellation: +- Items no longer needed at destination +- Source location needs the inventory +- Order created in error + +Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.transferOrders().cancel( + CancelTransferOrderRequest + .builder() + .transferOrderId("transfer_order_id") + .idempotencyKey("65cc0586-3e82-4d08-b524-3885cffd52") + .version(1753117449752L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transferOrderId:** `String` — The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status. + +
+
+ +
+
+ +**idempotencyKey:** `String` + +A unique string that identifies this UpdateTransferOrder request. Keys can be +any valid string but must be unique for every UpdateTransferOrder request. + +
+
+ +
+
+ +**version:** `Optional` — Version for optimistic concurrency + +
+
+
+
+ + +
+
+
+ +
client.transferOrders.receive(transferOrderId, request) -> ReceiveTransferOrderResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Records receipt of [CatalogItemVariation](entity:CatalogItemVariation)s for a transfer order. +This endpoint supports partial receiving - you can receive items in multiple batches. + +For each line item, you can specify: +- Quantity received in good condition (added to destination inventory with [InventoryState](entity:InventoryState) of IN_STOCK) +- Quantity damaged during transit/handling (added to destination inventory with [InventoryState](entity:InventoryState) of WASTE) +- Quantity canceled (returned to source location's inventory) + +The order must be in [STARTED](entity:TransferOrderStatus) or [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. +Received quantities are added to the destination [Location](entity:Location)'s inventory according to their condition. +Canceled quantities are immediately returned to the source [Location](entity:Location)'s inventory. + +When all items are either received, damaged, or canceled, the order moves to +[COMPLETED](entity:TransferOrderStatus) status. + +Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.transferOrders().receive( + ReceiveTransferOrderRequest + .builder() + .transferOrderId("transfer_order_id") + .idempotencyKey("EXAMPLE_IDEMPOTENCY_KEY_101") + .receipt( + TransferOrderGoodsReceipt + .builder() + .lineItems( + Optional.of( + Arrays.asList( + TransferOrderGoodsReceiptLineItem + .builder() + .transferOrderLineUid("transfer_order_line_uid") + .quantityReceived("3") + .quantityDamaged("1") + .quantityCanceled("1") + .build(), + TransferOrderGoodsReceiptLineItem + .builder() + .transferOrderLineUid("transfer_order_line_uid") + .quantityReceived("2") + .quantityCanceled("1") + .build() + ) + ) + ) + .build() + ) + .version(1753118664873L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transferOrderId:** `String` — The ID of the transfer order to receive items for + +
+
+ +
+
+ +**idempotencyKey:** `String` — A unique key to make this request idempotent + +
+
+ +
+
+ +**receipt:** `TransferOrderGoodsReceipt` — The receipt details + +
+
+ +
+
+ +**version:** `Optional` — Version for optimistic concurrency + +
+
+
+
+ + +
+
+
+ +
client.transferOrders.start(transferOrderId, request) -> StartTransferOrderResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Changes a [DRAFT](entity:TransferOrderStatus) transfer order to [STARTED](entity:TransferOrderStatus) status. +This decrements inventory at the source [Location](entity:Location) and marks it as in-transit. + +The order must be in [DRAFT](entity:TransferOrderStatus) status and have all required fields populated. +Once started, the order can no longer be deleted, but it can be canceled via +[CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + +Creates a [transfer_order.updated](webhook:transfer_order.updated) webhook event. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.transferOrders().start( + StartTransferOrderRequest + .builder() + .transferOrderId("transfer_order_id") + .idempotencyKey("EXAMPLE_IDEMPOTENCY_KEY_789") + .version(1753109537351L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transferOrderId:** `String` — The ID of the transfer order to start. Must be in DRAFT status. + +
+
+ +
+
+ +**idempotencyKey:** `String` + +A unique string that identifies this UpdateTransferOrder request. Keys can be +any valid string but must be unique for every UpdateTransferOrder request. + +
+
+ +
+
+ +**version:** `Optional` — Version for optimistic concurrency + +
+
+
+
+ + +
+
+
+ +## Vendors +
client.vendors.batchCreate(request) -> BatchCreateVendorsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creates one or more [Vendor](entity:Vendor) objects to represent suppliers to a seller. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.vendors().batchCreate( + BatchCreateVendorsRequest + .builder() + .vendors( + new HashMap() {{ + put("8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", Vendor + .builder() + .name(Optional.of("Joe's Fresh Seafood")) + .address( + Optional.of( + Address + .builder() + .addressLine1(Optional.of("505 Electric Ave")) + .addressLine2(Optional.of("Suite 600")) + .locality(Optional.of("New York")) + .administrativeDistrictLevel1(Optional.of("NY")) + .postalCode(Optional.of("10003")) + .country(Optional.of(Country.US)) + .build() + ) + ) + .contacts( + Optional.of( + Arrays.asList( + VendorContact + .builder() + .ordinal(1) + .name("Joe Burrow") .emailAddress("joe@joesfreshseafood.com") .phoneNumber("1-212-555-4250") .build() @@ -15698,6 +16796,8 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` client.bookings().customAttributeDefinitions().list( ListCustomAttributeDefinitionsRequest .builder() + .limit(1) + .cursor("cursor") .build() ); ``` @@ -15872,6 +16972,7 @@ client.bookings().customAttributeDefinitions().get( GetCustomAttributeDefinitionsRequest .builder() .key("key") + .version(1) .build() ); ``` @@ -16276,6 +17377,9 @@ client.bookings().customAttributes().list( ListCustomAttributesRequest .builder() .bookingId("booking_id") + .limit(1) + .cursor("cursor") + .withDefinitions(true) .build() ); ``` @@ -16375,6 +17479,8 @@ client.bookings().customAttributes().get( .builder() .bookingId("booking_id") .key("key") + .withDefinition(true) + .version(1) .build() ); ``` @@ -16660,6 +17766,8 @@ Lists location booking profiles of a seller. client.bookings().locationProfiles().list( ListLocationProfilesRequest .builder() + .limit(1) + .cursor("cursor") .build() ); ``` @@ -16727,6 +17835,10 @@ Lists booking profiles for team members. client.bookings().teamMemberProfiles().list( ListTeamMemberProfilesRequest .builder() + .bookableOnly(true) + .limit(1) + .cursor("cursor") + .locationId("location_id") .build() ); ``` @@ -16871,6 +17983,11 @@ client.cashDrawers().shifts().list( ListShiftsRequest .builder() .locationId("location_id") + .sortOrder(SortOrder.DESC) + .beginTime("begin_time") + .endTime("end_time") + .limit(1) + .cursor("cursor") .build() ); ``` @@ -17046,6 +18163,8 @@ client.cashDrawers().shifts().listEvents( .builder() .shiftId("shift_id") .locationId("location_id") + .limit(1) + .cursor("cursor") .build() ); ``` @@ -17345,6 +18464,9 @@ client.catalog().object().get( GetObjectRequest .builder() .objectId("object_id") + .includeRelatedObjects(true) + .catalogVersion(1000000L) + .includeCategoryPathToRoot(true) .build() ); ``` @@ -17525,6 +18647,8 @@ Lists all payment links. client.checkout().paymentLinks().list( ListPaymentLinksRequest .builder() + .cursor("cursor") + .limit(1) .build() ); ``` @@ -17955,6 +19079,8 @@ seller-defined custom attributes (also known as custom fields) are always set to client.customers().customAttributeDefinitions().list( ListCustomAttributeDefinitionsRequest .builder() + .limit(1) + .cursor("cursor") .build() ); ``` @@ -18134,6 +19260,7 @@ client.customers().customAttributeDefinitions().get( GetCustomAttributeDefinitionsRequest .builder() .key("key") + .version(1) .build() ); ``` @@ -18514,6 +19641,8 @@ Retrieves the list of customer groups of a business. client.customers().groups().list( ListGroupsRequest .builder() + .cursor("cursor") + .limit(1) .build() ); ``` @@ -18998,6 +20127,8 @@ Retrieves the list of customer segments of a business. client.customers().segments().list( ListSegmentsRequest .builder() + .cursor("cursor") + .limit(1) .build() ); ``` @@ -19338,6 +20469,9 @@ client.customers().customAttributes().list( ListCustomAttributesRequest .builder() .customerId("customer_id") + .limit(1) + .cursor("cursor") + .withDefinitions(true) .build() ); ``` @@ -19441,6 +20575,8 @@ client.customers().customAttributes().get( .builder() .customerId("customer_id") .key("key") + .withDefinition(true) + .version(1) .build() ); ``` @@ -19727,6 +20863,10 @@ Lists all DeviceCodes associated with the merchant. client.devices().codes().list( ListCodesRequest .builder() + .cursor("cursor") + .locationId("location_id") + .productType("TERMINAL_API") + .status(DeviceCodeStatus.UNKNOWN) .build() ); ``` @@ -19965,6 +21105,7 @@ client.disputes().evidence().list( ListEvidenceRequest .builder() .disputeId("dispute_id") + .cursor("cursor") .build() ); ``` @@ -20178,6 +21319,14 @@ for all gift cards in a specific region, or for activities within a time window. client.giftCards().activities().list( ListActivitiesRequest .builder() + .giftCardId("gift_card_id") + .type("type") + .locationId("location_id") + .beginTime("begin_time") + .endTime("end_time") + .limit(1) + .cursor("cursor") + .sortOrder("sort_order") .build() ); ``` @@ -20408,6 +21557,9 @@ Returns a paginated list of `BreakType` instances for a business. client.labor().breakTypes().list( ListBreakTypesRequest .builder() + .locationId("location_id") + .limit(1) + .cursor("cursor") .build() ); ``` @@ -20775,6 +21927,9 @@ Returns a paginated list of `EmployeeWage` instances for a business. client.labor().employeeWages().list( ListEmployeeWagesRequest .builder() + .employeeId("employee_id") + .limit(1) + .cursor("cursor") .build() ); ``` @@ -21392,6 +22547,9 @@ Returns a paginated list of `TeamMemberWage` instances for a business. client.labor().teamMemberWages().list( ListTeamMemberWagesRequest .builder() + .teamMemberId("team_member_id") + .limit(1) + .cursor("cursor") .build() ); ``` @@ -21532,6 +22690,8 @@ Returns a list of `WorkweekConfig` instances for a business. client.labor().workweekConfigs().list( ListWorkweekConfigsRequest .builder() + .limit(1) + .cursor("cursor") .build() ); ``` @@ -21677,6 +22837,9 @@ applications and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES` client.locations().customAttributeDefinitions().list( ListCustomAttributeDefinitionsRequest .builder() + .visibilityFilter(VisibilityFilter.ALL) + .limit(1) + .cursor("cursor") .build() ); ``` @@ -21857,6 +23020,7 @@ client.locations().customAttributeDefinitions().get( GetCustomAttributeDefinitionsRequest .builder() .key("key") + .version(1) .build() ); ``` @@ -22290,6 +23454,10 @@ client.locations().customAttributes().list( ListCustomAttributesRequest .builder() .locationId("location_id") + .visibilityFilter(VisibilityFilter.ALL) + .limit(1) + .cursor("cursor") + .withDefinitions(true) .build() ); ``` @@ -22398,6 +23566,8 @@ client.locations().customAttributes().get( .builder() .locationId("location_id") .key("key") + .withDefinition(true) + .version(1) .build() ); ``` @@ -22683,6 +23853,10 @@ client.locations().transactions().list( ListTransactionsRequest .builder() .locationId("location_id") + .beginTime("begin_time") + .endTime("end_time") + .sortOrder(SortOrder.DESC) + .cursor("cursor") .build() ); ``` @@ -24090,6 +25264,9 @@ client.loyalty().programs().promotions().list( ListPromotionsRequest .builder() .programId("program_id") + .status(LoyaltyPromotionStatus.ACTIVE) + .cursor("cursor") + .limit(1) .build() ); ``` @@ -24290,7 +25467,7 @@ see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-pa
-
client.loyalty.programs.promotions.get(promotionId, programId) -> GetLoyaltyPromotionResponse +
client.loyalty.programs.promotions.get(programId, promotionId) -> GetLoyaltyPromotionResponse
@@ -24320,8 +25497,8 @@ Retrieves a loyalty promotion. client.loyalty().programs().promotions().get( GetPromotionsRequest .builder() - .promotionId("promotion_id") .programId("program_id") + .promotionId("promotion_id") .build() ); ``` @@ -24338,7 +25515,10 @@ client.loyalty().programs().promotions().get(
-**promotionId:** `String` — The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve. +**programId:** `String` + +The ID of the base [loyalty program](entity:LoyaltyProgram). To get the program ID, +call [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) using the `main` keyword.
@@ -24346,10 +25526,7 @@ client.loyalty().programs().promotions().get(
-**programId:** `String` - -The ID of the base [loyalty program](entity:LoyaltyProgram). To get the program ID, -call [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) using the `main` keyword. +**promotionId:** `String` — The ID of the [loyalty promotion](entity:LoyaltyPromotion) to retrieve.
@@ -24361,7 +25538,7 @@ call [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) using
-
client.loyalty.programs.promotions.cancel(promotionId, programId) -> CancelLoyaltyPromotionResponse +
client.loyalty.programs.promotions.cancel(programId, promotionId) -> CancelLoyaltyPromotionResponse
@@ -24396,8 +25573,8 @@ This endpoint sets the loyalty promotion to the `CANCELED` state client.loyalty().programs().promotions().cancel( CancelPromotionsRequest .builder() - .promotionId("promotion_id") .programId("program_id") + .promotionId("promotion_id") .build() ); ``` @@ -24414,10 +25591,7 @@ client.loyalty().programs().promotions().cancel(
-**promotionId:** `String` - -The ID of the [loyalty promotion](entity:LoyaltyPromotion) to cancel. You can cancel a -promotion that has an `ACTIVE` or `SCHEDULED` status. +**programId:** `String` — The ID of the base [loyalty program](entity:LoyaltyProgram).
@@ -24425,7 +25599,10 @@ promotion that has an `ACTIVE` or `SCHEDULED` status.
-**programId:** `String` — The ID of the base [loyalty program](entity:LoyaltyProgram). +**promotionId:** `String` + +The ID of the [loyalty promotion](entity:LoyaltyPromotion) to cancel. You can cancel a +promotion that has an `ACTIVE` or `SCHEDULED` status.
@@ -24471,6 +25648,9 @@ applications and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES` client.merchants().customAttributeDefinitions().list( ListCustomAttributeDefinitionsRequest .builder() + .visibilityFilter(VisibilityFilter.ALL) + .limit(1) + .cursor("cursor") .build() ); ``` @@ -24651,6 +25831,7 @@ client.merchants().customAttributeDefinitions().get( GetCustomAttributeDefinitionsRequest .builder() .key("key") + .version(1) .build() ); ``` @@ -25068,6 +26249,10 @@ client.merchants().customAttributes().list( ListCustomAttributesRequest .builder() .merchantId("merchant_id") + .visibilityFilter(VisibilityFilter.ALL) + .limit(1) + .cursor("cursor") + .withDefinitions(true) .build() ); ``` @@ -25176,6 +26361,8 @@ client.merchants().customAttributes().get( .builder() .merchantId("merchant_id") .key("key") + .withDefinition(true) + .version(1) .build() ); ``` @@ -25460,6 +26647,9 @@ seller-defined custom attributes (also known as custom fields) are always set to client.orders().customAttributeDefinitions().list( ListCustomAttributeDefinitionsRequest .builder() + .visibilityFilter(VisibilityFilter.ALL) + .cursor("cursor") + .limit(1) .build() ); ``` @@ -25643,6 +26833,7 @@ client.orders().customAttributeDefinitions().get( GetCustomAttributeDefinitionsRequest .builder() .key("key") + .version(1) .build() ); ``` @@ -26061,6 +27252,10 @@ client.orders().customAttributes().list( ListCustomAttributesRequest .builder() .orderId("order_id") + .visibilityFilter(VisibilityFilter.ALL) + .cursor("cursor") + .limit(1) + .withDefinitions(true) .build() ); ``` @@ -26173,6 +27368,8 @@ client.orders().customAttributes().get( .builder() .orderId("order_id") .customAttributeKey("custom_attribute_key") + .version(1) + .withDefinition(true) .build() ); ``` @@ -27553,6 +28750,7 @@ Lists all webhook event types that can be subscribed to. client.webhooks().eventTypes().list( ListEventTypesRequest .builder() + .apiVersion("api_version") .build() ); ``` @@ -27612,6 +28810,10 @@ Lists all webhook subscriptions owned by your application. client.webhooks().subscriptions().list( ListSubscriptionsRequest .builder() + .cursor("cursor") + .includeDisabled(true) + .sortOrder(SortOrder.DESC) + .limit(1) .build() ); ``` diff --git a/src/main/java/com/squareup/square/AsyncCatalogClient.java b/src/main/java/com/squareup/square/AsyncCatalogClient.java index 5e174f3b..f5001c87 100644 --- a/src/main/java/com/squareup/square/AsyncCatalogClient.java +++ b/src/main/java/com/squareup/square/AsyncCatalogClient.java @@ -19,9 +19,7 @@ import com.squareup.square.types.CatalogObject; import com.squareup.square.types.ListCatalogRequest; import com.squareup.square.types.SearchCatalogItemsRequest; -import com.squareup.square.types.SearchCatalogItemsResponse; import com.squareup.square.types.SearchCatalogObjectsRequest; -import com.squareup.square.types.SearchCatalogObjectsResponse; import com.squareup.square.types.UpdateItemModifierListsRequest; import com.squareup.square.types.UpdateItemModifierListsResponse; import com.squareup.square.types.UpdateItemTaxesRequest; @@ -216,7 +214,7 @@ public CompletableFuture> list( *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } @@ -232,7 +230,7 @@ public CompletableFuture search() { *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public CompletableFuture search(SearchCatalogObjectsRequest request) { + public CompletableFuture> search(SearchCatalogObjectsRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -248,7 +246,7 @@ public CompletableFuture search(SearchCatalogObjec *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public CompletableFuture search( + public CompletableFuture> search( SearchCatalogObjectsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } @@ -265,7 +263,7 @@ public CompletableFuture search( *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public CompletableFuture searchItems() { + public CompletableFuture> searchItems() { return this.rawClient.searchItems().thenApply(response -> response.body()); } @@ -281,7 +279,7 @@ public CompletableFuture searchItems() { *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public CompletableFuture searchItems(SearchCatalogItemsRequest request) { + public CompletableFuture> searchItems(SearchCatalogItemsRequest request) { return this.rawClient.searchItems(request).thenApply(response -> response.body()); } @@ -297,7 +295,7 @@ public CompletableFuture searchItems(SearchCatalogIt *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public CompletableFuture searchItems( + public CompletableFuture> searchItems( SearchCatalogItemsRequest request, RequestOptions requestOptions) { return this.rawClient.searchItems(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/AsyncChannelsClient.java b/src/main/java/com/squareup/square/AsyncChannelsClient.java new file mode 100644 index 00000000..5d1c9280 --- /dev/null +++ b/src/main/java/com/squareup/square/AsyncChannelsClient.java @@ -0,0 +1,63 @@ +/** + * 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.core.SyncPagingIterable; +import com.squareup.square.types.BulkRetrieveChannelsRequest; +import com.squareup.square.types.BulkRetrieveChannelsResponse; +import com.squareup.square.types.Channel; +import com.squareup.square.types.GetChannelsRequest; +import com.squareup.square.types.ListChannelsRequest; +import com.squareup.square.types.RetrieveChannelResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncChannelsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawChannelsClient rawClient; + + public AsyncChannelsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawChannelsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawChannelsClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture> list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + public CompletableFuture> list(ListChannelsRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + public CompletableFuture> list( + ListChannelsRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture bulkRetrieve(BulkRetrieveChannelsRequest request) { + return this.rawClient.bulkRetrieve(request).thenApply(response -> response.body()); + } + + public CompletableFuture bulkRetrieve( + BulkRetrieveChannelsRequest request, RequestOptions requestOptions) { + return this.rawClient.bulkRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture get(GetChannelsRequest request) { + return this.rawClient.get(request).thenApply(response -> response.body()); + } + + public CompletableFuture get(GetChannelsRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/squareup/square/AsyncCustomersClient.java b/src/main/java/com/squareup/square/AsyncCustomersClient.java index 60953130..221312b3 100644 --- a/src/main/java/com/squareup/square/AsyncCustomersClient.java +++ b/src/main/java/com/squareup/square/AsyncCustomersClient.java @@ -29,7 +29,6 @@ import com.squareup.square.types.GetCustomersRequest; import com.squareup.square.types.ListCustomersRequest; import com.squareup.square.types.SearchCustomersRequest; -import com.squareup.square.types.SearchCustomersResponse; import com.squareup.square.types.UpdateCustomerRequest; import com.squareup.square.types.UpdateCustomerResponse; import java.util.concurrent.CompletableFuture; @@ -242,7 +241,7 @@ public CompletableFuture bulkUpdateCustomers( * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } @@ -255,7 +254,7 @@ public CompletableFuture search() { * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public CompletableFuture search(SearchCustomersRequest request) { + public CompletableFuture> search(SearchCustomersRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -268,7 +267,7 @@ public CompletableFuture search(SearchCustomersRequest * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public CompletableFuture search( + public CompletableFuture> search( SearchCustomersRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/AsyncInventoryClient.java b/src/main/java/com/squareup/square/AsyncInventoryClient.java index 59ec2fad..5c72924e 100644 --- a/src/main/java/com/squareup/square/AsyncInventoryClient.java +++ b/src/main/java/com/squareup/square/AsyncInventoryClient.java @@ -8,9 +8,7 @@ import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchChangeInventoryRequest; import com.squareup.square.types.BatchChangeInventoryResponse; -import com.squareup.square.types.BatchGetInventoryChangesResponse; import com.squareup.square.types.BatchGetInventoryCountsRequest; -import com.squareup.square.types.BatchGetInventoryCountsResponse; import com.squareup.square.types.BatchRetrieveInventoryChangesRequest; import com.squareup.square.types.ChangesInventoryRequest; import com.squareup.square.types.DeprecatedGetAdjustmentInventoryRequest; @@ -99,7 +97,7 @@ public CompletableFuture deprecatedBatchChange( * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture deprecatedBatchGetChanges() { + public CompletableFuture> deprecatedBatchGetChanges() { return this.rawClient.deprecatedBatchGetChanges().thenApply(response -> response.body()); } @@ -107,7 +105,7 @@ public CompletableFuture deprecatedBatchGetCha * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture deprecatedBatchGetChanges( + public CompletableFuture> deprecatedBatchGetChanges( BatchRetrieveInventoryChangesRequest request) { return this.rawClient.deprecatedBatchGetChanges(request).thenApply(response -> response.body()); } @@ -116,7 +114,7 @@ public CompletableFuture deprecatedBatchGetCha * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture deprecatedBatchGetChanges( + public CompletableFuture> deprecatedBatchGetChanges( BatchRetrieveInventoryChangesRequest request, RequestOptions requestOptions) { return this.rawClient.deprecatedBatchGetChanges(request, requestOptions).thenApply(response -> response.body()); } @@ -125,7 +123,7 @@ public CompletableFuture deprecatedBatchGetCha * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture deprecatedBatchGetCounts() { + public CompletableFuture> deprecatedBatchGetCounts() { return this.rawClient.deprecatedBatchGetCounts().thenApply(response -> response.body()); } @@ -133,7 +131,7 @@ public CompletableFuture deprecatedBatchGetCoun * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture deprecatedBatchGetCounts( + public CompletableFuture> deprecatedBatchGetCounts( BatchGetInventoryCountsRequest request) { return this.rawClient.deprecatedBatchGetCounts(request).thenApply(response -> response.body()); } @@ -142,7 +140,7 @@ public CompletableFuture deprecatedBatchGetCoun * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture deprecatedBatchGetCounts( + public CompletableFuture> deprecatedBatchGetCounts( BatchGetInventoryCountsRequest request, RequestOptions requestOptions) { return this.rawClient.deprecatedBatchGetCounts(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/AsyncInvoicesClient.java b/src/main/java/com/squareup/square/AsyncInvoicesClient.java index 23eaef9c..08257982 100644 --- a/src/main/java/com/squareup/square/AsyncInvoicesClient.java +++ b/src/main/java/com/squareup/square/AsyncInvoicesClient.java @@ -23,7 +23,6 @@ import com.squareup.square.types.PublishInvoiceRequest; import com.squareup.square.types.PublishInvoiceResponse; import com.squareup.square.types.SearchInvoicesRequest; -import com.squareup.square.types.SearchInvoicesResponse; import com.squareup.square.types.UpdateInvoiceRequest; import com.squareup.square.types.UpdateInvoiceResponse; import java.util.concurrent.CompletableFuture; @@ -93,7 +92,7 @@ public CompletableFuture create( *

    The response is paginated. If truncated, the response includes a cursor * that you use in a subsequent request to retrieve the next set of invoices.

    */ - public CompletableFuture search(SearchInvoicesRequest request) { + public CompletableFuture> search(SearchInvoicesRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -105,7 +104,7 @@ public CompletableFuture search(SearchInvoicesRequest re *

    The response is paginated. If truncated, the response includes a cursor * that you use in a subsequent request to retrieve the next set of invoices.

    */ - public CompletableFuture search( + public CompletableFuture> search( SearchInvoicesRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/AsyncLoyaltyClient.java b/src/main/java/com/squareup/square/AsyncLoyaltyClient.java index 574c6516..5c1d8626 100644 --- a/src/main/java/com/squareup/square/AsyncLoyaltyClient.java +++ b/src/main/java/com/squareup/square/AsyncLoyaltyClient.java @@ -6,11 +6,12 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; import com.squareup.square.core.Suppliers; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.AsyncAccountsClient; import com.squareup.square.loyalty.AsyncProgramsClient; import com.squareup.square.loyalty.AsyncRewardsClient; +import com.squareup.square.types.LoyaltyEvent; import com.squareup.square.types.SearchLoyaltyEventsRequest; -import com.squareup.square.types.SearchLoyaltyEventsResponse; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; @@ -48,7 +49,7 @@ public AsyncRawLoyaltyClient withRawResponse() { * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public CompletableFuture searchEvents() { + public CompletableFuture> searchEvents() { return this.rawClient.searchEvents().thenApply(response -> response.body()); } @@ -60,7 +61,7 @@ public CompletableFuture searchEvents() { * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public CompletableFuture searchEvents(SearchLoyaltyEventsRequest request) { + public CompletableFuture> searchEvents(SearchLoyaltyEventsRequest request) { return this.rawClient.searchEvents(request).thenApply(response -> response.body()); } @@ -72,7 +73,7 @@ public CompletableFuture searchEvents(SearchLoyalty * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public CompletableFuture searchEvents( + public CompletableFuture> searchEvents( SearchLoyaltyEventsRequest request, RequestOptions requestOptions) { return this.rawClient.searchEvents(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/AsyncOrdersClient.java b/src/main/java/com/squareup/square/AsyncOrdersClient.java index c614e34f..3dbefb34 100644 --- a/src/main/java/com/squareup/square/AsyncOrdersClient.java +++ b/src/main/java/com/squareup/square/AsyncOrdersClient.java @@ -6,6 +6,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; import com.squareup.square.core.Suppliers; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.orders.AsyncCustomAttributeDefinitionsClient; import com.squareup.square.orders.AsyncCustomAttributesClient; import com.squareup.square.types.BatchGetOrdersRequest; @@ -18,10 +19,10 @@ import com.squareup.square.types.CreateOrderResponse; import com.squareup.square.types.GetOrderResponse; import com.squareup.square.types.GetOrdersRequest; +import com.squareup.square.types.Order; import com.squareup.square.types.PayOrderRequest; import com.squareup.square.types.PayOrderResponse; import com.squareup.square.types.SearchOrdersRequest; -import com.squareup.square.types.SearchOrdersResponse; import com.squareup.square.types.UpdateOrderRequest; import com.squareup.square.types.UpdateOrderResponse; import java.util.concurrent.CompletableFuture; @@ -148,7 +149,7 @@ public CompletableFuture clone(CloneOrderRequest request, Re * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } @@ -168,7 +169,7 @@ public CompletableFuture search() { * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public CompletableFuture search(SearchOrdersRequest request) { + public CompletableFuture> search(SearchOrdersRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -188,7 +189,8 @@ public CompletableFuture search(SearchOrdersRequest reques * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public CompletableFuture search(SearchOrdersRequest request, RequestOptions requestOptions) { + public CompletableFuture> search( + SearchOrdersRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/AsyncRawCatalogClient.java b/src/main/java/com/squareup/square/AsyncRawCatalogClient.java index abf57df2..9f22bf42 100644 --- a/src/main/java/com/squareup/square/AsyncRawCatalogClient.java +++ b/src/main/java/com/squareup/square/AsyncRawCatalogClient.java @@ -490,7 +490,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchCatalogObjectsRequest.builder().build()); } @@ -506,7 +506,7 @@ public CompletableFuture> *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchCatalogObjectsRequest request) { return search(request, null); } @@ -523,7 +523,7 @@ public CompletableFuture> *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchCatalogObjectsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -547,15 +547,31 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchCatalogObjectsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchCatalogObjectsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchCatalogObjectsRequest nextRequest = SearchCatalogObjectsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getObjects().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchCatalogObjectsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } @@ -591,7 +607,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public CompletableFuture> searchItems() { + public CompletableFuture>> searchItems() { return searchItems(SearchCatalogItemsRequest.builder().build()); } @@ -607,7 +623,7 @@ public CompletableFuture> s *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public CompletableFuture> searchItems( + public CompletableFuture>> searchItems( SearchCatalogItemsRequest request) { return searchItems(request, null); } @@ -624,7 +640,7 @@ public CompletableFuture> s *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public CompletableFuture> searchItems( + public CompletableFuture>> searchItems( SearchCatalogItemsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -648,15 +664,31 @@ public CompletableFuture> s if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchCatalogItemsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchCatalogItemsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchCatalogItemsRequest nextRequest = SearchCatalogItemsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getItems().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchCatalogItemsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return searchItems(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/AsyncRawChannelsClient.java b/src/main/java/com/squareup/square/AsyncRawChannelsClient.java new file mode 100644 index 00000000..4f9f25b7 --- /dev/null +++ b/src/main/java/com/squareup/square/AsyncRawChannelsClient.java @@ -0,0 +1,250 @@ +/** + * 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.QueryStringMapper; +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.core.SyncPagingIterable; +import com.squareup.square.types.BulkRetrieveChannelsRequest; +import com.squareup.square.types.BulkRetrieveChannelsResponse; +import com.squareup.square.types.Channel; +import com.squareup.square.types.GetChannelsRequest; +import com.squareup.square.types.ListChannelsRequest; +import com.squareup.square.types.ListChannelsResponse; +import com.squareup.square.types.RetrieveChannelResponse; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +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 AsyncRawChannelsClient { + protected final ClientOptions clientOptions; + + public AsyncRawChannelsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture>> list() { + return list(ListChannelsRequest.builder().build()); + } + + public CompletableFuture>> list(ListChannelsRequest request) { + return list(request, null); + } + + public CompletableFuture>> list( + ListChannelsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/channels"); + if (request.getReferenceType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "reference_type", request.getReferenceType().get(), false); + } + if (request.getReferenceId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "reference_id", request.getReferenceId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.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()) { + if (response.isSuccessful()) { + ListChannelsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListChannelsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + ListChannelsRequest nextRequest = ListChannelsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getChannels().orElse(Collections.emptyList()); + future.complete(new SquareClientHttpResponse<>( + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return list(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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; + } + + public CompletableFuture> bulkRetrieve( + BulkRetrieveChannelsRequest request) { + return bulkRetrieve(request, null); + } + + public CompletableFuture> bulkRetrieve( + BulkRetrieveChannelsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/channels/bulk-retrieve") + .build(); + 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) + .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()) { + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), BulkRetrieveChannelsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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; + } + + public CompletableFuture> get(GetChannelsRequest request) { + return get(request, null); + } + + public CompletableFuture> get( + GetChannelsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/channels") + .addPathSegment(request.getChannelId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.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()) { + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), RetrieveChannelResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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/AsyncRawCustomersClient.java b/src/main/java/com/squareup/square/AsyncRawCustomersClient.java index f13859f1..b1183e95 100644 --- a/src/main/java/com/squareup/square/AsyncRawCustomersClient.java +++ b/src/main/java/com/squareup/square/AsyncRawCustomersClient.java @@ -568,7 +568,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchCustomersRequest.builder().build()); } @@ -581,7 +581,8 @@ public CompletableFuture> sear * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public CompletableFuture> search(SearchCustomersRequest request) { + public CompletableFuture>> search( + SearchCustomersRequest request) { return search(request, null); } @@ -594,7 +595,7 @@ public CompletableFuture> sear * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchCustomersRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -618,15 +619,30 @@ public CompletableFuture> sear if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchCustomersResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchCustomersResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchCustomersRequest nextRequest = SearchCustomersRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getCustomers().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchCustomersResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/AsyncRawInventoryClient.java b/src/main/java/com/squareup/square/AsyncRawInventoryClient.java index 44379820..3add22c4 100644 --- a/src/main/java/com/squareup/square/AsyncRawInventoryClient.java +++ b/src/main/java/com/squareup/square/AsyncRawInventoryClient.java @@ -254,7 +254,8 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture> deprecatedBatchGetChanges() { + public CompletableFuture>> + deprecatedBatchGetChanges() { return deprecatedBatchGetChanges( BatchRetrieveInventoryChangesRequest.builder().build()); } @@ -263,7 +264,7 @@ public CompletableFutureBatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture> deprecatedBatchGetChanges( + public CompletableFuture>> deprecatedBatchGetChanges( BatchRetrieveInventoryChangesRequest request) { return deprecatedBatchGetChanges(request, null); } @@ -272,7 +273,7 @@ public CompletableFutureBatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture> deprecatedBatchGetChanges( + public CompletableFuture>> deprecatedBatchGetChanges( BatchRetrieveInventoryChangesRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -296,16 +297,33 @@ public CompletableFuture> future = + 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()) { if (response.isSuccessful()) { + BatchGetInventoryChangesResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), BatchGetInventoryChangesResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + BatchRetrieveInventoryChangesRequest nextRequest = + BatchRetrieveInventoryChangesRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = + parsedResponse.getChanges().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), BatchGetInventoryChangesResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return deprecatedBatchGetChanges(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } @@ -333,7 +351,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture> deprecatedBatchGetCounts() { + public CompletableFuture>> deprecatedBatchGetCounts() { return deprecatedBatchGetCounts(BatchGetInventoryCountsRequest.builder().build()); } @@ -341,7 +359,7 @@ public CompletableFutureBatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture> deprecatedBatchGetCounts( + public CompletableFuture>> deprecatedBatchGetCounts( BatchGetInventoryCountsRequest request) { return deprecatedBatchGetCounts(request, null); } @@ -350,7 +368,7 @@ public CompletableFutureBatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public CompletableFuture> deprecatedBatchGetCounts( + public CompletableFuture>> deprecatedBatchGetCounts( BatchGetInventoryCountsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -374,15 +392,31 @@ public CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + BatchGetInventoryCountsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), BatchGetInventoryCountsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + BatchGetInventoryCountsRequest nextRequest = BatchGetInventoryCountsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getCounts().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), BatchGetInventoryCountsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return deprecatedBatchGetCounts(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/AsyncRawInvoicesClient.java b/src/main/java/com/squareup/square/AsyncRawInvoicesClient.java index 68b3c5ad..c8f983df 100644 --- a/src/main/java/com/squareup/square/AsyncRawInvoicesClient.java +++ b/src/main/java/com/squareup/square/AsyncRawInvoicesClient.java @@ -225,7 +225,8 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *

    The response is paginated. If truncated, the response includes a cursor * that you use in a subsequent request to retrieve the next set of invoices.

    */ - public CompletableFuture> search(SearchInvoicesRequest request) { + public CompletableFuture>> search( + SearchInvoicesRequest request) { return search(request, null); } @@ -237,7 +238,7 @@ public CompletableFuture> searc *

    The response is paginated. If truncated, the response includes a cursor * that you use in a subsequent request to retrieve the next set of invoices.

    */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchInvoicesRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -261,15 +262,30 @@ public CompletableFuture> searc if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchInvoicesResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchInvoicesResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchInvoicesRequest nextRequest = SearchInvoicesRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getInvoices().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchInvoicesResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/AsyncRawLoyaltyClient.java b/src/main/java/com/squareup/square/AsyncRawLoyaltyClient.java index 2540f6f8..3a3db7ed 100644 --- a/src/main/java/com/squareup/square/AsyncRawLoyaltyClient.java +++ b/src/main/java/com/squareup/square/AsyncRawLoyaltyClient.java @@ -11,10 +11,16 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; +import com.squareup.square.types.LoyaltyEvent; import com.squareup.square.types.SearchLoyaltyEventsRequest; import com.squareup.square.types.SearchLoyaltyEventsResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -41,7 +47,7 @@ public AsyncRawLoyaltyClient(ClientOptions clientOptions) { * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public CompletableFuture> searchEvents() { + public CompletableFuture>> searchEvents() { return searchEvents(SearchLoyaltyEventsRequest.builder().build()); } @@ -53,7 +59,7 @@ public CompletableFuture> * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public CompletableFuture> searchEvents( + public CompletableFuture>> searchEvents( SearchLoyaltyEventsRequest request) { return searchEvents(request, null); } @@ -66,7 +72,7 @@ public CompletableFuture> * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public CompletableFuture> searchEvents( + public CompletableFuture>> searchEvents( SearchLoyaltyEventsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -90,15 +96,31 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchLoyaltyEventsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchLoyaltyEventsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchLoyaltyEventsRequest nextRequest = SearchLoyaltyEventsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getEvents().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchLoyaltyEventsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return searchEvents(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/AsyncRawOrdersClient.java b/src/main/java/com/squareup/square/AsyncRawOrdersClient.java index e0c695c7..238ff6c9 100644 --- a/src/main/java/com/squareup/square/AsyncRawOrdersClient.java +++ b/src/main/java/com/squareup/square/AsyncRawOrdersClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchGetOrdersRequest; import com.squareup.square.types.BatchGetOrdersResponse; import com.squareup.square.types.CalculateOrderRequest; @@ -21,6 +22,7 @@ import com.squareup.square.types.CreateOrderResponse; import com.squareup.square.types.GetOrderResponse; import com.squareup.square.types.GetOrdersRequest; +import com.squareup.square.types.Order; import com.squareup.square.types.PayOrderRequest; import com.squareup.square.types.PayOrderResponse; import com.squareup.square.types.SearchOrdersRequest; @@ -28,7 +30,11 @@ import com.squareup.square.types.UpdateOrderRequest; import com.squareup.square.types.UpdateOrderResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -349,7 +355,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchOrdersRequest.builder().build()); } @@ -369,7 +375,7 @@ public CompletableFuture> search( * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public CompletableFuture> search(SearchOrdersRequest request) { + public CompletableFuture>> search(SearchOrdersRequest request) { return search(request, null); } @@ -389,7 +395,7 @@ public CompletableFuture> search( * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchOrdersRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -413,14 +419,30 @@ public CompletableFuture> search( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchOrdersResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchOrdersResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchOrdersRequest nextRequest = SearchOrdersRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getOrders().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchOrdersResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/AsyncRawSubscriptionsClient.java b/src/main/java/com/squareup/square/AsyncRawSubscriptionsClient.java index c2367a94..3cbbf503 100644 --- a/src/main/java/com/squareup/square/AsyncRawSubscriptionsClient.java +++ b/src/main/java/com/squareup/square/AsyncRawSubscriptionsClient.java @@ -33,6 +33,7 @@ import com.squareup.square.types.ResumeSubscriptionResponse; import com.squareup.square.types.SearchSubscriptionsRequest; import com.squareup.square.types.SearchSubscriptionsResponse; +import com.squareup.square.types.Subscription; import com.squareup.square.types.SubscriptionEvent; import com.squareup.square.types.SwapPlanRequest; import com.squareup.square.types.SwapPlanResponse; @@ -220,7 +221,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchSubscriptionsRequest.builder().build()); } @@ -238,7 +239,7 @@ public CompletableFuture> * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchSubscriptionsRequest request) { return search(request, null); } @@ -257,7 +258,7 @@ public CompletableFuture> * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchSubscriptionsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -281,15 +282,32 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchSubscriptionsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchSubscriptionsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchSubscriptionsRequest nextRequest = SearchSubscriptionsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = + parsedResponse.getSubscriptions().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchSubscriptionsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/AsyncRawTeamMembersClient.java b/src/main/java/com/squareup/square/AsyncRawTeamMembersClient.java index 0f8ae545..a08ab508 100644 --- a/src/main/java/com/squareup/square/AsyncRawTeamMembersClient.java +++ b/src/main/java/com/squareup/square/AsyncRawTeamMembersClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchCreateTeamMembersRequest; import com.squareup.square.types.BatchCreateTeamMembersResponse; import com.squareup.square.types.BatchUpdateTeamMembersRequest; @@ -21,10 +22,15 @@ import com.squareup.square.types.GetTeamMembersRequest; import com.squareup.square.types.SearchTeamMembersRequest; import com.squareup.square.types.SearchTeamMembersResponse; +import com.squareup.square.types.TeamMember; import com.squareup.square.types.UpdateTeamMemberResponse; import com.squareup.square.types.UpdateTeamMembersRequest; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -290,7 +296,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchTeamMembersRequest.builder().build()); } @@ -299,7 +305,7 @@ public CompletableFuture> se * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchTeamMembersRequest request) { return search(request, null); } @@ -309,7 +315,7 @@ public CompletableFuture> se * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchTeamMembersRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -333,15 +339,31 @@ public CompletableFuture> se if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchTeamMembersResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchTeamMembersResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTeamMembersRequest nextRequest = SearchTeamMembersRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = + parsedResponse.getTeamMembers().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchTeamMembersResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/AsyncRawTransferOrdersClient.java b/src/main/java/com/squareup/square/AsyncRawTransferOrdersClient.java new file mode 100644 index 00000000..6fca85bd --- /dev/null +++ b/src/main/java/com/squareup/square/AsyncRawTransferOrdersClient.java @@ -0,0 +1,749 @@ +/** + * 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.QueryStringMapper; +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.core.SyncPagingIterable; +import com.squareup.square.types.CancelTransferOrderRequest; +import com.squareup.square.types.CancelTransferOrderResponse; +import com.squareup.square.types.CreateTransferOrderRequest; +import com.squareup.square.types.CreateTransferOrderResponse; +import com.squareup.square.types.DeleteTransferOrderResponse; +import com.squareup.square.types.DeleteTransferOrdersRequest; +import com.squareup.square.types.GetTransferOrdersRequest; +import com.squareup.square.types.ReceiveTransferOrderRequest; +import com.squareup.square.types.ReceiveTransferOrderResponse; +import com.squareup.square.types.RetrieveTransferOrderResponse; +import com.squareup.square.types.SearchTransferOrdersRequest; +import com.squareup.square.types.SearchTransferOrdersResponse; +import com.squareup.square.types.StartTransferOrderRequest; +import com.squareup.square.types.StartTransferOrderResponse; +import com.squareup.square.types.TransferOrder; +import com.squareup.square.types.UpdateTransferOrderRequest; +import com.squareup.square.types.UpdateTransferOrderResponse; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +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 AsyncRawTransferOrdersClient { + protected final ClientOptions clientOptions; + + public AsyncRawTransferOrdersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a new transfer order in DRAFT status. A transfer order represents the intent + * to move CatalogItemVariations from one Location to another. + * The source and destination locations must be different and must belong to your Square account. + *

    In DRAFT status, you can:

    + *
      + *
    • Add or remove items
    • + *
    • Modify quantities
    • + *
    • Update shipping information
    • + *
    • Delete the entire order via DeleteTransferOrder
    • + *
    + *

    The request requires source_location_id and destination_location_id. + * Inventory levels are not affected until the order is started via + * StartTransferOrder.

    + *

    Common integration points:

    + *
      + *
    • Sync with warehouse management systems
    • + *
    • Automate regular stock transfers
    • + *
    • Initialize transfers from inventory optimization systems
    • + *
    + *

    Creates a transfer_order.created webhook event.

    + */ + public CompletableFuture> create( + CreateTransferOrderRequest request) { + return create(request, null); + } + + /** + * Creates a new transfer order in DRAFT status. A transfer order represents the intent + * to move CatalogItemVariations from one Location to another. + * The source and destination locations must be different and must belong to your Square account. + *

    In DRAFT status, you can:

    + *
      + *
    • Add or remove items
    • + *
    • Modify quantities
    • + *
    • Update shipping information
    • + *
    • Delete the entire order via DeleteTransferOrder
    • + *
    + *

    The request requires source_location_id and destination_location_id. + * Inventory levels are not affected until the order is started via + * StartTransferOrder.

    + *

    Common integration points:

    + *
      + *
    • Sync with warehouse management systems
    • + *
    • Automate regular stock transfers
    • + *
    • Initialize transfers from inventory optimization systems
    • + *
    + *

    Creates a transfer_order.created webhook event.

    + */ + public CompletableFuture> create( + CreateTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .build(); + 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) + .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()) { + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateTransferOrderResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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; + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public CompletableFuture>> search() { + return search(SearchTransferOrdersRequest.builder().build()); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public CompletableFuture>> search( + SearchTransferOrdersRequest request) { + return search(request, null); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public CompletableFuture>> search( + SearchTransferOrdersRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders/search") + .build(); + 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) + .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()) { + if (response.isSuccessful()) { + SearchTransferOrdersResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchTransferOrdersResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTransferOrdersRequest nextRequest = SearchTransferOrdersRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = + parsedResponse.getTransferOrders().orElse(Collections.emptyList()); + future.complete(new SquareClientHttpResponse<>( + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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; + } + + /** + * Retrieves a specific TransferOrder by ID. Returns the complete + * order details including: + *
      + *
    • Basic information (status, dates, notes)
    • + *
    • Line items with ordered and received quantities
    • + *
    • Source and destination Locations
    • + *
    • Tracking information (if available)
    • + *
    + */ + public CompletableFuture> get( + GetTransferOrdersRequest request) { + return get(request, null); + } + + /** + * Retrieves a specific TransferOrder by ID. Returns the complete + * order details including: + *
      + *
    • Basic information (status, dates, notes)
    • + *
    • Line items with ordered and received quantities
    • + *
    • Source and destination Locations
    • + *
    • Tracking information (if available)
    • + *
    + */ + public CompletableFuture> get( + GetTransferOrdersRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.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()) { + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), RetrieveTransferOrderResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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; + } + + /** + * Updates an existing transfer order. This endpoint supports sparse updates, + * allowing you to modify specific fields without affecting others. + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture> update( + UpdateTransferOrderRequest request) { + return update(request, null); + } + + /** + * Updates an existing transfer order. This endpoint supports sparse updates, + * allowing you to modify specific fields without affecting others. + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture> update( + UpdateTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .build(); + 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) + .method("PUT", 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()) { + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateTransferOrderResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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; + } + + /** + * Deletes a transfer order in DRAFT status. + * Only draft orders can be deleted. Once an order is started via + * StartTransferOrder, it can no longer be deleted. + *

    Creates a transfer_order.deleted webhook event.

    + */ + public CompletableFuture> delete( + DeleteTransferOrdersRequest request) { + return delete(request, null); + } + + /** + * Deletes a transfer order in DRAFT status. + * Only draft orders can be deleted. Once an order is started via + * StartTransferOrder, it can no longer be deleted. + *

    Creates a transfer_order.deleted webhook event.

    + */ + public CompletableFuture> delete( + DeleteTransferOrdersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()); + if (request.getVersion().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "version", request.getVersion().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.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()) { + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteTransferOrderResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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; + } + + /** + * Cancels a transfer order in STARTED or + * PARTIALLY_RECEIVED status. Any unreceived quantities will no + * longer be receivable and will be immediately returned to the source Location's inventory. + *

    Common reasons for cancellation:

    + *
      + *
    • Items no longer needed at destination
    • + *
    • Source location needs the inventory
    • + *
    • Order created in error
    • + *
    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture> cancel( + CancelTransferOrderRequest request) { + return cancel(request, null); + } + + /** + * Cancels a transfer order in STARTED or + * PARTIALLY_RECEIVED status. Any unreceived quantities will no + * longer be receivable and will be immediately returned to the source Location's inventory. + *

    Common reasons for cancellation:

    + *
      + *
    • Items no longer needed at destination
    • + *
    • Source location needs the inventory
    • + *
    • Order created in error
    • + *
    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture> cancel( + CancelTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .addPathSegments("cancel") + .build(); + 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) + .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()) { + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CancelTransferOrderResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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; + } + + /** + * Records receipt of CatalogItemVariations for a transfer order. + * This endpoint supports partial receiving - you can receive items in multiple batches. + *

    For each line item, you can specify:

    + *
      + *
    • Quantity received in good condition (added to destination inventory with InventoryState of IN_STOCK)
    • + *
    • Quantity damaged during transit/handling (added to destination inventory with InventoryState of WASTE)
    • + *
    • Quantity canceled (returned to source location's inventory)
    • + *
    + *

    The order must be in STARTED or PARTIALLY_RECEIVED status. + * Received quantities are added to the destination Location's inventory according to their condition. + * Canceled quantities are immediately returned to the source Location's inventory.

    + *

    When all items are either received, damaged, or canceled, the order moves to + * COMPLETED status.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture> receive( + ReceiveTransferOrderRequest request) { + return receive(request, null); + } + + /** + * Records receipt of CatalogItemVariations for a transfer order. + * This endpoint supports partial receiving - you can receive items in multiple batches. + *

    For each line item, you can specify:

    + *
      + *
    • Quantity received in good condition (added to destination inventory with InventoryState of IN_STOCK)
    • + *
    • Quantity damaged during transit/handling (added to destination inventory with InventoryState of WASTE)
    • + *
    • Quantity canceled (returned to source location's inventory)
    • + *
    + *

    The order must be in STARTED or PARTIALLY_RECEIVED status. + * Received quantities are added to the destination Location's inventory according to their condition. + * Canceled quantities are immediately returned to the source Location's inventory.

    + *

    When all items are either received, damaged, or canceled, the order moves to + * COMPLETED status.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture> receive( + ReceiveTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .addPathSegments("receive") + .build(); + 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) + .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()) { + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ReceiveTransferOrderResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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; + } + + /** + * Changes a DRAFT transfer order to STARTED status. + * This decrements inventory at the source Location and marks it as in-transit. + *

    The order must be in DRAFT status and have all required fields populated. + * Once started, the order can no longer be deleted, but it can be canceled via + * CancelTransferOrder.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture> start( + StartTransferOrderRequest request) { + return start(request, null); + } + + /** + * Changes a DRAFT transfer order to STARTED status. + * This decrements inventory at the source Location and marks it as in-transit. + *

    The order must be in DRAFT status and have all required fields populated. + * Once started, the order can no longer be deleted, but it can be canceled via + * CancelTransferOrder.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture> start( + StartTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .addPathSegments("start") + .build(); + 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) + .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()) { + if (response.isSuccessful()) { + future.complete(new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), StartTransferOrderResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + 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/AsyncRawVendorsClient.java b/src/main/java/com/squareup/square/AsyncRawVendorsClient.java index fd6cf515..9527d046 100644 --- a/src/main/java/com/squareup/square/AsyncRawVendorsClient.java +++ b/src/main/java/com/squareup/square/AsyncRawVendorsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchCreateVendorsRequest; import com.squareup.square.types.BatchCreateVendorsResponse; import com.squareup.square.types.BatchGetVendorsRequest; @@ -25,8 +26,13 @@ import com.squareup.square.types.SearchVendorsResponse; import com.squareup.square.types.UpdateVendorResponse; import com.squareup.square.types.UpdateVendorsRequest; +import com.squareup.square.types.Vendor; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -321,21 +327,22 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchVendorsRequest.builder().build()); } /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public CompletableFuture> search(SearchVendorsRequest request) { + public CompletableFuture>> search( + SearchVendorsRequest request) { return search(request, null); } /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchVendorsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -359,14 +366,30 @@ public CompletableFuture> search if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchVendorsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchVendorsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchVendorsRequest nextRequest = SearchVendorsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getVendors().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchVendorsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/AsyncSquareClient.java b/src/main/java/com/squareup/square/AsyncSquareClient.java index c307ebea..c78a23b4 100644 --- a/src/main/java/com/squareup/square/AsyncSquareClient.java +++ b/src/main/java/com/squareup/square/AsyncSquareClient.java @@ -28,6 +28,8 @@ public class AsyncSquareClient { protected final Supplier catalogClient; + protected final Supplier channelsClient; + protected final Supplier customersClient; protected final Supplier devicesClient; @@ -74,6 +76,8 @@ public class AsyncSquareClient { protected final Supplier terminalClient; + protected final Supplier transferOrdersClient; + protected final Supplier vendorsClient; protected final Supplier cashDrawersClient; @@ -90,6 +94,7 @@ public AsyncSquareClient(ClientOptions clientOptions) { this.bookingsClient = Suppliers.memoize(() -> new AsyncBookingsClient(clientOptions)); this.cardsClient = Suppliers.memoize(() -> new AsyncCardsClient(clientOptions)); this.catalogClient = Suppliers.memoize(() -> new AsyncCatalogClient(clientOptions)); + this.channelsClient = Suppliers.memoize(() -> new AsyncChannelsClient(clientOptions)); this.customersClient = Suppliers.memoize(() -> new AsyncCustomersClient(clientOptions)); this.devicesClient = Suppliers.memoize(() -> new AsyncDevicesClient(clientOptions)); this.disputesClient = Suppliers.memoize(() -> new AsyncDisputesClient(clientOptions)); @@ -113,6 +118,7 @@ public AsyncSquareClient(ClientOptions clientOptions) { this.teamMembersClient = Suppliers.memoize(() -> new AsyncTeamMembersClient(clientOptions)); this.teamClient = Suppliers.memoize(() -> new AsyncTeamClient(clientOptions)); this.terminalClient = Suppliers.memoize(() -> new AsyncTerminalClient(clientOptions)); + this.transferOrdersClient = Suppliers.memoize(() -> new AsyncTransferOrdersClient(clientOptions)); this.vendorsClient = Suppliers.memoize(() -> new AsyncVendorsClient(clientOptions)); this.cashDrawersClient = Suppliers.memoize(() -> new AsyncCashDrawersClient(clientOptions)); this.webhooksClient = Suppliers.memoize(() -> new AsyncWebhooksClient(clientOptions)); @@ -150,6 +156,10 @@ public AsyncCatalogClient catalog() { return this.catalogClient.get(); } + public AsyncChannelsClient channels() { + return this.channelsClient.get(); + } + public AsyncCustomersClient customers() { return this.customersClient.get(); } @@ -242,6 +252,10 @@ public AsyncTerminalClient terminal() { return this.terminalClient.get(); } + public AsyncTransferOrdersClient transferOrders() { + return this.transferOrdersClient.get(); + } + public AsyncVendorsClient vendors() { return this.vendorsClient.get(); } diff --git a/src/main/java/com/squareup/square/AsyncSquareClientBuilder.java b/src/main/java/com/squareup/square/AsyncSquareClientBuilder.java index 42e0a880..2c0155a9 100644 --- a/src/main/java/com/squareup/square/AsyncSquareClientBuilder.java +++ b/src/main/java/com/squareup/square/AsyncSquareClientBuilder.java @@ -19,7 +19,7 @@ public class AsyncSquareClientBuilder { private String token = System.getenv("SQUARE_TOKEN"); - private String version = "2025-09-24"; + private String version = "2025-10-16"; private Environment environment = Environment.PRODUCTION; diff --git a/src/main/java/com/squareup/square/AsyncSubscriptionsClient.java b/src/main/java/com/squareup/square/AsyncSubscriptionsClient.java index fb4aa583..e7aec595 100644 --- a/src/main/java/com/squareup/square/AsyncSubscriptionsClient.java +++ b/src/main/java/com/squareup/square/AsyncSubscriptionsClient.java @@ -24,7 +24,7 @@ import com.squareup.square.types.ResumeSubscriptionRequest; import com.squareup.square.types.ResumeSubscriptionResponse; import com.squareup.square.types.SearchSubscriptionsRequest; -import com.squareup.square.types.SearchSubscriptionsResponse; +import com.squareup.square.types.Subscription; import com.squareup.square.types.SubscriptionEvent; import com.squareup.square.types.SwapPlanRequest; import com.squareup.square.types.SwapPlanResponse; @@ -105,7 +105,7 @@ public CompletableFuture bulkSwapPlan( * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } @@ -123,7 +123,7 @@ public CompletableFuture search() { * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public CompletableFuture search(SearchSubscriptionsRequest request) { + public CompletableFuture> search(SearchSubscriptionsRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -141,7 +141,7 @@ public CompletableFuture search(SearchSubscriptions * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public CompletableFuture search( + public CompletableFuture> search( SearchSubscriptionsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/AsyncTeamMembersClient.java b/src/main/java/com/squareup/square/AsyncTeamMembersClient.java index 0c09eeb5..342fdb9d 100644 --- a/src/main/java/com/squareup/square/AsyncTeamMembersClient.java +++ b/src/main/java/com/squareup/square/AsyncTeamMembersClient.java @@ -6,6 +6,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; import com.squareup.square.core.Suppliers; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.teammembers.AsyncWageSettingClient; import com.squareup.square.types.BatchCreateTeamMembersRequest; import com.squareup.square.types.BatchCreateTeamMembersResponse; @@ -16,7 +17,7 @@ import com.squareup.square.types.GetTeamMemberResponse; import com.squareup.square.types.GetTeamMembersRequest; import com.squareup.square.types.SearchTeamMembersRequest; -import com.squareup.square.types.SearchTeamMembersResponse; +import com.squareup.square.types.TeamMember; import com.squareup.square.types.UpdateTeamMemberResponse; import com.squareup.square.types.UpdateTeamMembersRequest; import java.util.concurrent.CompletableFuture; @@ -133,7 +134,7 @@ public CompletableFuture batchUpdate( * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } @@ -142,7 +143,7 @@ public CompletableFuture search() { * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public CompletableFuture search(SearchTeamMembersRequest request) { + public CompletableFuture> search(SearchTeamMembersRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -151,7 +152,7 @@ public CompletableFuture search(SearchTeamMembersRequ * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public CompletableFuture search( + public CompletableFuture> search( SearchTeamMembersRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/AsyncTransferOrdersClient.java b/src/main/java/com/squareup/square/AsyncTransferOrdersClient.java new file mode 100644 index 00000000..356796b9 --- /dev/null +++ b/src/main/java/com/squareup/square/AsyncTransferOrdersClient.java @@ -0,0 +1,307 @@ +/** + * 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.core.SyncPagingIterable; +import com.squareup.square.types.CancelTransferOrderRequest; +import com.squareup.square.types.CancelTransferOrderResponse; +import com.squareup.square.types.CreateTransferOrderRequest; +import com.squareup.square.types.CreateTransferOrderResponse; +import com.squareup.square.types.DeleteTransferOrderResponse; +import com.squareup.square.types.DeleteTransferOrdersRequest; +import com.squareup.square.types.GetTransferOrdersRequest; +import com.squareup.square.types.ReceiveTransferOrderRequest; +import com.squareup.square.types.ReceiveTransferOrderResponse; +import com.squareup.square.types.RetrieveTransferOrderResponse; +import com.squareup.square.types.SearchTransferOrdersRequest; +import com.squareup.square.types.StartTransferOrderRequest; +import com.squareup.square.types.StartTransferOrderResponse; +import com.squareup.square.types.TransferOrder; +import com.squareup.square.types.UpdateTransferOrderRequest; +import com.squareup.square.types.UpdateTransferOrderResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncTransferOrdersClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTransferOrdersClient rawClient; + + public AsyncTransferOrdersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTransferOrdersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTransferOrdersClient withRawResponse() { + return this.rawClient; + } + + /** + * Creates a new transfer order in DRAFT status. A transfer order represents the intent + * to move CatalogItemVariations from one Location to another. + * The source and destination locations must be different and must belong to your Square account. + *

    In DRAFT status, you can:

    + *
      + *
    • Add or remove items
    • + *
    • Modify quantities
    • + *
    • Update shipping information
    • + *
    • Delete the entire order via DeleteTransferOrder
    • + *
    + *

    The request requires source_location_id and destination_location_id. + * Inventory levels are not affected until the order is started via + * StartTransferOrder.

    + *

    Common integration points:

    + *
      + *
    • Sync with warehouse management systems
    • + *
    • Automate regular stock transfers
    • + *
    • Initialize transfers from inventory optimization systems
    • + *
    + *

    Creates a transfer_order.created webhook event.

    + */ + public CompletableFuture create(CreateTransferOrderRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a new transfer order in DRAFT status. A transfer order represents the intent + * to move CatalogItemVariations from one Location to another. + * The source and destination locations must be different and must belong to your Square account. + *

    In DRAFT status, you can:

    + *
      + *
    • Add or remove items
    • + *
    • Modify quantities
    • + *
    • Update shipping information
    • + *
    • Delete the entire order via DeleteTransferOrder
    • + *
    + *

    The request requires source_location_id and destination_location_id. + * Inventory levels are not affected until the order is started via + * StartTransferOrder.

    + *

    Common integration points:

    + *
      + *
    • Sync with warehouse management systems
    • + *
    • Automate regular stock transfers
    • + *
    • Initialize transfers from inventory optimization systems
    • + *
    + *

    Creates a transfer_order.created webhook event.

    + */ + public CompletableFuture create( + CreateTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public CompletableFuture> search() { + return this.rawClient.search().thenApply(response -> response.body()); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public CompletableFuture> search(SearchTransferOrdersRequest request) { + return this.rawClient.search(request).thenApply(response -> response.body()); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public CompletableFuture> search( + SearchTransferOrdersRequest request, RequestOptions requestOptions) { + return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves a specific TransferOrder by ID. Returns the complete + * order details including: + *
      + *
    • Basic information (status, dates, notes)
    • + *
    • Line items with ordered and received quantities
    • + *
    • Source and destination Locations
    • + *
    • Tracking information (if available)
    • + *
    + */ + public CompletableFuture get(GetTransferOrdersRequest request) { + return this.rawClient.get(request).thenApply(response -> response.body()); + } + + /** + * Retrieves a specific TransferOrder by ID. Returns the complete + * order details including: + *
      + *
    • Basic information (status, dates, notes)
    • + *
    • Line items with ordered and received quantities
    • + *
    • Source and destination Locations
    • + *
    • Tracking information (if available)
    • + *
    + */ + public CompletableFuture get( + GetTransferOrdersRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates an existing transfer order. This endpoint supports sparse updates, + * allowing you to modify specific fields without affecting others. + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture update(UpdateTransferOrderRequest request) { + return this.rawClient.update(request).thenApply(response -> response.body()); + } + + /** + * Updates an existing transfer order. This endpoint supports sparse updates, + * allowing you to modify specific fields without affecting others. + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture update( + UpdateTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.update(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Deletes a transfer order in DRAFT status. + * Only draft orders can be deleted. Once an order is started via + * StartTransferOrder, it can no longer be deleted. + *

    Creates a transfer_order.deleted webhook event.

    + */ + public CompletableFuture delete(DeleteTransferOrdersRequest request) { + return this.rawClient.delete(request).thenApply(response -> response.body()); + } + + /** + * Deletes a transfer order in DRAFT status. + * Only draft orders can be deleted. Once an order is started via + * StartTransferOrder, it can no longer be deleted. + *

    Creates a transfer_order.deleted webhook event.

    + */ + public CompletableFuture delete( + DeleteTransferOrdersRequest request, RequestOptions requestOptions) { + return this.rawClient.delete(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Cancels a transfer order in STARTED or + * PARTIALLY_RECEIVED status. Any unreceived quantities will no + * longer be receivable and will be immediately returned to the source Location's inventory. + *

    Common reasons for cancellation:

    + *
      + *
    • Items no longer needed at destination
    • + *
    • Source location needs the inventory
    • + *
    • Order created in error
    • + *
    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture cancel(CancelTransferOrderRequest request) { + return this.rawClient.cancel(request).thenApply(response -> response.body()); + } + + /** + * Cancels a transfer order in STARTED or + * PARTIALLY_RECEIVED status. Any unreceived quantities will no + * longer be receivable and will be immediately returned to the source Location's inventory. + *

    Common reasons for cancellation:

    + *
      + *
    • Items no longer needed at destination
    • + *
    • Source location needs the inventory
    • + *
    • Order created in error
    • + *
    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture cancel( + CancelTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.cancel(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Records receipt of CatalogItemVariations for a transfer order. + * This endpoint supports partial receiving - you can receive items in multiple batches. + *

    For each line item, you can specify:

    + *
      + *
    • Quantity received in good condition (added to destination inventory with InventoryState of IN_STOCK)
    • + *
    • Quantity damaged during transit/handling (added to destination inventory with InventoryState of WASTE)
    • + *
    • Quantity canceled (returned to source location's inventory)
    • + *
    + *

    The order must be in STARTED or PARTIALLY_RECEIVED status. + * Received quantities are added to the destination Location's inventory according to their condition. + * Canceled quantities are immediately returned to the source Location's inventory.

    + *

    When all items are either received, damaged, or canceled, the order moves to + * COMPLETED status.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture receive(ReceiveTransferOrderRequest request) { + return this.rawClient.receive(request).thenApply(response -> response.body()); + } + + /** + * Records receipt of CatalogItemVariations for a transfer order. + * This endpoint supports partial receiving - you can receive items in multiple batches. + *

    For each line item, you can specify:

    + *
      + *
    • Quantity received in good condition (added to destination inventory with InventoryState of IN_STOCK)
    • + *
    • Quantity damaged during transit/handling (added to destination inventory with InventoryState of WASTE)
    • + *
    • Quantity canceled (returned to source location's inventory)
    • + *
    + *

    The order must be in STARTED or PARTIALLY_RECEIVED status. + * Received quantities are added to the destination Location's inventory according to their condition. + * Canceled quantities are immediately returned to the source Location's inventory.

    + *

    When all items are either received, damaged, or canceled, the order moves to + * COMPLETED status.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture receive( + ReceiveTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.receive(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Changes a DRAFT transfer order to STARTED status. + * This decrements inventory at the source Location and marks it as in-transit. + *

    The order must be in DRAFT status and have all required fields populated. + * Once started, the order can no longer be deleted, but it can be canceled via + * CancelTransferOrder.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture start(StartTransferOrderRequest request) { + return this.rawClient.start(request).thenApply(response -> response.body()); + } + + /** + * Changes a DRAFT transfer order to STARTED status. + * This decrements inventory at the source Location and marks it as in-transit. + *

    The order must be in DRAFT status and have all required fields populated. + * Once started, the order can no longer be deleted, but it can be canceled via + * CancelTransferOrder.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CompletableFuture start( + StartTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.start(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/squareup/square/AsyncVendorsClient.java b/src/main/java/com/squareup/square/AsyncVendorsClient.java index 6d6f281a..9875d1fe 100644 --- a/src/main/java/com/squareup/square/AsyncVendorsClient.java +++ b/src/main/java/com/squareup/square/AsyncVendorsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchCreateVendorsRequest; import com.squareup.square.types.BatchCreateVendorsResponse; import com.squareup.square.types.BatchGetVendorsRequest; @@ -16,9 +17,9 @@ import com.squareup.square.types.GetVendorResponse; import com.squareup.square.types.GetVendorsRequest; import com.squareup.square.types.SearchVendorsRequest; -import com.squareup.square.types.SearchVendorsResponse; import com.squareup.square.types.UpdateVendorResponse; import com.squareup.square.types.UpdateVendorsRequest; +import com.squareup.square.types.Vendor; import java.util.concurrent.CompletableFuture; public class AsyncVendorsClient { @@ -107,21 +108,21 @@ public CompletableFuture create(CreateVendorRequest reques /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public CompletableFuture search(SearchVendorsRequest request) { + public CompletableFuture> search(SearchVendorsRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public CompletableFuture search( + public CompletableFuture> search( SearchVendorsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/CatalogClient.java b/src/main/java/com/squareup/square/CatalogClient.java index 1be6dec3..3a2d6877 100644 --- a/src/main/java/com/squareup/square/CatalogClient.java +++ b/src/main/java/com/squareup/square/CatalogClient.java @@ -19,9 +19,7 @@ import com.squareup.square.types.CatalogObject; import com.squareup.square.types.ListCatalogRequest; import com.squareup.square.types.SearchCatalogItemsRequest; -import com.squareup.square.types.SearchCatalogItemsResponse; import com.squareup.square.types.SearchCatalogObjectsRequest; -import com.squareup.square.types.SearchCatalogObjectsResponse; import com.squareup.square.types.UpdateItemModifierListsRequest; import com.squareup.square.types.UpdateItemModifierListsResponse; import com.squareup.square.types.UpdateItemTaxesRequest; @@ -214,7 +212,7 @@ public SyncPagingIterable list(ListCatalogRequest request, Reques *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public SearchCatalogObjectsResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } @@ -230,7 +228,7 @@ public SearchCatalogObjectsResponse search() { *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public SearchCatalogObjectsResponse search(SearchCatalogObjectsRequest request) { + public SyncPagingIterable search(SearchCatalogObjectsRequest request) { return this.rawClient.search(request).body(); } @@ -246,7 +244,8 @@ public SearchCatalogObjectsResponse search(SearchCatalogObjectsRequest request) *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public SearchCatalogObjectsResponse search(SearchCatalogObjectsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search( + SearchCatalogObjectsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } @@ -262,7 +261,7 @@ public SearchCatalogObjectsResponse search(SearchCatalogObjectsRequest request, *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public SearchCatalogItemsResponse searchItems() { + public SyncPagingIterable searchItems() { return this.rawClient.searchItems().body(); } @@ -278,7 +277,7 @@ public SearchCatalogItemsResponse searchItems() { *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public SearchCatalogItemsResponse searchItems(SearchCatalogItemsRequest request) { + public SyncPagingIterable searchItems(SearchCatalogItemsRequest request) { return this.rawClient.searchItems(request).body(); } @@ -294,7 +293,8 @@ public SearchCatalogItemsResponse searchItems(SearchCatalogItemsRequest request) *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public SearchCatalogItemsResponse searchItems(SearchCatalogItemsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable searchItems( + SearchCatalogItemsRequest request, RequestOptions requestOptions) { return this.rawClient.searchItems(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/ChannelsClient.java b/src/main/java/com/squareup/square/ChannelsClient.java new file mode 100644 index 00000000..0d74ed7c --- /dev/null +++ b/src/main/java/com/squareup/square/ChannelsClient.java @@ -0,0 +1,61 @@ +/** + * 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.core.SyncPagingIterable; +import com.squareup.square.types.BulkRetrieveChannelsRequest; +import com.squareup.square.types.BulkRetrieveChannelsResponse; +import com.squareup.square.types.Channel; +import com.squareup.square.types.GetChannelsRequest; +import com.squareup.square.types.ListChannelsRequest; +import com.squareup.square.types.RetrieveChannelResponse; + +public class ChannelsClient { + protected final ClientOptions clientOptions; + + private final RawChannelsClient rawClient; + + public ChannelsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawChannelsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawChannelsClient withRawResponse() { + return this.rawClient; + } + + public SyncPagingIterable list() { + return this.rawClient.list().body(); + } + + public SyncPagingIterable list(ListChannelsRequest request) { + return this.rawClient.list(request).body(); + } + + public SyncPagingIterable list(ListChannelsRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).body(); + } + + public BulkRetrieveChannelsResponse bulkRetrieve(BulkRetrieveChannelsRequest request) { + return this.rawClient.bulkRetrieve(request).body(); + } + + public BulkRetrieveChannelsResponse bulkRetrieve( + BulkRetrieveChannelsRequest request, RequestOptions requestOptions) { + return this.rawClient.bulkRetrieve(request, requestOptions).body(); + } + + public RetrieveChannelResponse get(GetChannelsRequest request) { + return this.rawClient.get(request).body(); + } + + public RetrieveChannelResponse get(GetChannelsRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/squareup/square/CustomersClient.java b/src/main/java/com/squareup/square/CustomersClient.java index e714cdd4..75433f6c 100644 --- a/src/main/java/com/squareup/square/CustomersClient.java +++ b/src/main/java/com/squareup/square/CustomersClient.java @@ -29,7 +29,6 @@ import com.squareup.square.types.GetCustomersRequest; import com.squareup.square.types.ListCustomersRequest; import com.squareup.square.types.SearchCustomersRequest; -import com.squareup.square.types.SearchCustomersResponse; import com.squareup.square.types.UpdateCustomerRequest; import com.squareup.square.types.UpdateCustomerResponse; import java.util.function.Supplier; @@ -237,7 +236,7 @@ public BulkUpdateCustomersResponse bulkUpdateCustomers( * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public SearchCustomersResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } @@ -250,7 +249,7 @@ public SearchCustomersResponse search() { * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public SearchCustomersResponse search(SearchCustomersRequest request) { + public SyncPagingIterable search(SearchCustomersRequest request) { return this.rawClient.search(request).body(); } @@ -263,7 +262,7 @@ public SearchCustomersResponse search(SearchCustomersRequest request) { * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public SearchCustomersResponse search(SearchCustomersRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search(SearchCustomersRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/InventoryClient.java b/src/main/java/com/squareup/square/InventoryClient.java index c7ff71c6..be79f572 100644 --- a/src/main/java/com/squareup/square/InventoryClient.java +++ b/src/main/java/com/squareup/square/InventoryClient.java @@ -8,9 +8,7 @@ import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchChangeInventoryRequest; import com.squareup.square.types.BatchChangeInventoryResponse; -import com.squareup.square.types.BatchGetInventoryChangesResponse; import com.squareup.square.types.BatchGetInventoryCountsRequest; -import com.squareup.square.types.BatchGetInventoryCountsResponse; import com.squareup.square.types.BatchRetrieveInventoryChangesRequest; import com.squareup.square.types.ChangesInventoryRequest; import com.squareup.square.types.DeprecatedGetAdjustmentInventoryRequest; @@ -97,7 +95,7 @@ public BatchChangeInventoryResponse deprecatedBatchChange( * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public BatchGetInventoryChangesResponse deprecatedBatchGetChanges() { + public SyncPagingIterable deprecatedBatchGetChanges() { return this.rawClient.deprecatedBatchGetChanges().body(); } @@ -105,7 +103,7 @@ public BatchGetInventoryChangesResponse deprecatedBatchGetChanges() { * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public BatchGetInventoryChangesResponse deprecatedBatchGetChanges(BatchRetrieveInventoryChangesRequest request) { + public SyncPagingIterable deprecatedBatchGetChanges(BatchRetrieveInventoryChangesRequest request) { return this.rawClient.deprecatedBatchGetChanges(request).body(); } @@ -113,7 +111,7 @@ public BatchGetInventoryChangesResponse deprecatedBatchGetChanges(BatchRetrieveI * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public BatchGetInventoryChangesResponse deprecatedBatchGetChanges( + public SyncPagingIterable deprecatedBatchGetChanges( BatchRetrieveInventoryChangesRequest request, RequestOptions requestOptions) { return this.rawClient.deprecatedBatchGetChanges(request, requestOptions).body(); } @@ -122,7 +120,7 @@ public BatchGetInventoryChangesResponse deprecatedBatchGetChanges( * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public BatchGetInventoryCountsResponse deprecatedBatchGetCounts() { + public SyncPagingIterable deprecatedBatchGetCounts() { return this.rawClient.deprecatedBatchGetCounts().body(); } @@ -130,7 +128,7 @@ public BatchGetInventoryCountsResponse deprecatedBatchGetCounts() { * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public BatchGetInventoryCountsResponse deprecatedBatchGetCounts(BatchGetInventoryCountsRequest request) { + public SyncPagingIterable deprecatedBatchGetCounts(BatchGetInventoryCountsRequest request) { return this.rawClient.deprecatedBatchGetCounts(request).body(); } @@ -138,7 +136,7 @@ public BatchGetInventoryCountsResponse deprecatedBatchGetCounts(BatchGetInventor * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public BatchGetInventoryCountsResponse deprecatedBatchGetCounts( + public SyncPagingIterable deprecatedBatchGetCounts( BatchGetInventoryCountsRequest request, RequestOptions requestOptions) { return this.rawClient.deprecatedBatchGetCounts(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/InvoicesClient.java b/src/main/java/com/squareup/square/InvoicesClient.java index 9216285e..0a960c23 100644 --- a/src/main/java/com/squareup/square/InvoicesClient.java +++ b/src/main/java/com/squareup/square/InvoicesClient.java @@ -23,7 +23,6 @@ import com.squareup.square.types.PublishInvoiceRequest; import com.squareup.square.types.PublishInvoiceResponse; import com.squareup.square.types.SearchInvoicesRequest; -import com.squareup.square.types.SearchInvoicesResponse; import com.squareup.square.types.UpdateInvoiceRequest; import com.squareup.square.types.UpdateInvoiceResponse; @@ -90,7 +89,7 @@ public CreateInvoiceResponse create(CreateInvoiceRequest request, RequestOptions *

    The response is paginated. If truncated, the response includes a cursor * that you use in a subsequent request to retrieve the next set of invoices.

    */ - public SearchInvoicesResponse search(SearchInvoicesRequest request) { + public SyncPagingIterable search(SearchInvoicesRequest request) { return this.rawClient.search(request).body(); } @@ -102,7 +101,7 @@ public SearchInvoicesResponse search(SearchInvoicesRequest request) { *

    The response is paginated. If truncated, the response includes a cursor * that you use in a subsequent request to retrieve the next set of invoices.

    */ - public SearchInvoicesResponse search(SearchInvoicesRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search(SearchInvoicesRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/LoyaltyClient.java b/src/main/java/com/squareup/square/LoyaltyClient.java index 430835f3..a49816de 100644 --- a/src/main/java/com/squareup/square/LoyaltyClient.java +++ b/src/main/java/com/squareup/square/LoyaltyClient.java @@ -6,11 +6,12 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; import com.squareup.square.core.Suppliers; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.AccountsClient; import com.squareup.square.loyalty.ProgramsClient; import com.squareup.square.loyalty.RewardsClient; +import com.squareup.square.types.LoyaltyEvent; import com.squareup.square.types.SearchLoyaltyEventsRequest; -import com.squareup.square.types.SearchLoyaltyEventsResponse; import java.util.function.Supplier; public class LoyaltyClient { @@ -47,7 +48,7 @@ public RawLoyaltyClient withRawResponse() { * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public SearchLoyaltyEventsResponse searchEvents() { + public SyncPagingIterable searchEvents() { return this.rawClient.searchEvents().body(); } @@ -59,7 +60,7 @@ public SearchLoyaltyEventsResponse searchEvents() { * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public SearchLoyaltyEventsResponse searchEvents(SearchLoyaltyEventsRequest request) { + public SyncPagingIterable searchEvents(SearchLoyaltyEventsRequest request) { return this.rawClient.searchEvents(request).body(); } @@ -71,7 +72,8 @@ public SearchLoyaltyEventsResponse searchEvents(SearchLoyaltyEventsRequest reque * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public SearchLoyaltyEventsResponse searchEvents(SearchLoyaltyEventsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable searchEvents( + SearchLoyaltyEventsRequest request, RequestOptions requestOptions) { return this.rawClient.searchEvents(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/OrdersClient.java b/src/main/java/com/squareup/square/OrdersClient.java index a0310b5d..98f08688 100644 --- a/src/main/java/com/squareup/square/OrdersClient.java +++ b/src/main/java/com/squareup/square/OrdersClient.java @@ -6,6 +6,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; import com.squareup.square.core.Suppliers; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.orders.CustomAttributeDefinitionsClient; import com.squareup.square.orders.CustomAttributesClient; import com.squareup.square.types.BatchGetOrdersRequest; @@ -18,10 +19,10 @@ import com.squareup.square.types.CreateOrderResponse; import com.squareup.square.types.GetOrderResponse; import com.squareup.square.types.GetOrdersRequest; +import com.squareup.square.types.Order; import com.squareup.square.types.PayOrderRequest; import com.squareup.square.types.PayOrderResponse; import com.squareup.square.types.SearchOrdersRequest; -import com.squareup.square.types.SearchOrdersResponse; import com.squareup.square.types.UpdateOrderRequest; import com.squareup.square.types.UpdateOrderResponse; import java.util.function.Supplier; @@ -145,7 +146,7 @@ public CloneOrderResponse clone(CloneOrderRequest request, RequestOptions reques * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public SearchOrdersResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } @@ -165,7 +166,7 @@ public SearchOrdersResponse search() { * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public SearchOrdersResponse search(SearchOrdersRequest request) { + public SyncPagingIterable search(SearchOrdersRequest request) { return this.rawClient.search(request).body(); } @@ -185,7 +186,7 @@ public SearchOrdersResponse search(SearchOrdersRequest request) { * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public SearchOrdersResponse search(SearchOrdersRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search(SearchOrdersRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/RawCatalogClient.java b/src/main/java/com/squareup/square/RawCatalogClient.java index ba0faa9e..77d2c34d 100644 --- a/src/main/java/com/squareup/square/RawCatalogClient.java +++ b/src/main/java/com/squareup/square/RawCatalogClient.java @@ -409,7 +409,7 @@ public SquareClientHttpResponse> list( *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchCatalogObjectsRequest.builder().build()); } @@ -425,7 +425,7 @@ public SquareClientHttpResponse search() { *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public SquareClientHttpResponse search(SearchCatalogObjectsRequest request) { + public SquareClientHttpResponse> search(SearchCatalogObjectsRequest request) { return search(request, null); } @@ -441,7 +441,7 @@ public SquareClientHttpResponse search(SearchCatal *
  • The both endpoints have different call conventions, including the query filter formats.
  • * */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchCatalogObjectsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -468,8 +468,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchCatalogObjectsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchCatalogObjectsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchCatalogObjectsRequest nextRequest = SearchCatalogObjectsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getObjects().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchCatalogObjectsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -495,7 +505,7 @@ public SquareClientHttpResponse search( *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public SquareClientHttpResponse searchItems() { + public SquareClientHttpResponse> searchItems() { return searchItems(SearchCatalogItemsRequest.builder().build()); } @@ -511,7 +521,7 @@ public SquareClientHttpResponse searchItems() { *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public SquareClientHttpResponse searchItems(SearchCatalogItemsRequest request) { + public SquareClientHttpResponse> searchItems(SearchCatalogItemsRequest request) { return searchItems(request, null); } @@ -527,7 +537,7 @@ public SquareClientHttpResponse searchItems(SearchCa *
  • The both endpoints use different call conventions, including the query filter formats.
  • * */ - public SquareClientHttpResponse searchItems( + public SquareClientHttpResponse> searchItems( SearchCatalogItemsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -554,8 +564,18 @@ public SquareClientHttpResponse searchItems( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchCatalogItemsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchCatalogItemsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchCatalogItemsRequest nextRequest = SearchCatalogItemsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getItems().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchCatalogItemsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> searchItems(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/RawChannelsClient.java b/src/main/java/com/squareup/square/RawChannelsClient.java new file mode 100644 index 00000000..3dcc2b29 --- /dev/null +++ b/src/main/java/com/squareup/square/RawChannelsClient.java @@ -0,0 +1,197 @@ +/** + * 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.QueryStringMapper; +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.core.SyncPagingIterable; +import com.squareup.square.types.BulkRetrieveChannelsRequest; +import com.squareup.square.types.BulkRetrieveChannelsResponse; +import com.squareup.square.types.Channel; +import com.squareup.square.types.GetChannelsRequest; +import com.squareup.square.types.ListChannelsRequest; +import com.squareup.square.types.ListChannelsResponse; +import com.squareup.square.types.RetrieveChannelResponse; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawChannelsClient { + protected final ClientOptions clientOptions; + + public RawChannelsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public SquareClientHttpResponse> list() { + return list(ListChannelsRequest.builder().build()); + } + + public SquareClientHttpResponse> list(ListChannelsRequest request) { + return list(request, null); + } + + public SquareClientHttpResponse> list( + ListChannelsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/channels"); + if (request.getReferenceType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "reference_type", request.getReferenceType().get(), false); + } + if (request.getReferenceId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "reference_id", request.getReferenceId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.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(); + if (response.isSuccessful()) { + ListChannelsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListChannelsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + ListChannelsRequest nextRequest = ListChannelsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getChannels().orElse(Collections.emptyList()); + return new SquareClientHttpResponse<>( + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) + .body()), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + public SquareClientHttpResponse bulkRetrieve(BulkRetrieveChannelsRequest request) { + return bulkRetrieve(request, null); + } + + public SquareClientHttpResponse bulkRetrieve( + BulkRetrieveChannelsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/channels/bulk-retrieve") + .build(); + 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) + .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(); + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BulkRetrieveChannelsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + public SquareClientHttpResponse get(GetChannelsRequest request) { + return get(request, null); + } + + public SquareClientHttpResponse get( + GetChannelsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/channels") + .addPathSegment(request.getChannelId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.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(); + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RetrieveChannelResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/squareup/square/RawCustomersClient.java b/src/main/java/com/squareup/square/RawCustomersClient.java index 7ea67c8a..e6769bb0 100644 --- a/src/main/java/com/squareup/square/RawCustomersClient.java +++ b/src/main/java/com/squareup/square/RawCustomersClient.java @@ -472,7 +472,7 @@ public SquareClientHttpResponse bulkUpdateCustomers * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchCustomersRequest.builder().build()); } @@ -485,7 +485,7 @@ public SquareClientHttpResponse search() { * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public SquareClientHttpResponse search(SearchCustomersRequest request) { + public SquareClientHttpResponse> search(SearchCustomersRequest request) { return search(request, null); } @@ -498,7 +498,7 @@ public SquareClientHttpResponse search(SearchCustomersR * for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated * profiles can take closer to one minute or longer, especially during network incidents and outages.

    */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchCustomersRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -525,8 +525,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchCustomersResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchCustomersResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchCustomersRequest nextRequest = SearchCustomersRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getCustomers().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchCustomersResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/RawInventoryClient.java b/src/main/java/com/squareup/square/RawInventoryClient.java index 0e63c408..52885cdc 100644 --- a/src/main/java/com/squareup/square/RawInventoryClient.java +++ b/src/main/java/com/squareup/square/RawInventoryClient.java @@ -209,7 +209,7 @@ public SquareClientHttpResponse deprecatedBatchCha * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public SquareClientHttpResponse deprecatedBatchGetChanges() { + public SquareClientHttpResponse> deprecatedBatchGetChanges() { return deprecatedBatchGetChanges( BatchRetrieveInventoryChangesRequest.builder().build()); } @@ -218,7 +218,7 @@ public SquareClientHttpResponse deprecatedBatc * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public SquareClientHttpResponse deprecatedBatchGetChanges( + public SquareClientHttpResponse> deprecatedBatchGetChanges( BatchRetrieveInventoryChangesRequest request) { return deprecatedBatchGetChanges(request, null); } @@ -227,7 +227,7 @@ public SquareClientHttpResponse deprecatedBatc * Deprecated version of BatchRetrieveInventoryChanges after the endpoint URL * is updated to conform to the standard convention. */ - public SquareClientHttpResponse deprecatedBatchGetChanges( + public SquareClientHttpResponse> deprecatedBatchGetChanges( BatchRetrieveInventoryChangesRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -254,9 +254,19 @@ public SquareClientHttpResponse deprecatedBatc try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + BatchGetInventoryChangesResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), BatchGetInventoryChangesResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + BatchRetrieveInventoryChangesRequest nextRequest = BatchRetrieveInventoryChangesRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getChanges().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), BatchGetInventoryChangesResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> deprecatedBatchGetChanges( + nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -274,7 +284,7 @@ public SquareClientHttpResponse deprecatedBatc * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public SquareClientHttpResponse deprecatedBatchGetCounts() { + public SquareClientHttpResponse> deprecatedBatchGetCounts() { return deprecatedBatchGetCounts(BatchGetInventoryCountsRequest.builder().build()); } @@ -282,7 +292,7 @@ public SquareClientHttpResponse deprecatedBatch * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public SquareClientHttpResponse deprecatedBatchGetCounts( + public SquareClientHttpResponse> deprecatedBatchGetCounts( BatchGetInventoryCountsRequest request) { return deprecatedBatchGetCounts(request, null); } @@ -291,7 +301,7 @@ public SquareClientHttpResponse deprecatedBatch * Deprecated version of BatchRetrieveInventoryCounts after the endpoint URL * is updated to conform to the standard convention. */ - public SquareClientHttpResponse deprecatedBatchGetCounts( + public SquareClientHttpResponse> deprecatedBatchGetCounts( BatchGetInventoryCountsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -318,9 +328,19 @@ public SquareClientHttpResponse deprecatedBatch try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + BatchGetInventoryCountsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), BatchGetInventoryCountsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + BatchGetInventoryCountsRequest nextRequest = BatchGetInventoryCountsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getCounts().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), BatchGetInventoryCountsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> deprecatedBatchGetCounts( + nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/RawInvoicesClient.java b/src/main/java/com/squareup/square/RawInvoicesClient.java index a5a7509d..43deb48c 100644 --- a/src/main/java/com/squareup/square/RawInvoicesClient.java +++ b/src/main/java/com/squareup/square/RawInvoicesClient.java @@ -188,7 +188,7 @@ public SquareClientHttpResponse create( *

    The response is paginated. If truncated, the response includes a cursor * that you use in a subsequent request to retrieve the next set of invoices.

    */ - public SquareClientHttpResponse search(SearchInvoicesRequest request) { + public SquareClientHttpResponse> search(SearchInvoicesRequest request) { return search(request, null); } @@ -200,7 +200,7 @@ public SquareClientHttpResponse search(SearchInvoicesReq *

    The response is paginated. If truncated, the response includes a cursor * that you use in a subsequent request to retrieve the next set of invoices.

    */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchInvoicesRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -227,8 +227,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchInvoicesResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchInvoicesResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchInvoicesRequest nextRequest = SearchInvoicesRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getInvoices().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchInvoicesResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/RawLoyaltyClient.java b/src/main/java/com/squareup/square/RawLoyaltyClient.java index f73e37c5..58642121 100644 --- a/src/main/java/com/squareup/square/RawLoyaltyClient.java +++ b/src/main/java/com/squareup/square/RawLoyaltyClient.java @@ -11,9 +11,14 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; +import com.squareup.square.types.LoyaltyEvent; import com.squareup.square.types.SearchLoyaltyEventsRequest; import com.squareup.square.types.SearchLoyaltyEventsResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -37,7 +42,7 @@ public RawLoyaltyClient(ClientOptions clientOptions) { * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public SquareClientHttpResponse searchEvents() { + public SquareClientHttpResponse> searchEvents() { return searchEvents(SearchLoyaltyEventsRequest.builder().build()); } @@ -49,7 +54,7 @@ public SquareClientHttpResponse searchEvents() { * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public SquareClientHttpResponse searchEvents(SearchLoyaltyEventsRequest request) { + public SquareClientHttpResponse> searchEvents(SearchLoyaltyEventsRequest request) { return searchEvents(request, null); } @@ -61,7 +66,7 @@ public SquareClientHttpResponse searchEvents(Search * recorded in the ledger. Using this endpoint, you can search the ledger for events.

    *

    Search results are sorted by created_at in descending order.

    */ - public SquareClientHttpResponse searchEvents( + public SquareClientHttpResponse> searchEvents( SearchLoyaltyEventsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -88,8 +93,18 @@ public SquareClientHttpResponse searchEvents( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchLoyaltyEventsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchLoyaltyEventsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchLoyaltyEventsRequest nextRequest = SearchLoyaltyEventsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getEvents().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchLoyaltyEventsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> searchEvents(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/RawOrdersClient.java b/src/main/java/com/squareup/square/RawOrdersClient.java index 4eaa353f..b69cd1ae 100644 --- a/src/main/java/com/squareup/square/RawOrdersClient.java +++ b/src/main/java/com/squareup/square/RawOrdersClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchGetOrdersRequest; import com.squareup.square.types.BatchGetOrdersResponse; import com.squareup.square.types.CalculateOrderRequest; @@ -21,6 +22,7 @@ import com.squareup.square.types.CreateOrderResponse; import com.squareup.square.types.GetOrderResponse; import com.squareup.square.types.GetOrdersRequest; +import com.squareup.square.types.Order; import com.squareup.square.types.PayOrderRequest; import com.squareup.square.types.PayOrderResponse; import com.squareup.square.types.SearchOrdersRequest; @@ -28,6 +30,9 @@ import com.squareup.square.types.UpdateOrderRequest; import com.squareup.square.types.UpdateOrderResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -289,7 +294,7 @@ public SquareClientHttpResponse clone( * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchOrdersRequest.builder().build()); } @@ -309,7 +314,7 @@ public SquareClientHttpResponse search() { * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public SquareClientHttpResponse search(SearchOrdersRequest request) { + public SquareClientHttpResponse> search(SearchOrdersRequest request) { return search(request, null); } @@ -329,7 +334,7 @@ public SquareClientHttpResponse search(SearchOrdersRequest * orders have a created_at value that reflects the time the order was created, * not the time it was subsequently transmitted to Square.

    */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchOrdersRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -356,8 +361,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchOrdersResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchOrdersResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchOrdersRequest nextRequest = SearchOrdersRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getOrders().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchOrdersResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/RawSubscriptionsClient.java b/src/main/java/com/squareup/square/RawSubscriptionsClient.java index 3c7da78d..87019ec8 100644 --- a/src/main/java/com/squareup/square/RawSubscriptionsClient.java +++ b/src/main/java/com/squareup/square/RawSubscriptionsClient.java @@ -33,6 +33,7 @@ import com.squareup.square.types.ResumeSubscriptionResponse; import com.squareup.square.types.SearchSubscriptionsRequest; import com.squareup.square.types.SearchSubscriptionsResponse; +import com.squareup.square.types.Subscription; import com.squareup.square.types.SubscriptionEvent; import com.squareup.square.types.SwapPlanRequest; import com.squareup.square.types.SwapPlanResponse; @@ -187,7 +188,7 @@ public SquareClientHttpResponse bulkSwapPlan( * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchSubscriptionsRequest.builder().build()); } @@ -205,7 +206,7 @@ public SquareClientHttpResponse search() { * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public SquareClientHttpResponse search(SearchSubscriptionsRequest request) { + public SquareClientHttpResponse> search(SearchSubscriptionsRequest request) { return search(request, null); } @@ -223,7 +224,7 @@ public SquareClientHttpResponse search(SearchSubscr * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchSubscriptionsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -250,8 +251,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchSubscriptionsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchSubscriptionsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchSubscriptionsRequest nextRequest = SearchSubscriptionsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getSubscriptions().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchSubscriptionsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/RawTeamMembersClient.java b/src/main/java/com/squareup/square/RawTeamMembersClient.java index 5b79aaff..91eccb67 100644 --- a/src/main/java/com/squareup/square/RawTeamMembersClient.java +++ b/src/main/java/com/squareup/square/RawTeamMembersClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchCreateTeamMembersRequest; import com.squareup.square.types.BatchCreateTeamMembersResponse; import com.squareup.square.types.BatchUpdateTeamMembersRequest; @@ -21,9 +22,13 @@ import com.squareup.square.types.GetTeamMembersRequest; import com.squareup.square.types.SearchTeamMembersRequest; import com.squareup.square.types.SearchTeamMembersResponse; +import com.squareup.square.types.TeamMember; import com.squareup.square.types.UpdateTeamMemberResponse; import com.squareup.square.types.UpdateTeamMembersRequest; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -243,7 +248,7 @@ public SquareClientHttpResponse batchUpdate( * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchTeamMembersRequest.builder().build()); } @@ -252,7 +257,7 @@ public SquareClientHttpResponse search() { * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public SquareClientHttpResponse search(SearchTeamMembersRequest request) { + public SquareClientHttpResponse> search(SearchTeamMembersRequest request) { return search(request, null); } @@ -261,7 +266,7 @@ public SquareClientHttpResponse search(SearchTeamMemb * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchTeamMembersRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -288,8 +293,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchTeamMembersResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchTeamMembersResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTeamMembersRequest nextRequest = SearchTeamMembersRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getTeamMembers().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchTeamMembersResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/RawTransferOrdersClient.java b/src/main/java/com/squareup/square/RawTransferOrdersClient.java new file mode 100644 index 00000000..466b9d48 --- /dev/null +++ b/src/main/java/com/squareup/square/RawTransferOrdersClient.java @@ -0,0 +1,617 @@ +/** + * 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.QueryStringMapper; +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.core.SyncPagingIterable; +import com.squareup.square.types.CancelTransferOrderRequest; +import com.squareup.square.types.CancelTransferOrderResponse; +import com.squareup.square.types.CreateTransferOrderRequest; +import com.squareup.square.types.CreateTransferOrderResponse; +import com.squareup.square.types.DeleteTransferOrderResponse; +import com.squareup.square.types.DeleteTransferOrdersRequest; +import com.squareup.square.types.GetTransferOrdersRequest; +import com.squareup.square.types.ReceiveTransferOrderRequest; +import com.squareup.square.types.ReceiveTransferOrderResponse; +import com.squareup.square.types.RetrieveTransferOrderResponse; +import com.squareup.square.types.SearchTransferOrdersRequest; +import com.squareup.square.types.SearchTransferOrdersResponse; +import com.squareup.square.types.StartTransferOrderRequest; +import com.squareup.square.types.StartTransferOrderResponse; +import com.squareup.square.types.TransferOrder; +import com.squareup.square.types.UpdateTransferOrderRequest; +import com.squareup.square.types.UpdateTransferOrderResponse; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTransferOrdersClient { + protected final ClientOptions clientOptions; + + public RawTransferOrdersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a new transfer order in DRAFT status. A transfer order represents the intent + * to move CatalogItemVariations from one Location to another. + * The source and destination locations must be different and must belong to your Square account. + *

    In DRAFT status, you can:

    + *
      + *
    • Add or remove items
    • + *
    • Modify quantities
    • + *
    • Update shipping information
    • + *
    • Delete the entire order via DeleteTransferOrder
    • + *
    + *

    The request requires source_location_id and destination_location_id. + * Inventory levels are not affected until the order is started via + * StartTransferOrder.

    + *

    Common integration points:

    + *
      + *
    • Sync with warehouse management systems
    • + *
    • Automate regular stock transfers
    • + *
    • Initialize transfers from inventory optimization systems
    • + *
    + *

    Creates a transfer_order.created webhook event.

    + */ + public SquareClientHttpResponse create(CreateTransferOrderRequest request) { + return create(request, null); + } + + /** + * Creates a new transfer order in DRAFT status. A transfer order represents the intent + * to move CatalogItemVariations from one Location to another. + * The source and destination locations must be different and must belong to your Square account. + *

    In DRAFT status, you can:

    + *
      + *
    • Add or remove items
    • + *
    • Modify quantities
    • + *
    • Update shipping information
    • + *
    • Delete the entire order via DeleteTransferOrder
    • + *
    + *

    The request requires source_location_id and destination_location_id. + * Inventory levels are not affected until the order is started via + * StartTransferOrder.

    + *

    Common integration points:

    + *
      + *
    • Sync with warehouse management systems
    • + *
    • Automate regular stock transfers
    • + *
    • Initialize transfers from inventory optimization systems
    • + *
    + *

    Creates a transfer_order.created webhook event.

    + */ + public SquareClientHttpResponse create( + CreateTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .build(); + 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) + .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(); + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateTransferOrderResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public SquareClientHttpResponse> search() { + return search(SearchTransferOrdersRequest.builder().build()); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public SquareClientHttpResponse> search(SearchTransferOrdersRequest request) { + return search(request, null); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public SquareClientHttpResponse> search( + SearchTransferOrdersRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders/search") + .build(); + 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) + .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(); + if (response.isSuccessful()) { + SearchTransferOrdersResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchTransferOrdersResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTransferOrdersRequest nextRequest = SearchTransferOrdersRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getTransferOrders().orElse(Collections.emptyList()); + return new SquareClientHttpResponse<>( + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + /** + * Retrieves a specific TransferOrder by ID. Returns the complete + * order details including: + *
      + *
    • Basic information (status, dates, notes)
    • + *
    • Line items with ordered and received quantities
    • + *
    • Source and destination Locations
    • + *
    • Tracking information (if available)
    • + *
    + */ + public SquareClientHttpResponse get(GetTransferOrdersRequest request) { + return get(request, null); + } + + /** + * Retrieves a specific TransferOrder by ID. Returns the complete + * order details including: + *
      + *
    • Basic information (status, dates, notes)
    • + *
    • Line items with ordered and received quantities
    • + *
    • Source and destination Locations
    • + *
    • Tracking information (if available)
    • + *
    + */ + public SquareClientHttpResponse get( + GetTransferOrdersRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.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(); + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RetrieveTransferOrderResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + /** + * Updates an existing transfer order. This endpoint supports sparse updates, + * allowing you to modify specific fields without affecting others. + *

    Creates a transfer_order.updated webhook event.

    + */ + public SquareClientHttpResponse update(UpdateTransferOrderRequest request) { + return update(request, null); + } + + /** + * Updates an existing transfer order. This endpoint supports sparse updates, + * allowing you to modify specific fields without affecting others. + *

    Creates a transfer_order.updated webhook event.

    + */ + public SquareClientHttpResponse update( + UpdateTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .build(); + 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) + .method("PUT", 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(); + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateTransferOrderResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + /** + * Deletes a transfer order in DRAFT status. + * Only draft orders can be deleted. Once an order is started via + * StartTransferOrder, it can no longer be deleted. + *

    Creates a transfer_order.deleted webhook event.

    + */ + public SquareClientHttpResponse delete(DeleteTransferOrdersRequest request) { + return delete(request, null); + } + + /** + * Deletes a transfer order in DRAFT status. + * Only draft orders can be deleted. Once an order is started via + * StartTransferOrder, it can no longer be deleted. + *

    Creates a transfer_order.deleted webhook event.

    + */ + public SquareClientHttpResponse delete( + DeleteTransferOrdersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()); + if (request.getVersion().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "version", request.getVersion().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.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(); + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteTransferOrderResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + /** + * Cancels a transfer order in STARTED or + * PARTIALLY_RECEIVED status. Any unreceived quantities will no + * longer be receivable and will be immediately returned to the source Location's inventory. + *

    Common reasons for cancellation:

    + *
      + *
    • Items no longer needed at destination
    • + *
    • Source location needs the inventory
    • + *
    • Order created in error
    • + *
    + *

    Creates a transfer_order.updated webhook event.

    + */ + public SquareClientHttpResponse cancel(CancelTransferOrderRequest request) { + return cancel(request, null); + } + + /** + * Cancels a transfer order in STARTED or + * PARTIALLY_RECEIVED status. Any unreceived quantities will no + * longer be receivable and will be immediately returned to the source Location's inventory. + *

    Common reasons for cancellation:

    + *
      + *
    • Items no longer needed at destination
    • + *
    • Source location needs the inventory
    • + *
    • Order created in error
    • + *
    + *

    Creates a transfer_order.updated webhook event.

    + */ + public SquareClientHttpResponse cancel( + CancelTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .addPathSegments("cancel") + .build(); + 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) + .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(); + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CancelTransferOrderResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + /** + * Records receipt of CatalogItemVariations for a transfer order. + * This endpoint supports partial receiving - you can receive items in multiple batches. + *

    For each line item, you can specify:

    + *
      + *
    • Quantity received in good condition (added to destination inventory with InventoryState of IN_STOCK)
    • + *
    • Quantity damaged during transit/handling (added to destination inventory with InventoryState of WASTE)
    • + *
    • Quantity canceled (returned to source location's inventory)
    • + *
    + *

    The order must be in STARTED or PARTIALLY_RECEIVED status. + * Received quantities are added to the destination Location's inventory according to their condition. + * Canceled quantities are immediately returned to the source Location's inventory.

    + *

    When all items are either received, damaged, or canceled, the order moves to + * COMPLETED status.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public SquareClientHttpResponse receive(ReceiveTransferOrderRequest request) { + return receive(request, null); + } + + /** + * Records receipt of CatalogItemVariations for a transfer order. + * This endpoint supports partial receiving - you can receive items in multiple batches. + *

    For each line item, you can specify:

    + *
      + *
    • Quantity received in good condition (added to destination inventory with InventoryState of IN_STOCK)
    • + *
    • Quantity damaged during transit/handling (added to destination inventory with InventoryState of WASTE)
    • + *
    • Quantity canceled (returned to source location's inventory)
    • + *
    + *

    The order must be in STARTED or PARTIALLY_RECEIVED status. + * Received quantities are added to the destination Location's inventory according to their condition. + * Canceled quantities are immediately returned to the source Location's inventory.

    + *

    When all items are either received, damaged, or canceled, the order moves to + * COMPLETED status.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public SquareClientHttpResponse receive( + ReceiveTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .addPathSegments("receive") + .build(); + 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) + .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(); + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReceiveTransferOrderResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } + + /** + * Changes a DRAFT transfer order to STARTED status. + * This decrements inventory at the source Location and marks it as in-transit. + *

    The order must be in DRAFT status and have all required fields populated. + * Once started, the order can no longer be deleted, but it can be canceled via + * CancelTransferOrder.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public SquareClientHttpResponse start(StartTransferOrderRequest request) { + return start(request, null); + } + + /** + * Changes a DRAFT transfer order to STARTED status. + * This decrements inventory at the source Location and marks it as in-transit. + *

    The order must be in DRAFT status and have all required fields populated. + * Once started, the order can no longer be deleted, but it can be canceled via + * CancelTransferOrder.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public SquareClientHttpResponse start( + StartTransferOrderRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/transfer-orders") + .addPathSegment(request.getTransferOrderId()) + .addPathSegments("start") + .build(); + 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) + .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(); + if (response.isSuccessful()) { + return new SquareClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), StartTransferOrderResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SquareApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new SquareException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/squareup/square/RawVendorsClient.java b/src/main/java/com/squareup/square/RawVendorsClient.java index eee42cf9..0c72caa2 100644 --- a/src/main/java/com/squareup/square/RawVendorsClient.java +++ b/src/main/java/com/squareup/square/RawVendorsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchCreateVendorsRequest; import com.squareup.square.types.BatchCreateVendorsResponse; import com.squareup.square.types.BatchGetVendorsRequest; @@ -25,7 +26,11 @@ import com.squareup.square.types.SearchVendorsResponse; import com.squareup.square.types.UpdateVendorResponse; import com.squareup.square.types.UpdateVendorsRequest; +import com.squareup.square.types.Vendor; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -259,21 +264,21 @@ public SquareClientHttpResponse create( /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchVendorsRequest.builder().build()); } /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public SquareClientHttpResponse search(SearchVendorsRequest request) { + public SquareClientHttpResponse> search(SearchVendorsRequest request) { return search(request, null); } /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchVendorsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -300,8 +305,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchVendorsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchVendorsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchVendorsRequest nextRequest = SearchVendorsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getVendors().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchVendorsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/SquareClient.java b/src/main/java/com/squareup/square/SquareClient.java index 1340e133..722d9a2e 100644 --- a/src/main/java/com/squareup/square/SquareClient.java +++ b/src/main/java/com/squareup/square/SquareClient.java @@ -28,6 +28,8 @@ public class SquareClient { protected final Supplier catalogClient; + protected final Supplier channelsClient; + protected final Supplier customersClient; protected final Supplier devicesClient; @@ -74,6 +76,8 @@ public class SquareClient { protected final Supplier terminalClient; + protected final Supplier transferOrdersClient; + protected final Supplier vendorsClient; protected final Supplier cashDrawersClient; @@ -90,6 +94,7 @@ public SquareClient(ClientOptions clientOptions) { this.bookingsClient = Suppliers.memoize(() -> new BookingsClient(clientOptions)); this.cardsClient = Suppliers.memoize(() -> new CardsClient(clientOptions)); this.catalogClient = Suppliers.memoize(() -> new CatalogClient(clientOptions)); + this.channelsClient = Suppliers.memoize(() -> new ChannelsClient(clientOptions)); this.customersClient = Suppliers.memoize(() -> new CustomersClient(clientOptions)); this.devicesClient = Suppliers.memoize(() -> new DevicesClient(clientOptions)); this.disputesClient = Suppliers.memoize(() -> new DisputesClient(clientOptions)); @@ -113,6 +118,7 @@ public SquareClient(ClientOptions clientOptions) { this.teamMembersClient = Suppliers.memoize(() -> new TeamMembersClient(clientOptions)); this.teamClient = Suppliers.memoize(() -> new TeamClient(clientOptions)); this.terminalClient = Suppliers.memoize(() -> new TerminalClient(clientOptions)); + this.transferOrdersClient = Suppliers.memoize(() -> new TransferOrdersClient(clientOptions)); this.vendorsClient = Suppliers.memoize(() -> new VendorsClient(clientOptions)); this.cashDrawersClient = Suppliers.memoize(() -> new CashDrawersClient(clientOptions)); this.webhooksClient = Suppliers.memoize(() -> new WebhooksClient(clientOptions)); @@ -150,6 +156,10 @@ public CatalogClient catalog() { return this.catalogClient.get(); } + public ChannelsClient channels() { + return this.channelsClient.get(); + } + public CustomersClient customers() { return this.customersClient.get(); } @@ -242,6 +252,10 @@ public TerminalClient terminal() { return this.terminalClient.get(); } + public TransferOrdersClient transferOrders() { + return this.transferOrdersClient.get(); + } + public VendorsClient vendors() { return this.vendorsClient.get(); } diff --git a/src/main/java/com/squareup/square/SquareClientBuilder.java b/src/main/java/com/squareup/square/SquareClientBuilder.java index 26026398..ae79625a 100644 --- a/src/main/java/com/squareup/square/SquareClientBuilder.java +++ b/src/main/java/com/squareup/square/SquareClientBuilder.java @@ -19,7 +19,7 @@ public class SquareClientBuilder { private String token = System.getenv("SQUARE_TOKEN"); - private String version = "2025-09-24"; + private String version = "2025-10-16"; private Environment environment = Environment.PRODUCTION; diff --git a/src/main/java/com/squareup/square/SubscriptionsClient.java b/src/main/java/com/squareup/square/SubscriptionsClient.java index 66c44b32..6b89918c 100644 --- a/src/main/java/com/squareup/square/SubscriptionsClient.java +++ b/src/main/java/com/squareup/square/SubscriptionsClient.java @@ -24,7 +24,7 @@ import com.squareup.square.types.ResumeSubscriptionRequest; import com.squareup.square.types.ResumeSubscriptionResponse; import com.squareup.square.types.SearchSubscriptionsRequest; -import com.squareup.square.types.SearchSubscriptionsResponse; +import com.squareup.square.types.Subscription; import com.squareup.square.types.SubscriptionEvent; import com.squareup.square.types.SwapPlanRequest; import com.squareup.square.types.SwapPlanResponse; @@ -102,7 +102,7 @@ public BulkSwapPlanResponse bulkSwapPlan(BulkSwapPlanRequest request, RequestOpt * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public SearchSubscriptionsResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } @@ -120,7 +120,7 @@ public SearchSubscriptionsResponse search() { * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public SearchSubscriptionsResponse search(SearchSubscriptionsRequest request) { + public SyncPagingIterable search(SearchSubscriptionsRequest request) { return this.rawClient.search(request).body(); } @@ -138,7 +138,7 @@ public SearchSubscriptionsResponse search(SearchSubscriptionsRequest request) { * first by location, within location by customer ID, and within * customer by subscription creation date.

    */ - public SearchSubscriptionsResponse search(SearchSubscriptionsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search(SearchSubscriptionsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/TeamMembersClient.java b/src/main/java/com/squareup/square/TeamMembersClient.java index ed299c13..6879a82f 100644 --- a/src/main/java/com/squareup/square/TeamMembersClient.java +++ b/src/main/java/com/squareup/square/TeamMembersClient.java @@ -6,6 +6,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; import com.squareup.square.core.Suppliers; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.teammembers.WageSettingClient; import com.squareup.square.types.BatchCreateTeamMembersRequest; import com.squareup.square.types.BatchCreateTeamMembersResponse; @@ -16,7 +17,7 @@ import com.squareup.square.types.GetTeamMemberResponse; import com.squareup.square.types.GetTeamMembersRequest; import com.squareup.square.types.SearchTeamMembersRequest; -import com.squareup.square.types.SearchTeamMembersResponse; +import com.squareup.square.types.TeamMember; import com.squareup.square.types.UpdateTeamMemberResponse; import com.squareup.square.types.UpdateTeamMembersRequest; import java.util.function.Supplier; @@ -131,7 +132,7 @@ public BatchUpdateTeamMembersResponse batchUpdate( * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public SearchTeamMembersResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } @@ -140,7 +141,7 @@ public SearchTeamMembersResponse search() { * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public SearchTeamMembersResponse search(SearchTeamMembersRequest request) { + public SyncPagingIterable search(SearchTeamMembersRequest request) { return this.rawClient.search(request).body(); } @@ -149,7 +150,7 @@ public SearchTeamMembersResponse search(SearchTeamMembersRequest request) { * The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether * the team member is the Square account owner. */ - public SearchTeamMembersResponse search(SearchTeamMembersRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search(SearchTeamMembersRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/TransferOrdersClient.java b/src/main/java/com/squareup/square/TransferOrdersClient.java new file mode 100644 index 00000000..72153370 --- /dev/null +++ b/src/main/java/com/squareup/square/TransferOrdersClient.java @@ -0,0 +1,299 @@ +/** + * 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.core.SyncPagingIterable; +import com.squareup.square.types.CancelTransferOrderRequest; +import com.squareup.square.types.CancelTransferOrderResponse; +import com.squareup.square.types.CreateTransferOrderRequest; +import com.squareup.square.types.CreateTransferOrderResponse; +import com.squareup.square.types.DeleteTransferOrderResponse; +import com.squareup.square.types.DeleteTransferOrdersRequest; +import com.squareup.square.types.GetTransferOrdersRequest; +import com.squareup.square.types.ReceiveTransferOrderRequest; +import com.squareup.square.types.ReceiveTransferOrderResponse; +import com.squareup.square.types.RetrieveTransferOrderResponse; +import com.squareup.square.types.SearchTransferOrdersRequest; +import com.squareup.square.types.StartTransferOrderRequest; +import com.squareup.square.types.StartTransferOrderResponse; +import com.squareup.square.types.TransferOrder; +import com.squareup.square.types.UpdateTransferOrderRequest; +import com.squareup.square.types.UpdateTransferOrderResponse; + +public class TransferOrdersClient { + protected final ClientOptions clientOptions; + + private final RawTransferOrdersClient rawClient; + + public TransferOrdersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawTransferOrdersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTransferOrdersClient withRawResponse() { + return this.rawClient; + } + + /** + * Creates a new transfer order in DRAFT status. A transfer order represents the intent + * to move CatalogItemVariations from one Location to another. + * The source and destination locations must be different and must belong to your Square account. + *

    In DRAFT status, you can:

    + *
      + *
    • Add or remove items
    • + *
    • Modify quantities
    • + *
    • Update shipping information
    • + *
    • Delete the entire order via DeleteTransferOrder
    • + *
    + *

    The request requires source_location_id and destination_location_id. + * Inventory levels are not affected until the order is started via + * StartTransferOrder.

    + *

    Common integration points:

    + *
      + *
    • Sync with warehouse management systems
    • + *
    • Automate regular stock transfers
    • + *
    • Initialize transfers from inventory optimization systems
    • + *
    + *

    Creates a transfer_order.created webhook event.

    + */ + public CreateTransferOrderResponse create(CreateTransferOrderRequest request) { + return this.rawClient.create(request).body(); + } + + /** + * Creates a new transfer order in DRAFT status. A transfer order represents the intent + * to move CatalogItemVariations from one Location to another. + * The source and destination locations must be different and must belong to your Square account. + *

    In DRAFT status, you can:

    + *
      + *
    • Add or remove items
    • + *
    • Modify quantities
    • + *
    • Update shipping information
    • + *
    • Delete the entire order via DeleteTransferOrder
    • + *
    + *

    The request requires source_location_id and destination_location_id. + * Inventory levels are not affected until the order is started via + * StartTransferOrder.

    + *

    Common integration points:

    + *
      + *
    • Sync with warehouse management systems
    • + *
    • Automate regular stock transfers
    • + *
    • Initialize transfers from inventory optimization systems
    • + *
    + *

    Creates a transfer_order.created webhook event.

    + */ + public CreateTransferOrderResponse create(CreateTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).body(); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public SyncPagingIterable search() { + return this.rawClient.search().body(); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public SyncPagingIterable search(SearchTransferOrdersRequest request) { + return this.rawClient.search(request).body(); + } + + /** + * Searches for transfer orders using filters. Returns a paginated list of matching + * TransferOrders sorted by creation date. + *

    Common search scenarios:

    + * + */ + public SyncPagingIterable search( + SearchTransferOrdersRequest request, RequestOptions requestOptions) { + return this.rawClient.search(request, requestOptions).body(); + } + + /** + * Retrieves a specific TransferOrder by ID. Returns the complete + * order details including: + *
      + *
    • Basic information (status, dates, notes)
    • + *
    • Line items with ordered and received quantities
    • + *
    • Source and destination Locations
    • + *
    • Tracking information (if available)
    • + *
    + */ + public RetrieveTransferOrderResponse get(GetTransferOrdersRequest request) { + return this.rawClient.get(request).body(); + } + + /** + * Retrieves a specific TransferOrder by ID. Returns the complete + * order details including: + *
      + *
    • Basic information (status, dates, notes)
    • + *
    • Line items with ordered and received quantities
    • + *
    • Source and destination Locations
    • + *
    • Tracking information (if available)
    • + *
    + */ + public RetrieveTransferOrderResponse get(GetTransferOrdersRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).body(); + } + + /** + * Updates an existing transfer order. This endpoint supports sparse updates, + * allowing you to modify specific fields without affecting others. + *

    Creates a transfer_order.updated webhook event.

    + */ + public UpdateTransferOrderResponse update(UpdateTransferOrderRequest request) { + return this.rawClient.update(request).body(); + } + + /** + * Updates an existing transfer order. This endpoint supports sparse updates, + * allowing you to modify specific fields without affecting others. + *

    Creates a transfer_order.updated webhook event.

    + */ + public UpdateTransferOrderResponse update(UpdateTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.update(request, requestOptions).body(); + } + + /** + * Deletes a transfer order in DRAFT status. + * Only draft orders can be deleted. Once an order is started via + * StartTransferOrder, it can no longer be deleted. + *

    Creates a transfer_order.deleted webhook event.

    + */ + public DeleteTransferOrderResponse delete(DeleteTransferOrdersRequest request) { + return this.rawClient.delete(request).body(); + } + + /** + * Deletes a transfer order in DRAFT status. + * Only draft orders can be deleted. Once an order is started via + * StartTransferOrder, it can no longer be deleted. + *

    Creates a transfer_order.deleted webhook event.

    + */ + public DeleteTransferOrderResponse delete(DeleteTransferOrdersRequest request, RequestOptions requestOptions) { + return this.rawClient.delete(request, requestOptions).body(); + } + + /** + * Cancels a transfer order in STARTED or + * PARTIALLY_RECEIVED status. Any unreceived quantities will no + * longer be receivable and will be immediately returned to the source Location's inventory. + *

    Common reasons for cancellation:

    + *
      + *
    • Items no longer needed at destination
    • + *
    • Source location needs the inventory
    • + *
    • Order created in error
    • + *
    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CancelTransferOrderResponse cancel(CancelTransferOrderRequest request) { + return this.rawClient.cancel(request).body(); + } + + /** + * Cancels a transfer order in STARTED or + * PARTIALLY_RECEIVED status. Any unreceived quantities will no + * longer be receivable and will be immediately returned to the source Location's inventory. + *

    Common reasons for cancellation:

    + *
      + *
    • Items no longer needed at destination
    • + *
    • Source location needs the inventory
    • + *
    • Order created in error
    • + *
    + *

    Creates a transfer_order.updated webhook event.

    + */ + public CancelTransferOrderResponse cancel(CancelTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.cancel(request, requestOptions).body(); + } + + /** + * Records receipt of CatalogItemVariations for a transfer order. + * This endpoint supports partial receiving - you can receive items in multiple batches. + *

    For each line item, you can specify:

    + *
      + *
    • Quantity received in good condition (added to destination inventory with InventoryState of IN_STOCK)
    • + *
    • Quantity damaged during transit/handling (added to destination inventory with InventoryState of WASTE)
    • + *
    • Quantity canceled (returned to source location's inventory)
    • + *
    + *

    The order must be in STARTED or PARTIALLY_RECEIVED status. + * Received quantities are added to the destination Location's inventory according to their condition. + * Canceled quantities are immediately returned to the source Location's inventory.

    + *

    When all items are either received, damaged, or canceled, the order moves to + * COMPLETED status.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public ReceiveTransferOrderResponse receive(ReceiveTransferOrderRequest request) { + return this.rawClient.receive(request).body(); + } + + /** + * Records receipt of CatalogItemVariations for a transfer order. + * This endpoint supports partial receiving - you can receive items in multiple batches. + *

    For each line item, you can specify:

    + *
      + *
    • Quantity received in good condition (added to destination inventory with InventoryState of IN_STOCK)
    • + *
    • Quantity damaged during transit/handling (added to destination inventory with InventoryState of WASTE)
    • + *
    • Quantity canceled (returned to source location's inventory)
    • + *
    + *

    The order must be in STARTED or PARTIALLY_RECEIVED status. + * Received quantities are added to the destination Location's inventory according to their condition. + * Canceled quantities are immediately returned to the source Location's inventory.

    + *

    When all items are either received, damaged, or canceled, the order moves to + * COMPLETED status.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public ReceiveTransferOrderResponse receive(ReceiveTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.receive(request, requestOptions).body(); + } + + /** + * Changes a DRAFT transfer order to STARTED status. + * This decrements inventory at the source Location and marks it as in-transit. + *

    The order must be in DRAFT status and have all required fields populated. + * Once started, the order can no longer be deleted, but it can be canceled via + * CancelTransferOrder.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public StartTransferOrderResponse start(StartTransferOrderRequest request) { + return this.rawClient.start(request).body(); + } + + /** + * Changes a DRAFT transfer order to STARTED status. + * This decrements inventory at the source Location and marks it as in-transit. + *

    The order must be in DRAFT status and have all required fields populated. + * Once started, the order can no longer be deleted, but it can be canceled via + * CancelTransferOrder.

    + *

    Creates a transfer_order.updated webhook event.

    + */ + public StartTransferOrderResponse start(StartTransferOrderRequest request, RequestOptions requestOptions) { + return this.rawClient.start(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/squareup/square/VendorsClient.java b/src/main/java/com/squareup/square/VendorsClient.java index fe4e7880..140e9c5f 100644 --- a/src/main/java/com/squareup/square/VendorsClient.java +++ b/src/main/java/com/squareup/square/VendorsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.types.BatchCreateVendorsRequest; import com.squareup.square.types.BatchCreateVendorsResponse; import com.squareup.square.types.BatchGetVendorsRequest; @@ -16,9 +17,9 @@ import com.squareup.square.types.GetVendorResponse; import com.squareup.square.types.GetVendorsRequest; import com.squareup.square.types.SearchVendorsRequest; -import com.squareup.square.types.SearchVendorsResponse; import com.squareup.square.types.UpdateVendorResponse; import com.squareup.square.types.UpdateVendorsRequest; +import com.squareup.square.types.Vendor; public class VendorsClient { protected final ClientOptions clientOptions; @@ -103,21 +104,21 @@ public CreateVendorResponse create(CreateVendorRequest request, RequestOptions r /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public SearchVendorsResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public SearchVendorsResponse search(SearchVendorsRequest request) { + public SyncPagingIterable search(SearchVendorsRequest request) { return this.rawClient.search(request).body(); } /** * Searches for vendors using a filter against supported Vendor properties and a supported sorter. */ - public SearchVendorsResponse search(SearchVendorsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search(SearchVendorsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/core/ClientOptions.java b/src/main/java/com/squareup/square/core/ClientOptions.java index 3ff46663..0960b301 100644 --- a/src/main/java/com/squareup/square/core/ClientOptions.java +++ b/src/main/java/com/squareup/square/core/ClientOptions.java @@ -32,10 +32,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.squareup:square/45.0.0.20250924"); + put("User-Agent", "com.squareup:square/45.1.0.20251016"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.square.fern:api-sdk"); - put("X-Fern-SDK-Version", "45.0.0.20250924"); + put("X-Fern-SDK-Version", "45.1.0.20251016"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/squareup/square/labor/AsyncRawShiftsClient.java b/src/main/java/com/squareup/square/labor/AsyncRawShiftsClient.java index a617eaa5..d54fe35b 100644 --- a/src/main/java/com/squareup/square/labor/AsyncRawShiftsClient.java +++ b/src/main/java/com/squareup/square/labor/AsyncRawShiftsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.labor.types.CreateShiftRequest; import com.squareup.square.labor.types.DeleteShiftsRequest; import com.squareup.square.labor.types.GetShiftsRequest; @@ -20,9 +21,14 @@ import com.squareup.square.types.DeleteShiftResponse; import com.squareup.square.types.GetShiftResponse; import com.squareup.square.types.SearchShiftsResponse; +import com.squareup.square.types.Shift; import com.squareup.square.types.UpdateShiftResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -161,7 +167,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *
  • UPDATED_AT
  • * */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchShiftsRequest.builder().build()); } @@ -184,7 +190,7 @@ public CompletableFuture> search( *
  • UPDATED_AT
  • * */ - public CompletableFuture> search(SearchShiftsRequest request) { + public CompletableFuture>> search(SearchShiftsRequest request) { return search(request, null); } @@ -207,7 +213,7 @@ public CompletableFuture> search( *
  • UPDATED_AT
  • * */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchShiftsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -231,14 +237,30 @@ public CompletableFuture> search( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchShiftsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchShiftsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchShiftsRequest nextRequest = SearchShiftsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getShifts().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchShiftsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/labor/AsyncShiftsClient.java b/src/main/java/com/squareup/square/labor/AsyncShiftsClient.java index a76f660a..ee603628 100644 --- a/src/main/java/com/squareup/square/labor/AsyncShiftsClient.java +++ b/src/main/java/com/squareup/square/labor/AsyncShiftsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.labor.types.CreateShiftRequest; import com.squareup.square.labor.types.DeleteShiftsRequest; import com.squareup.square.labor.types.GetShiftsRequest; @@ -13,7 +14,7 @@ import com.squareup.square.types.CreateShiftResponse; import com.squareup.square.types.DeleteShiftResponse; import com.squareup.square.types.GetShiftResponse; -import com.squareup.square.types.SearchShiftsResponse; +import com.squareup.square.types.Shift; import com.squareup.square.types.UpdateShiftResponse; import java.util.concurrent.CompletableFuture; @@ -103,7 +104,7 @@ public CompletableFuture create(CreateShiftRequest request, *
  • UPDATED_AT
  • * */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } @@ -126,7 +127,7 @@ public CompletableFuture search() { *
  • UPDATED_AT
  • * */ - public CompletableFuture search(SearchShiftsRequest request) { + public CompletableFuture> search(SearchShiftsRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -149,7 +150,8 @@ public CompletableFuture search(SearchShiftsRequest reques *
  • UPDATED_AT
  • * */ - public CompletableFuture search(SearchShiftsRequest request, RequestOptions requestOptions) { + public CompletableFuture> search( + SearchShiftsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/labor/RawShiftsClient.java b/src/main/java/com/squareup/square/labor/RawShiftsClient.java index cb7387e1..31e6f908 100644 --- a/src/main/java/com/squareup/square/labor/RawShiftsClient.java +++ b/src/main/java/com/squareup/square/labor/RawShiftsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.labor.types.CreateShiftRequest; import com.squareup.square.labor.types.DeleteShiftsRequest; import com.squareup.square.labor.types.GetShiftsRequest; @@ -20,8 +21,12 @@ import com.squareup.square.types.DeleteShiftResponse; import com.squareup.square.types.GetShiftResponse; import com.squareup.square.types.SearchShiftsResponse; +import com.squareup.square.types.Shift; import com.squareup.square.types.UpdateShiftResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -144,7 +149,7 @@ public SquareClientHttpResponse create( *
  • UPDATED_AT
  • * */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchShiftsRequest.builder().build()); } @@ -167,7 +172,7 @@ public SquareClientHttpResponse search() { *
  • UPDATED_AT
  • * */ - public SquareClientHttpResponse search(SearchShiftsRequest request) { + public SquareClientHttpResponse> search(SearchShiftsRequest request) { return search(request, null); } @@ -190,7 +195,7 @@ public SquareClientHttpResponse search(SearchShiftsRequest *
  • UPDATED_AT
  • * */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchShiftsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -217,8 +222,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchShiftsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchShiftsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchShiftsRequest nextRequest = SearchShiftsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getShifts().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchShiftsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/labor/ShiftsClient.java b/src/main/java/com/squareup/square/labor/ShiftsClient.java index 23c8ee45..838e198d 100644 --- a/src/main/java/com/squareup/square/labor/ShiftsClient.java +++ b/src/main/java/com/squareup/square/labor/ShiftsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.labor.types.CreateShiftRequest; import com.squareup.square.labor.types.DeleteShiftsRequest; import com.squareup.square.labor.types.GetShiftsRequest; @@ -13,7 +14,7 @@ import com.squareup.square.types.CreateShiftResponse; import com.squareup.square.types.DeleteShiftResponse; import com.squareup.square.types.GetShiftResponse; -import com.squareup.square.types.SearchShiftsResponse; +import com.squareup.square.types.Shift; import com.squareup.square.types.UpdateShiftResponse; public class ShiftsClient { @@ -102,7 +103,7 @@ public CreateShiftResponse create(CreateShiftRequest request, RequestOptions req *
  • UPDATED_AT
  • * */ - public SearchShiftsResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } @@ -125,7 +126,7 @@ public SearchShiftsResponse search() { *
  • UPDATED_AT
  • * */ - public SearchShiftsResponse search(SearchShiftsRequest request) { + public SyncPagingIterable search(SearchShiftsRequest request) { return this.rawClient.search(request).body(); } @@ -148,7 +149,7 @@ public SearchShiftsResponse search(SearchShiftsRequest request) { *
  • UPDATED_AT
  • * */ - public SearchShiftsResponse search(SearchShiftsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search(SearchShiftsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/loyalty/AccountsClient.java b/src/main/java/com/squareup/square/loyalty/AccountsClient.java index e74105fe..3774be65 100644 --- a/src/main/java/com/squareup/square/loyalty/AccountsClient.java +++ b/src/main/java/com/squareup/square/loyalty/AccountsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.types.AccumulateLoyaltyPointsRequest; import com.squareup.square.loyalty.types.AdjustLoyaltyPointsRequest; import com.squareup.square.loyalty.types.CreateLoyaltyAccountRequest; @@ -14,7 +15,7 @@ import com.squareup.square.types.AdjustLoyaltyPointsResponse; import com.squareup.square.types.CreateLoyaltyAccountResponse; import com.squareup.square.types.GetLoyaltyAccountResponse; -import com.squareup.square.types.SearchLoyaltyAccountsResponse; +import com.squareup.square.types.LoyaltyAccount; public class AccountsClient { protected final ClientOptions clientOptions; @@ -52,7 +53,7 @@ public CreateLoyaltyAccountResponse create(CreateLoyaltyAccountRequest request, *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public SearchLoyaltyAccountsResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } @@ -61,7 +62,7 @@ public SearchLoyaltyAccountsResponse search() { *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public SearchLoyaltyAccountsResponse search(SearchLoyaltyAccountsRequest request) { + public SyncPagingIterable search(SearchLoyaltyAccountsRequest request) { return this.rawClient.search(request).body(); } @@ -70,7 +71,8 @@ public SearchLoyaltyAccountsResponse search(SearchLoyaltyAccountsRequest request *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public SearchLoyaltyAccountsResponse search(SearchLoyaltyAccountsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search( + SearchLoyaltyAccountsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/loyalty/AsyncAccountsClient.java b/src/main/java/com/squareup/square/loyalty/AsyncAccountsClient.java index 02bac252..f3530776 100644 --- a/src/main/java/com/squareup/square/loyalty/AsyncAccountsClient.java +++ b/src/main/java/com/squareup/square/loyalty/AsyncAccountsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.types.AccumulateLoyaltyPointsRequest; import com.squareup.square.loyalty.types.AdjustLoyaltyPointsRequest; import com.squareup.square.loyalty.types.CreateLoyaltyAccountRequest; @@ -14,7 +15,7 @@ import com.squareup.square.types.AdjustLoyaltyPointsResponse; import com.squareup.square.types.CreateLoyaltyAccountResponse; import com.squareup.square.types.GetLoyaltyAccountResponse; -import com.squareup.square.types.SearchLoyaltyAccountsResponse; +import com.squareup.square.types.LoyaltyAccount; import java.util.concurrent.CompletableFuture; public class AsyncAccountsClient { @@ -54,7 +55,7 @@ public CompletableFuture create( *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } @@ -63,7 +64,7 @@ public CompletableFuture search() { *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public CompletableFuture search(SearchLoyaltyAccountsRequest request) { + public CompletableFuture> search(SearchLoyaltyAccountsRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -72,7 +73,7 @@ public CompletableFuture search(SearchLoyaltyAcco *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public CompletableFuture search( + public CompletableFuture> search( SearchLoyaltyAccountsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/loyalty/AsyncRawAccountsClient.java b/src/main/java/com/squareup/square/loyalty/AsyncRawAccountsClient.java index d59c6aaa..a176e20a 100644 --- a/src/main/java/com/squareup/square/loyalty/AsyncRawAccountsClient.java +++ b/src/main/java/com/squareup/square/loyalty/AsyncRawAccountsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.types.AccumulateLoyaltyPointsRequest; import com.squareup.square.loyalty.types.AdjustLoyaltyPointsRequest; import com.squareup.square.loyalty.types.CreateLoyaltyAccountRequest; @@ -20,9 +21,14 @@ import com.squareup.square.types.AdjustLoyaltyPointsResponse; import com.squareup.square.types.CreateLoyaltyAccountResponse; import com.squareup.square.types.GetLoyaltyAccountResponse; +import com.squareup.square.types.LoyaltyAccount; import com.squareup.square.types.SearchLoyaltyAccountsResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -113,7 +119,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchLoyaltyAccountsRequest.builder().build()); } @@ -122,7 +128,7 @@ public CompletableFuture *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchLoyaltyAccountsRequest request) { return search(request, null); } @@ -132,7 +138,7 @@ public CompletableFuture *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchLoyaltyAccountsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -156,15 +162,32 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchLoyaltyAccountsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchLoyaltyAccountsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchLoyaltyAccountsRequest nextRequest = SearchLoyaltyAccountsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = + parsedResponse.getLoyaltyAccounts().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchLoyaltyAccountsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/loyalty/AsyncRawRewardsClient.java b/src/main/java/com/squareup/square/loyalty/AsyncRawRewardsClient.java index 6cfc17da..48c9bedd 100644 --- a/src/main/java/com/squareup/square/loyalty/AsyncRawRewardsClient.java +++ b/src/main/java/com/squareup/square/loyalty/AsyncRawRewardsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.types.CreateLoyaltyRewardRequest; import com.squareup.square.loyalty.types.DeleteRewardsRequest; import com.squareup.square.loyalty.types.GetRewardsRequest; @@ -19,10 +20,15 @@ import com.squareup.square.types.CreateLoyaltyRewardResponse; import com.squareup.square.types.DeleteLoyaltyRewardResponse; import com.squareup.square.types.GetLoyaltyRewardResponse; +import com.squareup.square.types.LoyaltyReward; import com.squareup.square.types.RedeemLoyaltyRewardResponse; import com.squareup.square.types.SearchLoyaltyRewardsResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -129,7 +135,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchLoyaltyRewardsRequest.builder().build()); } @@ -140,7 +146,7 @@ public CompletableFuture> * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchLoyaltyRewardsRequest request) { return search(request, null); } @@ -152,7 +158,7 @@ public CompletableFuture> * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchLoyaltyRewardsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -176,15 +182,31 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchLoyaltyRewardsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchLoyaltyRewardsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchLoyaltyRewardsRequest nextRequest = SearchLoyaltyRewardsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getRewards().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchLoyaltyRewardsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/loyalty/AsyncRewardsClient.java b/src/main/java/com/squareup/square/loyalty/AsyncRewardsClient.java index 856c5c2c..850a6257 100644 --- a/src/main/java/com/squareup/square/loyalty/AsyncRewardsClient.java +++ b/src/main/java/com/squareup/square/loyalty/AsyncRewardsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.types.CreateLoyaltyRewardRequest; import com.squareup.square.loyalty.types.DeleteRewardsRequest; import com.squareup.square.loyalty.types.GetRewardsRequest; @@ -13,8 +14,8 @@ import com.squareup.square.types.CreateLoyaltyRewardResponse; import com.squareup.square.types.DeleteLoyaltyRewardResponse; import com.squareup.square.types.GetLoyaltyRewardResponse; +import com.squareup.square.types.LoyaltyReward; import com.squareup.square.types.RedeemLoyaltyRewardResponse; -import com.squareup.square.types.SearchLoyaltyRewardsResponse; import java.util.concurrent.CompletableFuture; public class AsyncRewardsClient { @@ -70,7 +71,7 @@ public CompletableFuture create( * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } @@ -81,7 +82,7 @@ public CompletableFuture search() { * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public CompletableFuture search(SearchLoyaltyRewardsRequest request) { + public CompletableFuture> search(SearchLoyaltyRewardsRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -92,7 +93,7 @@ public CompletableFuture search(SearchLoyaltyRewar * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public CompletableFuture search( + public CompletableFuture> search( SearchLoyaltyRewardsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/loyalty/RawAccountsClient.java b/src/main/java/com/squareup/square/loyalty/RawAccountsClient.java index 739c3cbc..ed651215 100644 --- a/src/main/java/com/squareup/square/loyalty/RawAccountsClient.java +++ b/src/main/java/com/squareup/square/loyalty/RawAccountsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.types.AccumulateLoyaltyPointsRequest; import com.squareup.square.loyalty.types.AdjustLoyaltyPointsRequest; import com.squareup.square.loyalty.types.CreateLoyaltyAccountRequest; @@ -20,8 +21,12 @@ import com.squareup.square.types.AdjustLoyaltyPointsResponse; import com.squareup.square.types.CreateLoyaltyAccountResponse; import com.squareup.square.types.GetLoyaltyAccountResponse; +import com.squareup.square.types.LoyaltyAccount; import com.squareup.square.types.SearchLoyaltyAccountsResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -94,7 +99,7 @@ public SquareClientHttpResponse create( *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchLoyaltyAccountsRequest.builder().build()); } @@ -103,7 +108,7 @@ public SquareClientHttpResponse search() { *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public SquareClientHttpResponse search(SearchLoyaltyAccountsRequest request) { + public SquareClientHttpResponse> search(SearchLoyaltyAccountsRequest request) { return search(request, null); } @@ -112,7 +117,7 @@ public SquareClientHttpResponse search(SearchLoya *

    You can search for a loyalty account using the phone number or customer ID associated with the account. To return all loyalty accounts, specify an empty query object or omit it entirely.

    *

    Search results are sorted by created_at in ascending order.

    */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchLoyaltyAccountsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -139,8 +144,19 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchLoyaltyAccountsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchLoyaltyAccountsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchLoyaltyAccountsRequest nextRequest = SearchLoyaltyAccountsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = + parsedResponse.getLoyaltyAccounts().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchLoyaltyAccountsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/loyalty/RawRewardsClient.java b/src/main/java/com/squareup/square/loyalty/RawRewardsClient.java index 6e023c40..af32a476 100644 --- a/src/main/java/com/squareup/square/loyalty/RawRewardsClient.java +++ b/src/main/java/com/squareup/square/loyalty/RawRewardsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.types.CreateLoyaltyRewardRequest; import com.squareup.square.loyalty.types.DeleteRewardsRequest; import com.squareup.square.loyalty.types.GetRewardsRequest; @@ -19,9 +20,13 @@ import com.squareup.square.types.CreateLoyaltyRewardResponse; import com.squareup.square.types.DeleteLoyaltyRewardResponse; import com.squareup.square.types.GetLoyaltyRewardResponse; +import com.squareup.square.types.LoyaltyReward; import com.squareup.square.types.RedeemLoyaltyRewardResponse; import com.squareup.square.types.SearchLoyaltyRewardsResponse; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -110,7 +115,7 @@ public SquareClientHttpResponse create( * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchLoyaltyRewardsRequest.builder().build()); } @@ -121,7 +126,7 @@ public SquareClientHttpResponse search() { * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public SquareClientHttpResponse search(SearchLoyaltyRewardsRequest request) { + public SquareClientHttpResponse> search(SearchLoyaltyRewardsRequest request) { return search(request, null); } @@ -132,7 +137,7 @@ public SquareClientHttpResponse search(SearchLoyal * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchLoyaltyRewardsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -159,8 +164,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchLoyaltyRewardsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchLoyaltyRewardsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchLoyaltyRewardsRequest nextRequest = SearchLoyaltyRewardsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getRewards().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchLoyaltyRewardsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/loyalty/RewardsClient.java b/src/main/java/com/squareup/square/loyalty/RewardsClient.java index 00f7e5e0..2dd457e8 100644 --- a/src/main/java/com/squareup/square/loyalty/RewardsClient.java +++ b/src/main/java/com/squareup/square/loyalty/RewardsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.loyalty.types.CreateLoyaltyRewardRequest; import com.squareup.square.loyalty.types.DeleteRewardsRequest; import com.squareup.square.loyalty.types.GetRewardsRequest; @@ -13,8 +14,8 @@ import com.squareup.square.types.CreateLoyaltyRewardResponse; import com.squareup.square.types.DeleteLoyaltyRewardResponse; import com.squareup.square.types.GetLoyaltyRewardResponse; +import com.squareup.square.types.LoyaltyReward; import com.squareup.square.types.RedeemLoyaltyRewardResponse; -import com.squareup.square.types.SearchLoyaltyRewardsResponse; public class RewardsClient { protected final ClientOptions clientOptions; @@ -68,7 +69,7 @@ public CreateLoyaltyRewardResponse create(CreateLoyaltyRewardRequest request, Re * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public SearchLoyaltyRewardsResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } @@ -79,7 +80,7 @@ public SearchLoyaltyRewardsResponse search() { * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public SearchLoyaltyRewardsResponse search(SearchLoyaltyRewardsRequest request) { + public SyncPagingIterable search(SearchLoyaltyRewardsRequest request) { return this.rawClient.search(request).body(); } @@ -90,7 +91,8 @@ public SearchLoyaltyRewardsResponse search(SearchLoyaltyRewardsRequest request) * RetrieveLoyaltyReward endpoint.

    *

    Search results are sorted by updated_at in descending order.

    */ - public SearchLoyaltyRewardsResponse search(SearchLoyaltyRewardsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search( + SearchLoyaltyRewardsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/loyalty/programs/types/CancelPromotionsRequest.java b/src/main/java/com/squareup/square/loyalty/programs/types/CancelPromotionsRequest.java index 198b6525..1dff3b15 100644 --- a/src/main/java/com/squareup/square/loyalty/programs/types/CancelPromotionsRequest.java +++ b/src/main/java/com/squareup/square/loyalty/programs/types/CancelPromotionsRequest.java @@ -19,18 +19,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CancelPromotionsRequest.Builder.class) public final class CancelPromotionsRequest { - private final String promotionId; - private final String programId; + private final String promotionId; + private final Map additionalProperties; - private CancelPromotionsRequest(String promotionId, String programId, Map additionalProperties) { - this.promotionId = promotionId; + private CancelPromotionsRequest(String programId, String promotionId, Map additionalProperties) { this.programId = programId; + this.promotionId = promotionId; this.additionalProperties = additionalProperties; } + /** + * @return The ID of the base loyalty program. + */ + @JsonProperty("program_id") + public String getProgramId() { + return programId; + } + /** * @return The ID of the loyalty promotion to cancel. You can cancel a * promotion that has an ACTIVE or SCHEDULED status. @@ -40,14 +48,6 @@ public String getPromotionId() { return promotionId; } - /** - * @return The ID of the base loyalty program. - */ - @JsonProperty("program_id") - public String getProgramId() { - return programId; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -60,12 +60,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(CancelPromotionsRequest other) { - return promotionId.equals(other.promotionId) && programId.equals(other.programId); + return programId.equals(other.programId) && promotionId.equals(other.promotionId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.promotionId, this.programId); + return Objects.hash(this.programId, this.promotionId); } @java.lang.Override @@ -73,25 +73,25 @@ public String toString() { return ObjectMappers.stringify(this); } - public static PromotionIdStage builder() { + public static ProgramIdStage builder() { return new Builder(); } - public interface PromotionIdStage { + public interface ProgramIdStage { /** - *

    The ID of the loyalty promotion to cancel. You can cancel a - * promotion that has an ACTIVE or SCHEDULED status.

    + *

    The ID of the base loyalty program.

    */ - ProgramIdStage promotionId(@NotNull String promotionId); + PromotionIdStage programId(@NotNull String programId); Builder from(CancelPromotionsRequest other); } - public interface ProgramIdStage { + public interface PromotionIdStage { /** - *

    The ID of the base loyalty program.

    + *

    The ID of the loyalty promotion to cancel. You can cancel a + * promotion that has an ACTIVE or SCHEDULED status.

    */ - _FinalStage programId(@NotNull String programId); + _FinalStage promotionId(@NotNull String promotionId); } public interface _FinalStage { @@ -99,11 +99,11 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PromotionIdStage, ProgramIdStage, _FinalStage { - private String promotionId; - + public static final class Builder implements ProgramIdStage, PromotionIdStage, _FinalStage { private String programId; + private String promotionId; + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -111,40 +111,40 @@ private Builder() {} @java.lang.Override public Builder from(CancelPromotionsRequest other) { - promotionId(other.getPromotionId()); programId(other.getProgramId()); + promotionId(other.getPromotionId()); return this; } /** - *

    The ID of the loyalty promotion to cancel. You can cancel a - * promotion that has an ACTIVE or SCHEDULED status.

    - *

    The ID of the loyalty promotion to cancel. You can cancel a - * promotion that has an ACTIVE or SCHEDULED status.

    + *

    The ID of the base loyalty program.

    + *

    The ID of the base loyalty program.

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

    The ID of the base loyalty program.

    - *

    The ID of the base loyalty program.

    + *

    The ID of the loyalty promotion to cancel. You can cancel a + * promotion that has an ACTIVE or SCHEDULED status.

    + *

    The ID of the loyalty promotion to cancel. You can cancel a + * promotion that has an ACTIVE or SCHEDULED status.

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("program_id") - public _FinalStage programId(@NotNull String programId) { - this.programId = Objects.requireNonNull(programId, "programId must not be null"); + @JsonSetter("promotion_id") + public _FinalStage promotionId(@NotNull String promotionId) { + this.promotionId = Objects.requireNonNull(promotionId, "promotionId must not be null"); return this; } @java.lang.Override public CancelPromotionsRequest build() { - return new CancelPromotionsRequest(promotionId, programId, additionalProperties); + return new CancelPromotionsRequest(programId, promotionId, additionalProperties); } } } diff --git a/src/main/java/com/squareup/square/loyalty/programs/types/GetPromotionsRequest.java b/src/main/java/com/squareup/square/loyalty/programs/types/GetPromotionsRequest.java index 82dcd4e4..3935590a 100644 --- a/src/main/java/com/squareup/square/loyalty/programs/types/GetPromotionsRequest.java +++ b/src/main/java/com/squareup/square/loyalty/programs/types/GetPromotionsRequest.java @@ -19,26 +19,18 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GetPromotionsRequest.Builder.class) public final class GetPromotionsRequest { - private final String promotionId; - private final String programId; + private final String promotionId; + private final Map additionalProperties; - private GetPromotionsRequest(String promotionId, String programId, Map additionalProperties) { - this.promotionId = promotionId; + private GetPromotionsRequest(String programId, String promotionId, Map additionalProperties) { this.programId = programId; + this.promotionId = promotionId; this.additionalProperties = additionalProperties; } - /** - * @return The ID of the loyalty promotion to retrieve. - */ - @JsonProperty("promotion_id") - public String getPromotionId() { - return promotionId; - } - /** * @return The ID of the base loyalty program. To get the program ID, * call RetrieveLoyaltyProgram using the main keyword. @@ -48,6 +40,14 @@ public String getProgramId() { return programId; } + /** + * @return The ID of the loyalty promotion to retrieve. + */ + @JsonProperty("promotion_id") + public String getPromotionId() { + return promotionId; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -60,12 +60,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(GetPromotionsRequest other) { - return promotionId.equals(other.promotionId) && programId.equals(other.programId); + return programId.equals(other.programId) && promotionId.equals(other.promotionId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.promotionId, this.programId); + return Objects.hash(this.programId, this.promotionId); } @java.lang.Override @@ -73,25 +73,25 @@ public String toString() { return ObjectMappers.stringify(this); } - public static PromotionIdStage builder() { + public static ProgramIdStage builder() { return new Builder(); } - public interface PromotionIdStage { + public interface ProgramIdStage { /** - *

    The ID of the loyalty promotion to retrieve.

    + *

    The ID of the base loyalty program. To get the program ID, + * call RetrieveLoyaltyProgram using the main keyword.

    */ - ProgramIdStage promotionId(@NotNull String promotionId); + PromotionIdStage programId(@NotNull String programId); Builder from(GetPromotionsRequest other); } - public interface ProgramIdStage { + public interface PromotionIdStage { /** - *

    The ID of the base loyalty program. To get the program ID, - * call RetrieveLoyaltyProgram using the main keyword.

    + *

    The ID of the loyalty promotion to retrieve.

    */ - _FinalStage programId(@NotNull String programId); + _FinalStage promotionId(@NotNull String promotionId); } public interface _FinalStage { @@ -99,11 +99,11 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PromotionIdStage, ProgramIdStage, _FinalStage { - private String promotionId; - + public static final class Builder implements ProgramIdStage, PromotionIdStage, _FinalStage { private String programId; + private String promotionId; + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -111,40 +111,40 @@ private Builder() {} @java.lang.Override public Builder from(GetPromotionsRequest other) { - promotionId(other.getPromotionId()); programId(other.getProgramId()); + promotionId(other.getPromotionId()); return this; } /** - *

    The ID of the loyalty promotion to retrieve.

    - *

    The ID of the loyalty promotion to retrieve.

    + *

    The ID of the base loyalty program. To get the program ID, + * call RetrieveLoyaltyProgram using the main keyword.

    + *

    The ID of the base loyalty program. To get the program ID, + * call RetrieveLoyaltyProgram using the main keyword.

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

    The ID of the base loyalty program. To get the program ID, - * call RetrieveLoyaltyProgram using the main keyword.

    - *

    The ID of the base loyalty program. To get the program ID, - * call RetrieveLoyaltyProgram using the main keyword.

    + *

    The ID of the loyalty promotion to retrieve.

    + *

    The ID of the loyalty promotion to retrieve.

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("program_id") - public _FinalStage programId(@NotNull String programId) { - this.programId = Objects.requireNonNull(programId, "programId must not be null"); + @JsonSetter("promotion_id") + public _FinalStage promotionId(@NotNull String promotionId) { + this.promotionId = Objects.requireNonNull(promotionId, "promotionId must not be null"); return this; } @java.lang.Override public GetPromotionsRequest build() { - return new GetPromotionsRequest(promotionId, programId, additionalProperties); + return new GetPromotionsRequest(programId, promotionId, additionalProperties); } } } diff --git a/src/main/java/com/squareup/square/terminal/ActionsClient.java b/src/main/java/com/squareup/square/terminal/ActionsClient.java index 3f481bbc..57e2377d 100644 --- a/src/main/java/com/squareup/square/terminal/ActionsClient.java +++ b/src/main/java/com/squareup/square/terminal/ActionsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelActionsRequest; import com.squareup.square.terminal.types.CreateTerminalActionRequest; import com.squareup.square.terminal.types.GetActionsRequest; @@ -12,7 +13,7 @@ import com.squareup.square.types.CancelTerminalActionResponse; import com.squareup.square.types.CreateTerminalActionResponse; import com.squareup.square.types.GetTerminalActionResponse; -import com.squareup.square.types.SearchTerminalActionsResponse; +import com.squareup.square.types.TerminalAction; public class ActionsClient { protected final ClientOptions clientOptions; @@ -48,21 +49,22 @@ public CreateTerminalActionResponse create(CreateTerminalActionRequest request, /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public SearchTerminalActionsResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public SearchTerminalActionsResponse search(SearchTerminalActionsRequest request) { + public SyncPagingIterable search(SearchTerminalActionsRequest request) { return this.rawClient.search(request).body(); } /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public SearchTerminalActionsResponse search(SearchTerminalActionsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search( + SearchTerminalActionsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/terminal/AsyncActionsClient.java b/src/main/java/com/squareup/square/terminal/AsyncActionsClient.java index be6c7745..c5af078e 100644 --- a/src/main/java/com/squareup/square/terminal/AsyncActionsClient.java +++ b/src/main/java/com/squareup/square/terminal/AsyncActionsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelActionsRequest; import com.squareup.square.terminal.types.CreateTerminalActionRequest; import com.squareup.square.terminal.types.GetActionsRequest; @@ -12,7 +13,7 @@ import com.squareup.square.types.CancelTerminalActionResponse; import com.squareup.square.types.CreateTerminalActionResponse; import com.squareup.square.types.GetTerminalActionResponse; -import com.squareup.square.types.SearchTerminalActionsResponse; +import com.squareup.square.types.TerminalAction; import java.util.concurrent.CompletableFuture; public class AsyncActionsClient { @@ -50,21 +51,21 @@ public CompletableFuture create( /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public CompletableFuture search(SearchTerminalActionsRequest request) { + public CompletableFuture> search(SearchTerminalActionsRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public CompletableFuture search( + public CompletableFuture> search( SearchTerminalActionsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/terminal/AsyncCheckoutsClient.java b/src/main/java/com/squareup/square/terminal/AsyncCheckoutsClient.java index 09974ec3..882bdd78 100644 --- a/src/main/java/com/squareup/square/terminal/AsyncCheckoutsClient.java +++ b/src/main/java/com/squareup/square/terminal/AsyncCheckoutsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelCheckoutsRequest; import com.squareup.square.terminal.types.CreateTerminalCheckoutRequest; import com.squareup.square.terminal.types.GetCheckoutsRequest; @@ -12,7 +13,7 @@ import com.squareup.square.types.CancelTerminalCheckoutResponse; import com.squareup.square.types.CreateTerminalCheckoutResponse; import com.squareup.square.types.GetTerminalCheckoutResponse; -import com.squareup.square.types.SearchTerminalCheckoutsResponse; +import com.squareup.square.types.TerminalCheckout; import java.util.concurrent.CompletableFuture; public class AsyncCheckoutsClient { @@ -52,21 +53,21 @@ public CompletableFuture create( /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public CompletableFuture search(SearchTerminalCheckoutsRequest request) { + public CompletableFuture> search(SearchTerminalCheckoutsRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public CompletableFuture search( + public CompletableFuture> search( SearchTerminalCheckoutsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/terminal/AsyncRawActionsClient.java b/src/main/java/com/squareup/square/terminal/AsyncRawActionsClient.java index 3a4921e5..31f62362 100644 --- a/src/main/java/com/squareup/square/terminal/AsyncRawActionsClient.java +++ b/src/main/java/com/squareup/square/terminal/AsyncRawActionsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelActionsRequest; import com.squareup.square.terminal.types.CreateTerminalActionRequest; import com.squareup.square.terminal.types.GetActionsRequest; @@ -19,8 +20,13 @@ import com.squareup.square.types.CreateTerminalActionResponse; import com.squareup.square.types.GetTerminalActionResponse; import com.squareup.square.types.SearchTerminalActionsResponse; +import com.squareup.square.types.TerminalAction; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -109,14 +115,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchTerminalActionsRequest.builder().build()); } /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchTerminalActionsRequest request) { return search(request, null); } @@ -124,7 +130,7 @@ public CompletableFuture /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchTerminalActionsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -148,15 +154,31 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchTerminalActionsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchTerminalActionsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTerminalActionsRequest nextRequest = SearchTerminalActionsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getAction().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchTerminalActionsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/terminal/AsyncRawCheckoutsClient.java b/src/main/java/com/squareup/square/terminal/AsyncRawCheckoutsClient.java index cc5d98a8..94341ef0 100644 --- a/src/main/java/com/squareup/square/terminal/AsyncRawCheckoutsClient.java +++ b/src/main/java/com/squareup/square/terminal/AsyncRawCheckoutsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelCheckoutsRequest; import com.squareup.square.terminal.types.CreateTerminalCheckoutRequest; import com.squareup.square.terminal.types.GetCheckoutsRequest; @@ -19,8 +20,13 @@ import com.squareup.square.types.CreateTerminalCheckoutResponse; import com.squareup.square.types.GetTerminalCheckoutResponse; import com.squareup.square.types.SearchTerminalCheckoutsResponse; +import com.squareup.square.types.TerminalCheckout; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -111,14 +117,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchTerminalCheckoutsRequest.builder().build()); } /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchTerminalCheckoutsRequest request) { return search(request, null); } @@ -126,7 +132,7 @@ public CompletableFuture> search( + public CompletableFuture>> search( SearchTerminalCheckoutsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -150,15 +156,32 @@ public CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchTerminalCheckoutsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchTerminalCheckoutsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTerminalCheckoutsRequest nextRequest = SearchTerminalCheckoutsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = + parsedResponse.getCheckouts().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchTerminalCheckoutsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/terminal/AsyncRawRefundsClient.java b/src/main/java/com/squareup/square/terminal/AsyncRawRefundsClient.java index af289d51..b4343eba 100644 --- a/src/main/java/com/squareup/square/terminal/AsyncRawRefundsClient.java +++ b/src/main/java/com/squareup/square/terminal/AsyncRawRefundsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelRefundsRequest; import com.squareup.square.terminal.types.CreateTerminalRefundRequest; import com.squareup.square.terminal.types.GetRefundsRequest; @@ -19,8 +20,13 @@ import com.squareup.square.types.CreateTerminalRefundResponse; import com.squareup.square.types.GetTerminalRefundResponse; import com.squareup.square.types.SearchTerminalRefundsResponse; +import com.squareup.square.types.TerminalRefund; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Headers; @@ -109,14 +115,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public CompletableFuture> search() { + public CompletableFuture>> search() { return search(SearchTerminalRefundsRequest.builder().build()); } /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchTerminalRefundsRequest request) { return search(request, null); } @@ -124,7 +130,7 @@ public CompletableFuture /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public CompletableFuture> search( + public CompletableFuture>> search( SearchTerminalRefundsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -148,15 +154,32 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + 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()) { if (response.isSuccessful()) { + SearchTerminalRefundsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchTerminalRefundsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTerminalRefundsRequest nextRequest = SearchTerminalRefundsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = + parsedResponse.getRefunds().orElse(Collections.emptyList()); future.complete(new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchTerminalRefundsResponse.class), + new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/squareup/square/terminal/AsyncRefundsClient.java b/src/main/java/com/squareup/square/terminal/AsyncRefundsClient.java index 83aae4c5..995d5302 100644 --- a/src/main/java/com/squareup/square/terminal/AsyncRefundsClient.java +++ b/src/main/java/com/squareup/square/terminal/AsyncRefundsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelRefundsRequest; import com.squareup.square.terminal.types.CreateTerminalRefundRequest; import com.squareup.square.terminal.types.GetRefundsRequest; @@ -12,7 +13,7 @@ import com.squareup.square.types.CancelTerminalRefundResponse; import com.squareup.square.types.CreateTerminalRefundResponse; import com.squareup.square.types.GetTerminalRefundResponse; -import com.squareup.square.types.SearchTerminalRefundsResponse; +import com.squareup.square.types.TerminalRefund; import java.util.concurrent.CompletableFuture; public class AsyncRefundsClient { @@ -50,21 +51,21 @@ public CompletableFuture create( /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public CompletableFuture search() { + public CompletableFuture> search() { return this.rawClient.search().thenApply(response -> response.body()); } /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public CompletableFuture search(SearchTerminalRefundsRequest request) { + public CompletableFuture> search(SearchTerminalRefundsRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public CompletableFuture search( + public CompletableFuture> search( SearchTerminalRefundsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/squareup/square/terminal/CheckoutsClient.java b/src/main/java/com/squareup/square/terminal/CheckoutsClient.java index 28ca26d5..2c5c94b7 100644 --- a/src/main/java/com/squareup/square/terminal/CheckoutsClient.java +++ b/src/main/java/com/squareup/square/terminal/CheckoutsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelCheckoutsRequest; import com.squareup.square.terminal.types.CreateTerminalCheckoutRequest; import com.squareup.square.terminal.types.GetCheckoutsRequest; @@ -12,7 +13,7 @@ import com.squareup.square.types.CancelTerminalCheckoutResponse; import com.squareup.square.types.CreateTerminalCheckoutResponse; import com.squareup.square.types.GetTerminalCheckoutResponse; -import com.squareup.square.types.SearchTerminalCheckoutsResponse; +import com.squareup.square.types.TerminalCheckout; public class CheckoutsClient { protected final ClientOptions clientOptions; @@ -50,21 +51,21 @@ public CreateTerminalCheckoutResponse create(CreateTerminalCheckoutRequest reque /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public SearchTerminalCheckoutsResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public SearchTerminalCheckoutsResponse search(SearchTerminalCheckoutsRequest request) { + public SyncPagingIterable search(SearchTerminalCheckoutsRequest request) { return this.rawClient.search(request).body(); } /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public SearchTerminalCheckoutsResponse search( + public SyncPagingIterable search( SearchTerminalCheckoutsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/terminal/RawActionsClient.java b/src/main/java/com/squareup/square/terminal/RawActionsClient.java index 928149b2..ce3c2d73 100644 --- a/src/main/java/com/squareup/square/terminal/RawActionsClient.java +++ b/src/main/java/com/squareup/square/terminal/RawActionsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelActionsRequest; import com.squareup.square.terminal.types.CreateTerminalActionRequest; import com.squareup.square.terminal.types.GetActionsRequest; @@ -19,7 +20,11 @@ import com.squareup.square.types.CreateTerminalActionResponse; import com.squareup.square.types.GetTerminalActionResponse; import com.squareup.square.types.SearchTerminalActionsResponse; +import com.squareup.square.types.TerminalAction; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -90,21 +95,21 @@ public SquareClientHttpResponse create( /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchTerminalActionsRequest.builder().build()); } /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public SquareClientHttpResponse search(SearchTerminalActionsRequest request) { + public SquareClientHttpResponse> search(SearchTerminalActionsRequest request) { return search(request, null); } /** * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days. */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchTerminalActionsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -131,8 +136,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchTerminalActionsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchTerminalActionsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTerminalActionsRequest nextRequest = SearchTerminalActionsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getAction().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchTerminalActionsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/terminal/RawCheckoutsClient.java b/src/main/java/com/squareup/square/terminal/RawCheckoutsClient.java index 6e30ccd4..deed4d62 100644 --- a/src/main/java/com/squareup/square/terminal/RawCheckoutsClient.java +++ b/src/main/java/com/squareup/square/terminal/RawCheckoutsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelCheckoutsRequest; import com.squareup.square.terminal.types.CreateTerminalCheckoutRequest; import com.squareup.square.terminal.types.GetCheckoutsRequest; @@ -19,7 +20,11 @@ import com.squareup.square.types.CreateTerminalCheckoutResponse; import com.squareup.square.types.GetTerminalCheckoutResponse; import com.squareup.square.types.SearchTerminalCheckoutsResponse; +import com.squareup.square.types.TerminalCheckout; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -93,21 +98,22 @@ public SquareClientHttpResponse create( /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchTerminalCheckoutsRequest.builder().build()); } /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public SquareClientHttpResponse search(SearchTerminalCheckoutsRequest request) { + public SquareClientHttpResponse> search( + SearchTerminalCheckoutsRequest request) { return search(request, null); } /** * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days. */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchTerminalCheckoutsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -134,9 +140,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchTerminalCheckoutsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchTerminalCheckoutsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTerminalCheckoutsRequest nextRequest = SearchTerminalCheckoutsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getCheckouts().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchTerminalCheckoutsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/terminal/RawRefundsClient.java b/src/main/java/com/squareup/square/terminal/RawRefundsClient.java index 0962cf47..2e807f16 100644 --- a/src/main/java/com/squareup/square/terminal/RawRefundsClient.java +++ b/src/main/java/com/squareup/square/terminal/RawRefundsClient.java @@ -11,6 +11,7 @@ import com.squareup.square.core.SquareApiException; import com.squareup.square.core.SquareClientHttpResponse; import com.squareup.square.core.SquareException; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelRefundsRequest; import com.squareup.square.terminal.types.CreateTerminalRefundRequest; import com.squareup.square.terminal.types.GetRefundsRequest; @@ -19,7 +20,11 @@ import com.squareup.square.types.CreateTerminalRefundResponse; import com.squareup.square.types.GetTerminalRefundResponse; import com.squareup.square.types.SearchTerminalRefundsResponse; +import com.squareup.square.types.TerminalRefund; import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -90,21 +95,21 @@ public SquareClientHttpResponse create( /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public SquareClientHttpResponse search() { + public SquareClientHttpResponse> search() { return search(SearchTerminalRefundsRequest.builder().build()); } /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public SquareClientHttpResponse search(SearchTerminalRefundsRequest request) { + public SquareClientHttpResponse> search(SearchTerminalRefundsRequest request) { return search(request, null); } /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public SquareClientHttpResponse search( + public SquareClientHttpResponse> search( SearchTerminalRefundsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -131,8 +136,18 @@ public SquareClientHttpResponse search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { + SearchTerminalRefundsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchTerminalRefundsResponse.class); + Optional startingAfter = parsedResponse.getCursor(); + SearchTerminalRefundsRequest nextRequest = SearchTerminalRefundsRequest.builder() + .from(request) + .cursor(startingAfter) + .build(); + List result = parsedResponse.getRefunds().orElse(Collections.emptyList()); return new SquareClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchTerminalRefundsResponse.class), + new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/squareup/square/terminal/RefundsClient.java b/src/main/java/com/squareup/square/terminal/RefundsClient.java index 2de218bf..aa254bae 100644 --- a/src/main/java/com/squareup/square/terminal/RefundsClient.java +++ b/src/main/java/com/squareup/square/terminal/RefundsClient.java @@ -5,6 +5,7 @@ import com.squareup.square.core.ClientOptions; import com.squareup.square.core.RequestOptions; +import com.squareup.square.core.SyncPagingIterable; import com.squareup.square.terminal.types.CancelRefundsRequest; import com.squareup.square.terminal.types.CreateTerminalRefundRequest; import com.squareup.square.terminal.types.GetRefundsRequest; @@ -12,7 +13,7 @@ import com.squareup.square.types.CancelTerminalRefundResponse; import com.squareup.square.types.CreateTerminalRefundResponse; import com.squareup.square.types.GetTerminalRefundResponse; -import com.squareup.square.types.SearchTerminalRefundsResponse; +import com.squareup.square.types.TerminalRefund; public class RefundsClient { protected final ClientOptions clientOptions; @@ -48,21 +49,22 @@ public CreateTerminalRefundResponse create(CreateTerminalRefundRequest request, /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public SearchTerminalRefundsResponse search() { + public SyncPagingIterable search() { return this.rawClient.search().body(); } /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public SearchTerminalRefundsResponse search(SearchTerminalRefundsRequest request) { + public SyncPagingIterable search(SearchTerminalRefundsRequest request) { return this.rawClient.search(request).body(); } /** * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days. */ - public SearchTerminalRefundsResponse search(SearchTerminalRefundsRequest request, RequestOptions requestOptions) { + public SyncPagingIterable search( + SearchTerminalRefundsRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } diff --git a/src/main/java/com/squareup/square/types/BulkRetrieveChannelsRequest.java b/src/main/java/com/squareup/square/types/BulkRetrieveChannelsRequest.java new file mode 100644 index 00000000..7555331f --- /dev/null +++ b/src/main/java/com/squareup/square/types/BulkRetrieveChannelsRequest.java @@ -0,0 +1,104 @@ +/** + * 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 = BulkRetrieveChannelsRequest.Builder.class) +public final class BulkRetrieveChannelsRequest { + private final List channelIds; + + private final Map additionalProperties; + + private BulkRetrieveChannelsRequest(List channelIds, Map additionalProperties) { + this.channelIds = channelIds; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("channel_ids") + public List getChannelIds() { + return channelIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BulkRetrieveChannelsRequest && equalTo((BulkRetrieveChannelsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BulkRetrieveChannelsRequest other) { + return channelIds.equals(other.channelIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.channelIds); + } + + @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 channelIds = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(BulkRetrieveChannelsRequest other) { + channelIds(other.getChannelIds()); + return this; + } + + @JsonSetter(value = "channel_ids", nulls = Nulls.SKIP) + public Builder channelIds(List channelIds) { + this.channelIds.clear(); + this.channelIds.addAll(channelIds); + return this; + } + + public Builder addChannelIds(String channelIds) { + this.channelIds.add(channelIds); + return this; + } + + public Builder addAllChannelIds(List channelIds) { + if (channelIds != null) { + this.channelIds.addAll(channelIds); + } + return this; + } + + public BulkRetrieveChannelsRequest build() { + return new BulkRetrieveChannelsRequest(channelIds, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/BulkRetrieveChannelsResponse.java b/src/main/java/com/squareup/square/types/BulkRetrieveChannelsResponse.java new file mode 100644 index 00000000..ccad1b53 --- /dev/null +++ b/src/main/java/com/squareup/square/types/BulkRetrieveChannelsResponse.java @@ -0,0 +1,139 @@ +/** + * 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 = BulkRetrieveChannelsResponse.Builder.class) +public final class BulkRetrieveChannelsResponse { + private final Optional> errors; + + private final Optional> responses; + + private final Map additionalProperties; + + private BulkRetrieveChannelsResponse( + Optional> errors, + Optional> responses, + Map additionalProperties) { + this.errors = errors; + this.responses = responses; + this.additionalProperties = additionalProperties; + } + + /** + * @return Information about errors encountered during the request. + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + /** + * @return A map of channel IDs to channel responses which tell whether + * retrieval for a specific channel is success or not. + * Channel response of a success retrieval would contain channel info + * whereas channel response of a failed retrieval would have error info. + */ + @JsonProperty("responses") + public Optional> getResponses() { + return responses; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BulkRetrieveChannelsResponse && equalTo((BulkRetrieveChannelsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BulkRetrieveChannelsResponse other) { + return errors.equals(other.errors) && responses.equals(other.responses); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.errors, this.responses); + } + + @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> errors = Optional.empty(); + + private Optional> responses = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(BulkRetrieveChannelsResponse other) { + errors(other.getErrors()); + responses(other.getResponses()); + return this; + } + + /** + *

    Information about errors encountered during the request.

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + /** + *

    A map of channel IDs to channel responses which tell whether + * retrieval for a specific channel is success or not. + * Channel response of a success retrieval would contain channel info + * whereas channel response of a failed retrieval would have error info.

    + */ + @JsonSetter(value = "responses", nulls = Nulls.SKIP) + public Builder responses(Optional> responses) { + this.responses = responses; + return this; + } + + public Builder responses(Map responses) { + this.responses = Optional.ofNullable(responses); + return this; + } + + public BulkRetrieveChannelsResponse build() { + return new BulkRetrieveChannelsResponse(errors, responses, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/CancelTransferOrderRequest.java b/src/main/java/com/squareup/square/types/CancelTransferOrderRequest.java new file mode 100644 index 00000000..e1e74bc8 --- /dev/null +++ b/src/main/java/com/squareup/square/types/CancelTransferOrderRequest.java @@ -0,0 +1,199 @@ +/** + * 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 = CancelTransferOrderRequest.Builder.class) +public final class CancelTransferOrderRequest { + private final String transferOrderId; + + private final String idempotencyKey; + + private final Optional version; + + private final Map additionalProperties; + + private CancelTransferOrderRequest( + String transferOrderId, + String idempotencyKey, + Optional version, + Map additionalProperties) { + this.transferOrderId = transferOrderId; + this.idempotencyKey = idempotencyKey; + this.version = version; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status. + */ + @JsonProperty("transfer_order_id") + public String getTransferOrderId() { + return transferOrderId; + } + + /** + * @return A unique string that identifies this UpdateTransferOrder request. Keys can be + * any valid string but must be unique for every UpdateTransferOrder request. + */ + @JsonProperty("idempotency_key") + public String getIdempotencyKey() { + return idempotencyKey; + } + + /** + * @return Version for optimistic concurrency + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CancelTransferOrderRequest && equalTo((CancelTransferOrderRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CancelTransferOrderRequest other) { + return transferOrderId.equals(other.transferOrderId) + && idempotencyKey.equals(other.idempotencyKey) + && version.equals(other.version); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrderId, this.idempotencyKey, this.version); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TransferOrderIdStage builder() { + return new Builder(); + } + + public interface TransferOrderIdStage { + /** + *

    The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status.

    + */ + IdempotencyKeyStage transferOrderId(@NotNull String transferOrderId); + + Builder from(CancelTransferOrderRequest other); + } + + public interface IdempotencyKeyStage { + /** + *

    A unique string that identifies this UpdateTransferOrder request. Keys can be + * any valid string but must be unique for every UpdateTransferOrder request.

    + */ + _FinalStage idempotencyKey(@NotNull String idempotencyKey); + } + + public interface _FinalStage { + CancelTransferOrderRequest build(); + + /** + *

    Version for optimistic concurrency

    + */ + _FinalStage version(Optional version); + + _FinalStage version(Long version); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TransferOrderIdStage, IdempotencyKeyStage, _FinalStage { + private String transferOrderId; + + private String idempotencyKey; + + private Optional version = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CancelTransferOrderRequest other) { + transferOrderId(other.getTransferOrderId()); + idempotencyKey(other.getIdempotencyKey()); + version(other.getVersion()); + return this; + } + + /** + *

    The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status.

    + *

    The ID of the transfer order to cancel. Must be in STARTED or PARTIALLY_RECEIVED status.

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

    A unique string that identifies this UpdateTransferOrder request. Keys can be + * any valid string but must be unique for every UpdateTransferOrder request.

    + *

    A unique string that identifies this UpdateTransferOrder request. Keys can be + * any valid string but must be unique for every UpdateTransferOrder request.

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

    Version for optimistic concurrency

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

    Version for optimistic concurrency

    + */ + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + @java.lang.Override + public CancelTransferOrderRequest build() { + return new CancelTransferOrderRequest(transferOrderId, idempotencyKey, version, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/CancelTransferOrderResponse.java b/src/main/java/com/squareup/square/types/CancelTransferOrderResponse.java new file mode 100644 index 00000000..cc89e572 --- /dev/null +++ b/src/main/java/com/squareup/square/types/CancelTransferOrderResponse.java @@ -0,0 +1,133 @@ +/** + * 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 = CancelTransferOrderResponse.Builder.class) +public final class CancelTransferOrderResponse { + private final Optional transferOrder; + + private final Optional> errors; + + private final Map additionalProperties; + + private CancelTransferOrderResponse( + Optional transferOrder, + Optional> errors, + Map additionalProperties) { + this.transferOrder = transferOrder; + this.errors = errors; + this.additionalProperties = additionalProperties; + } + + /** + * @return The updated transfer order with status changed to CANCELED + */ + @JsonProperty("transfer_order") + public Optional getTransferOrder() { + return transferOrder; + } + + /** + * @return Any errors that occurred during the request + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CancelTransferOrderResponse && equalTo((CancelTransferOrderResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CancelTransferOrderResponse other) { + return transferOrder.equals(other.transferOrder) && errors.equals(other.errors); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrder, this.errors); + } + + @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 transferOrder = Optional.empty(); + + private Optional> errors = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CancelTransferOrderResponse other) { + transferOrder(other.getTransferOrder()); + errors(other.getErrors()); + return this; + } + + /** + *

    The updated transfer order with status changed to CANCELED

    + */ + @JsonSetter(value = "transfer_order", nulls = Nulls.SKIP) + public Builder transferOrder(Optional transferOrder) { + this.transferOrder = transferOrder; + return this; + } + + public Builder transferOrder(TransferOrder transferOrder) { + this.transferOrder = Optional.ofNullable(transferOrder); + return this; + } + + /** + *

    Any errors that occurred during the request

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + public CancelTransferOrderResponse build() { + return new CancelTransferOrderResponse(transferOrder, errors, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/Channel.java b/src/main/java/com/squareup/square/types/Channel.java new file mode 100644 index 00000000..2ab67bdf --- /dev/null +++ b/src/main/java/com/squareup/square/types/Channel.java @@ -0,0 +1,351 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = Channel.Builder.class) +public final class Channel { + private final Optional id; + + private final Optional merchantId; + + private final Optional name; + + private final Optional version; + + private final Optional reference; + + private final Optional status; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Map additionalProperties; + + private Channel( + Optional id, + Optional merchantId, + Optional name, + Optional version, + Optional reference, + Optional status, + Optional createdAt, + Optional updatedAt, + Map additionalProperties) { + this.id = id; + this.merchantId = merchantId; + this.name = name; + this.version = version; + this.reference = reference; + this.status = status; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return The channel's unique ID. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique ID of the merchant this channel belongs to. + */ + @JsonProperty("merchant_id") + public Optional getMerchantId() { + return merchantId; + } + + /** + * @return The name of the channel. + */ + @JsonIgnore + public Optional getName() { + if (name == null) { + return Optional.empty(); + } + return name; + } + + /** + * @return The version number which is incremented each time an update is made to the channel. + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + /** + * @return Represents an entity the channel is associated with. + */ + @JsonProperty("reference") + public Optional getReference() { + return reference; + } + + /** + * @return Status of the channel. + * See Status for possible values + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return The timestamp for when the channel was created, in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). + * For more information, see Working with Dates. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The timestamp for when the channel was last updated, in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). + * For more information, see Working with Dates. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("name") + private Optional _getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Channel && equalTo((Channel) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Channel other) { + return id.equals(other.id) + && merchantId.equals(other.merchantId) + && name.equals(other.name) + && version.equals(other.version) + && reference.equals(other.reference) + && status.equals(other.status) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.merchantId, + this.name, + this.version, + this.reference, + this.status, + this.createdAt, + this.updatedAt); + } + + @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 id = Optional.empty(); + + private Optional merchantId = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional version = Optional.empty(); + + private Optional reference = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Channel other) { + id(other.getId()); + merchantId(other.getMerchantId()); + name(other.getName()); + version(other.getVersion()); + reference(other.getReference()); + status(other.getStatus()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

    The channel's unique ID.

    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

    The unique ID of the merchant this channel belongs to.

    + */ + @JsonSetter(value = "merchant_id", nulls = Nulls.SKIP) + public Builder merchantId(Optional merchantId) { + this.merchantId = merchantId; + return this; + } + + public Builder merchantId(String merchantId) { + this.merchantId = Optional.ofNullable(merchantId); + return this; + } + + /** + *

    The name of the channel.

    + */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + public Builder name(Nullable name) { + if (name.isNull()) { + this.name = null; + } else if (name.isEmpty()) { + this.name = Optional.empty(); + } else { + this.name = Optional.of(name.get()); + } + return this; + } + + /** + *

    The version number which is incremented each time an update is made to the channel.

    + */ + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public Builder version(Optional version) { + this.version = version; + return this; + } + + public Builder version(Integer version) { + this.version = Optional.ofNullable(version); + return this; + } + + /** + *

    Represents an entity the channel is associated with.

    + */ + @JsonSetter(value = "reference", nulls = Nulls.SKIP) + public Builder reference(Optional reference) { + this.reference = reference; + return this; + } + + public Builder reference(Reference reference) { + this.reference = Optional.ofNullable(reference); + return this; + } + + /** + *

    Status of the channel. + * See Status for possible values

    + */ + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(ChannelStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + /** + *

    The timestamp for when the channel was created, in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). + * For more information, see Working with Dates.

    + */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(String createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    The timestamp for when the channel was last updated, in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). + * For more information, see Working with Dates.

    + */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(String updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + public Channel build() { + return new Channel( + id, merchantId, name, version, reference, status, createdAt, updatedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/ChannelStatus.java b/src/main/java/com/squareup/square/types/ChannelStatus.java new file mode 100644 index 00000000..666cc610 --- /dev/null +++ b/src/main/java/com/squareup/square/types/ChannelStatus.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 ChannelStatus { + public static final ChannelStatus ACTIVE = new ChannelStatus(Value.ACTIVE, "ACTIVE"); + + public static final ChannelStatus INACTIVE = new ChannelStatus(Value.INACTIVE, "INACTIVE"); + + private final Value value; + + private final String string; + + ChannelStatus(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 ChannelStatus && this.string.equals(((ChannelStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ACTIVE: + return visitor.visitActive(); + case INACTIVE: + return visitor.visitInactive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ChannelStatus valueOf(String value) { + switch (value) { + case "ACTIVE": + return ACTIVE; + case "INACTIVE": + return INACTIVE; + default: + return new ChannelStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + INACTIVE, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitInactive(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/squareup/square/types/CreateTransferOrderData.java b/src/main/java/com/squareup/square/types/CreateTransferOrderData.java new file mode 100644 index 00000000..55cdeca1 --- /dev/null +++ b/src/main/java/com/squareup/square/types/CreateTransferOrderData.java @@ -0,0 +1,535 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = CreateTransferOrderData.Builder.class) +public final class CreateTransferOrderData { + private final String sourceLocationId; + + private final String destinationLocationId; + + private final Optional expectedAt; + + private final Optional notes; + + private final Optional trackingNumber; + + private final Optional createdByTeamMemberId; + + private final Optional> lineItems; + + private final Map additionalProperties; + + private CreateTransferOrderData( + String sourceLocationId, + String destinationLocationId, + Optional expectedAt, + Optional notes, + Optional trackingNumber, + Optional createdByTeamMemberId, + Optional> lineItems, + Map additionalProperties) { + this.sourceLocationId = sourceLocationId; + this.destinationLocationId = destinationLocationId; + this.expectedAt = expectedAt; + this.notes = notes; + this.trackingNumber = trackingNumber; + this.createdByTeamMemberId = createdByTeamMemberId; + this.lineItems = lineItems; + this.additionalProperties = additionalProperties; + } + + /** + * @return The source Location that will send the items. Must be an active location + * in your Square account with sufficient inventory of the requested items. + */ + @JsonProperty("source_location_id") + public String getSourceLocationId() { + return sourceLocationId; + } + + /** + * @return The destination Location that will receive the items. Must be an active location + * in your Square account + */ + @JsonProperty("destination_location_id") + public String getDestinationLocationId() { + return destinationLocationId; + } + + /** + * @return Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z"). + */ + @JsonIgnore + public Optional getExpectedAt() { + if (expectedAt == null) { + return Optional.empty(); + } + return expectedAt; + } + + /** + * @return Optional notes about the transfer + */ + @JsonIgnore + public Optional getNotes() { + if (notes == null) { + return Optional.empty(); + } + return notes; + } + + /** + * @return Optional shipment tracking number + */ + @JsonIgnore + public Optional getTrackingNumber() { + if (trackingNumber == null) { + return Optional.empty(); + } + return trackingNumber; + } + + /** + * @return ID of the TeamMember creating this transfer order. Used for tracking + * and auditing purposes. + */ + @JsonIgnore + public Optional getCreatedByTeamMemberId() { + if (createdByTeamMemberId == null) { + return Optional.empty(); + } + return createdByTeamMemberId; + } + + /** + * @return List of CatalogItemVariations to transfer, including quantities + */ + @JsonIgnore + public Optional> getLineItems() { + if (lineItems == null) { + return Optional.empty(); + } + return lineItems; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("expected_at") + private Optional _getExpectedAt() { + return expectedAt; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("notes") + private Optional _getNotes() { + return notes; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("tracking_number") + private Optional _getTrackingNumber() { + return trackingNumber; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("created_by_team_member_id") + private Optional _getCreatedByTeamMemberId() { + return createdByTeamMemberId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("line_items") + private Optional> _getLineItems() { + return lineItems; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateTransferOrderData && equalTo((CreateTransferOrderData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateTransferOrderData other) { + return sourceLocationId.equals(other.sourceLocationId) + && destinationLocationId.equals(other.destinationLocationId) + && expectedAt.equals(other.expectedAt) + && notes.equals(other.notes) + && trackingNumber.equals(other.trackingNumber) + && createdByTeamMemberId.equals(other.createdByTeamMemberId) + && lineItems.equals(other.lineItems); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.sourceLocationId, + this.destinationLocationId, + this.expectedAt, + this.notes, + this.trackingNumber, + this.createdByTeamMemberId, + this.lineItems); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourceLocationIdStage builder() { + return new Builder(); + } + + public interface SourceLocationIdStage { + /** + *

    The source Location that will send the items. Must be an active location + * in your Square account with sufficient inventory of the requested items.

    + */ + DestinationLocationIdStage sourceLocationId(@NotNull String sourceLocationId); + + Builder from(CreateTransferOrderData other); + } + + public interface DestinationLocationIdStage { + /** + *

    The destination Location that will receive the items. Must be an active location + * in your Square account

    + */ + _FinalStage destinationLocationId(@NotNull String destinationLocationId); + } + + public interface _FinalStage { + CreateTransferOrderData build(); + + /** + *

    Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z").

    + */ + _FinalStage expectedAt(Optional expectedAt); + + _FinalStage expectedAt(String expectedAt); + + _FinalStage expectedAt(Nullable expectedAt); + + /** + *

    Optional notes about the transfer

    + */ + _FinalStage notes(Optional notes); + + _FinalStage notes(String notes); + + _FinalStage notes(Nullable notes); + + /** + *

    Optional shipment tracking number

    + */ + _FinalStage trackingNumber(Optional trackingNumber); + + _FinalStage trackingNumber(String trackingNumber); + + _FinalStage trackingNumber(Nullable trackingNumber); + + /** + *

    ID of the TeamMember creating this transfer order. Used for tracking + * and auditing purposes.

    + */ + _FinalStage createdByTeamMemberId(Optional createdByTeamMemberId); + + _FinalStage createdByTeamMemberId(String createdByTeamMemberId); + + _FinalStage createdByTeamMemberId(Nullable createdByTeamMemberId); + + /** + *

    List of CatalogItemVariations to transfer, including quantities

    + */ + _FinalStage lineItems(Optional> lineItems); + + _FinalStage lineItems(List lineItems); + + _FinalStage lineItems(Nullable> lineItems); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SourceLocationIdStage, DestinationLocationIdStage, _FinalStage { + private String sourceLocationId; + + private String destinationLocationId; + + private Optional> lineItems = Optional.empty(); + + private Optional createdByTeamMemberId = Optional.empty(); + + private Optional trackingNumber = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional expectedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateTransferOrderData other) { + sourceLocationId(other.getSourceLocationId()); + destinationLocationId(other.getDestinationLocationId()); + expectedAt(other.getExpectedAt()); + notes(other.getNotes()); + trackingNumber(other.getTrackingNumber()); + createdByTeamMemberId(other.getCreatedByTeamMemberId()); + lineItems(other.getLineItems()); + return this; + } + + /** + *

    The source Location that will send the items. Must be an active location + * in your Square account with sufficient inventory of the requested items.

    + *

    The source Location that will send the items. Must be an active location + * in your Square account with sufficient inventory of the requested items.

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

    The destination Location that will receive the items. Must be an active location + * in your Square account

    + *

    The destination Location that will receive the items. Must be an active location + * in your Square account

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

    List of CatalogItemVariations to transfer, including quantities

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage lineItems(Nullable> lineItems) { + if (lineItems.isNull()) { + this.lineItems = null; + } else if (lineItems.isEmpty()) { + this.lineItems = Optional.empty(); + } else { + this.lineItems = Optional.of(lineItems.get()); + } + return this; + } + + /** + *

    List of CatalogItemVariations to transfer, including quantities

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

    List of CatalogItemVariations to transfer, including quantities

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

    ID of the TeamMember creating this transfer order. Used for tracking + * and auditing purposes.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdByTeamMemberId(Nullable createdByTeamMemberId) { + if (createdByTeamMemberId.isNull()) { + this.createdByTeamMemberId = null; + } else if (createdByTeamMemberId.isEmpty()) { + this.createdByTeamMemberId = Optional.empty(); + } else { + this.createdByTeamMemberId = Optional.of(createdByTeamMemberId.get()); + } + return this; + } + + /** + *

    ID of the TeamMember creating this transfer order. Used for tracking + * and auditing purposes.

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

    ID of the TeamMember creating this transfer order. Used for tracking + * and auditing purposes.

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

    Optional shipment tracking number

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage trackingNumber(Nullable trackingNumber) { + if (trackingNumber.isNull()) { + this.trackingNumber = null; + } else if (trackingNumber.isEmpty()) { + this.trackingNumber = Optional.empty(); + } else { + this.trackingNumber = Optional.of(trackingNumber.get()); + } + return this; + } + + /** + *

    Optional shipment tracking number

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

    Optional shipment tracking number

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

    Optional notes about the transfer

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage notes(Nullable notes) { + if (notes.isNull()) { + this.notes = null; + } else if (notes.isEmpty()) { + this.notes = Optional.empty(); + } else { + this.notes = Optional.of(notes.get()); + } + return this; + } + + /** + *

    Optional notes about the transfer

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

    Optional notes about the transfer

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

    Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z").

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage expectedAt(Nullable expectedAt) { + if (expectedAt.isNull()) { + this.expectedAt = null; + } else if (expectedAt.isEmpty()) { + this.expectedAt = Optional.empty(); + } else { + this.expectedAt = Optional.of(expectedAt.get()); + } + return this; + } + + /** + *

    Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z").

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

    Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z").

    + */ + @java.lang.Override + @JsonSetter(value = "expected_at", nulls = Nulls.SKIP) + public _FinalStage expectedAt(Optional expectedAt) { + this.expectedAt = expectedAt; + return this; + } + + @java.lang.Override + public CreateTransferOrderData build() { + return new CreateTransferOrderData( + sourceLocationId, + destinationLocationId, + expectedAt, + notes, + trackingNumber, + createdByTeamMemberId, + lineItems, + additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/CreateTransferOrderLineData.java b/src/main/java/com/squareup/square/types/CreateTransferOrderLineData.java new file mode 100644 index 00000000..ea827c0f --- /dev/null +++ b/src/main/java/com/squareup/square/types/CreateTransferOrderLineData.java @@ -0,0 +1,171 @@ +/** + * 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 = CreateTransferOrderLineData.Builder.class) +public final class CreateTransferOrderLineData { + private final String itemVariationId; + + private final String quantityOrdered; + + private final Map additionalProperties; + + private CreateTransferOrderLineData( + String itemVariationId, String quantityOrdered, Map additionalProperties) { + this.itemVariationId = itemVariationId; + this.quantityOrdered = quantityOrdered; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the CatalogItemVariation to transfer. Must reference a valid + * item variation in the Catalog. The item variation must be: + *
      + *
    • Active and available for sale
    • + *
    • Enabled for inventory tracking
    • + *
    • Available at the source location
    • + *
    + */ + @JsonProperty("item_variation_id") + public String getItemVariationId() { + return itemVariationId; + } + + /** + * @return Total quantity ordered + */ + @JsonProperty("quantity_ordered") + public String getQuantityOrdered() { + return quantityOrdered; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateTransferOrderLineData && equalTo((CreateTransferOrderLineData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateTransferOrderLineData other) { + return itemVariationId.equals(other.itemVariationId) && quantityOrdered.equals(other.quantityOrdered); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.itemVariationId, this.quantityOrdered); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ItemVariationIdStage builder() { + return new Builder(); + } + + public interface ItemVariationIdStage { + /** + *

    ID of the CatalogItemVariation to transfer. Must reference a valid + * item variation in the Catalog. The item variation must be:

    + *
      + *
    • Active and available for sale
    • + *
    • Enabled for inventory tracking
    • + *
    • Available at the source location
    • + *
    + */ + QuantityOrderedStage itemVariationId(@NotNull String itemVariationId); + + Builder from(CreateTransferOrderLineData other); + } + + public interface QuantityOrderedStage { + /** + *

    Total quantity ordered

    + */ + _FinalStage quantityOrdered(@NotNull String quantityOrdered); + } + + public interface _FinalStage { + CreateTransferOrderLineData build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ItemVariationIdStage, QuantityOrderedStage, _FinalStage { + private String itemVariationId; + + private String quantityOrdered; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateTransferOrderLineData other) { + itemVariationId(other.getItemVariationId()); + quantityOrdered(other.getQuantityOrdered()); + return this; + } + + /** + *

    ID of the CatalogItemVariation to transfer. Must reference a valid + * item variation in the Catalog. The item variation must be:

    + *
      + *
    • Active and available for sale
    • + *
    • Enabled for inventory tracking
    • + *
    • Available at the source location
    • + *
    + *

    ID of the CatalogItemVariation to transfer. Must reference a valid + * item variation in the Catalog. The item variation must be:

    + *
      + *
    • Active and available for sale
    • + *
    • Enabled for inventory tracking
    • + *
    • Available at the source location
    • + *
    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("item_variation_id") + public QuantityOrderedStage itemVariationId(@NotNull String itemVariationId) { + this.itemVariationId = Objects.requireNonNull(itemVariationId, "itemVariationId must not be null"); + return this; + } + + /** + *

    Total quantity ordered

    + *

    Total quantity ordered

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("quantity_ordered") + public _FinalStage quantityOrdered(@NotNull String quantityOrdered) { + this.quantityOrdered = Objects.requireNonNull(quantityOrdered, "quantityOrdered must not be null"); + return this; + } + + @java.lang.Override + public CreateTransferOrderLineData build() { + return new CreateTransferOrderLineData(itemVariationId, quantityOrdered, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/CreateTransferOrderRequest.java b/src/main/java/com/squareup/square/types/CreateTransferOrderRequest.java new file mode 100644 index 00000000..0d480d52 --- /dev/null +++ b/src/main/java/com/squareup/square/types/CreateTransferOrderRequest.java @@ -0,0 +1,151 @@ +/** + * 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 = CreateTransferOrderRequest.Builder.class) +public final class CreateTransferOrderRequest { + private final String idempotencyKey; + + private final CreateTransferOrderData transferOrder; + + private final Map additionalProperties; + + private CreateTransferOrderRequest( + String idempotencyKey, CreateTransferOrderData transferOrder, Map additionalProperties) { + this.idempotencyKey = idempotencyKey; + this.transferOrder = transferOrder; + this.additionalProperties = additionalProperties; + } + + /** + * @return A unique string that identifies this CreateTransferOrder request. Keys can be + * any valid string but must be unique for every CreateTransferOrder request. + */ + @JsonProperty("idempotency_key") + public String getIdempotencyKey() { + return idempotencyKey; + } + + /** + * @return The transfer order to create + */ + @JsonProperty("transfer_order") + public CreateTransferOrderData getTransferOrder() { + return transferOrder; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateTransferOrderRequest && equalTo((CreateTransferOrderRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateTransferOrderRequest other) { + return idempotencyKey.equals(other.idempotencyKey) && transferOrder.equals(other.transferOrder); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.idempotencyKey, this.transferOrder); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdempotencyKeyStage builder() { + return new Builder(); + } + + public interface IdempotencyKeyStage { + /** + *

    A unique string that identifies this CreateTransferOrder request. Keys can be + * any valid string but must be unique for every CreateTransferOrder request.

    + */ + TransferOrderStage idempotencyKey(@NotNull String idempotencyKey); + + Builder from(CreateTransferOrderRequest other); + } + + public interface TransferOrderStage { + /** + *

    The transfer order to create

    + */ + _FinalStage transferOrder(@NotNull CreateTransferOrderData transferOrder); + } + + public interface _FinalStage { + CreateTransferOrderRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdempotencyKeyStage, TransferOrderStage, _FinalStage { + private String idempotencyKey; + + private CreateTransferOrderData transferOrder; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateTransferOrderRequest other) { + idempotencyKey(other.getIdempotencyKey()); + transferOrder(other.getTransferOrder()); + return this; + } + + /** + *

    A unique string that identifies this CreateTransferOrder request. Keys can be + * any valid string but must be unique for every CreateTransferOrder request.

    + *

    A unique string that identifies this CreateTransferOrder request. Keys can be + * any valid string but must be unique for every CreateTransferOrder request.

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

    The transfer order to create

    + *

    The transfer order to create

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("transfer_order") + public _FinalStage transferOrder(@NotNull CreateTransferOrderData transferOrder) { + this.transferOrder = Objects.requireNonNull(transferOrder, "transferOrder must not be null"); + return this; + } + + @java.lang.Override + public CreateTransferOrderRequest build() { + return new CreateTransferOrderRequest(idempotencyKey, transferOrder, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/CreateTransferOrderResponse.java b/src/main/java/com/squareup/square/types/CreateTransferOrderResponse.java new file mode 100644 index 00000000..3702e395 --- /dev/null +++ b/src/main/java/com/squareup/square/types/CreateTransferOrderResponse.java @@ -0,0 +1,133 @@ +/** + * 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 = CreateTransferOrderResponse.Builder.class) +public final class CreateTransferOrderResponse { + private final Optional transferOrder; + + private final Optional> errors; + + private final Map additionalProperties; + + private CreateTransferOrderResponse( + Optional transferOrder, + Optional> errors, + Map additionalProperties) { + this.transferOrder = transferOrder; + this.errors = errors; + this.additionalProperties = additionalProperties; + } + + /** + * @return The created transfer order + */ + @JsonProperty("transfer_order") + public Optional getTransferOrder() { + return transferOrder; + } + + /** + * @return Any errors that occurred during the request + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateTransferOrderResponse && equalTo((CreateTransferOrderResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateTransferOrderResponse other) { + return transferOrder.equals(other.transferOrder) && errors.equals(other.errors); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrder, this.errors); + } + + @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 transferOrder = Optional.empty(); + + private Optional> errors = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CreateTransferOrderResponse other) { + transferOrder(other.getTransferOrder()); + errors(other.getErrors()); + return this; + } + + /** + *

    The created transfer order

    + */ + @JsonSetter(value = "transfer_order", nulls = Nulls.SKIP) + public Builder transferOrder(Optional transferOrder) { + this.transferOrder = transferOrder; + return this; + } + + public Builder transferOrder(TransferOrder transferOrder) { + this.transferOrder = Optional.ofNullable(transferOrder); + return this; + } + + /** + *

    Any errors that occurred during the request

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + public CreateTransferOrderResponse build() { + return new CreateTransferOrderResponse(transferOrder, errors, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/CustomAttribute.java b/src/main/java/com/squareup/square/types/CustomAttribute.java index a6ef4107..f3974b60 100644 --- a/src/main/java/com/squareup/square/types/CustomAttribute.java +++ b/src/main/java/com/squareup/square/types/CustomAttribute.java @@ -78,8 +78,17 @@ public Optional getKey() { return key; } - @JsonProperty("value") + /** + * @return The value assigned to the custom attribute. It is validated against the custom + * attribute definition's schema on write operations. For more information about custom + * attribute values, + * see Custom Attributes Overview. + */ + @JsonIgnore public Optional getValue() { + if (value == null) { + return Optional.empty(); + } return value; } @@ -137,6 +146,12 @@ private Optional _getKey() { return key; } + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("value") + private Optional _getValue() { + return value; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -239,6 +254,12 @@ public Builder key(Nullable key) { return this; } + /** + *

    The value assigned to the custom attribute. It is validated against the custom + * attribute definition's schema on write operations. For more information about custom + * attribute values, + * see Custom Attributes Overview.

    + */ @JsonSetter(value = "value", nulls = Nulls.SKIP) public Builder value(Optional value) { this.value = value; @@ -250,6 +271,17 @@ public Builder value(Object value) { return this; } + public Builder value(Nullable value) { + if (value.isNull()) { + this.value = null; + } else if (value.isEmpty()) { + this.value = Optional.empty(); + } else { + this.value = Optional.of(value.get()); + } + return this; + } + /** *

    Read only. The current version of the custom attribute. This field is incremented when the custom attribute is changed. * When updating an existing custom attribute value, you can provide this field diff --git a/src/main/java/com/squareup/square/types/DeleteTransferOrderResponse.java b/src/main/java/com/squareup/square/types/DeleteTransferOrderResponse.java new file mode 100644 index 00000000..27d9b9a0 --- /dev/null +++ b/src/main/java/com/squareup/square/types/DeleteTransferOrderResponse.java @@ -0,0 +1,102 @@ +/** + * 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 = DeleteTransferOrderResponse.Builder.class) +public final class DeleteTransferOrderResponse { + private final Optional> errors; + + private final Map additionalProperties; + + private DeleteTransferOrderResponse(Optional> errors, Map additionalProperties) { + this.errors = errors; + this.additionalProperties = additionalProperties; + } + + /** + * @return Any errors that occurred during the request + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTransferOrderResponse && equalTo((DeleteTransferOrderResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTransferOrderResponse other) { + return errors.equals(other.errors); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.errors); + } + + @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> errors = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteTransferOrderResponse other) { + errors(other.getErrors()); + return this; + } + + /** + *

    Any errors that occurred during the request

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + public DeleteTransferOrderResponse build() { + return new DeleteTransferOrderResponse(errors, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/DeleteTransferOrdersRequest.java b/src/main/java/com/squareup/square/types/DeleteTransferOrdersRequest.java new file mode 100644 index 00000000..1379695b --- /dev/null +++ b/src/main/java/com/squareup/square/types/DeleteTransferOrdersRequest.java @@ -0,0 +1,187 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = DeleteTransferOrdersRequest.Builder.class) +public final class DeleteTransferOrdersRequest { + private final String transferOrderId; + + private final Optional version; + + private final Map additionalProperties; + + private DeleteTransferOrdersRequest( + String transferOrderId, Optional version, Map additionalProperties) { + this.transferOrderId = transferOrderId; + this.version = version; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the transfer order to delete + */ + @JsonProperty("transfer_order_id") + public String getTransferOrderId() { + return transferOrderId; + } + + /** + * @return Version for optimistic concurrency + */ + @JsonIgnore + public Optional getVersion() { + if (version == null) { + return Optional.empty(); + } + return version; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("version") + private Optional _getVersion() { + return version; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTransferOrdersRequest && equalTo((DeleteTransferOrdersRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTransferOrdersRequest other) { + return transferOrderId.equals(other.transferOrderId) && version.equals(other.version); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrderId, this.version); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TransferOrderIdStage builder() { + return new Builder(); + } + + public interface TransferOrderIdStage { + /** + *

    The ID of the transfer order to delete

    + */ + _FinalStage transferOrderId(@NotNull String transferOrderId); + + Builder from(DeleteTransferOrdersRequest other); + } + + public interface _FinalStage { + DeleteTransferOrdersRequest build(); + + /** + *

    Version for optimistic concurrency

    + */ + _FinalStage version(Optional version); + + _FinalStage version(Long version); + + _FinalStage version(Nullable version); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TransferOrderIdStage, _FinalStage { + private String transferOrderId; + + private Optional version = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteTransferOrdersRequest other) { + transferOrderId(other.getTransferOrderId()); + version(other.getVersion()); + return this; + } + + /** + *

    The ID of the transfer order to delete

    + *

    The ID of the transfer order to delete

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

    Version for optimistic concurrency

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage version(Nullable version) { + if (version.isNull()) { + this.version = null; + } else if (version.isEmpty()) { + this.version = Optional.empty(); + } else { + this.version = Optional.of(version.get()); + } + return this; + } + + /** + *

    Version for optimistic concurrency

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

    Version for optimistic concurrency

    + */ + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + @java.lang.Override + public DeleteTransferOrdersRequest build() { + return new DeleteTransferOrdersRequest(transferOrderId, version, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/GetChannelsRequest.java b/src/main/java/com/squareup/square/types/GetChannelsRequest.java new file mode 100644 index 00000000..a537800e --- /dev/null +++ b/src/main/java/com/squareup/square/types/GetChannelsRequest.java @@ -0,0 +1,113 @@ +/** + * 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 = GetChannelsRequest.Builder.class) +public final class GetChannelsRequest { + private final String channelId; + + private final Map additionalProperties; + + private GetChannelsRequest(String channelId, Map additionalProperties) { + this.channelId = channelId; + this.additionalProperties = additionalProperties; + } + + /** + * @return A channel id + */ + @JsonProperty("channel_id") + public String getChannelId() { + return channelId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetChannelsRequest && equalTo((GetChannelsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetChannelsRequest other) { + return channelId.equals(other.channelId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.channelId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ChannelIdStage builder() { + return new Builder(); + } + + public interface ChannelIdStage { + /** + *

    A channel id

    + */ + _FinalStage channelId(@NotNull String channelId); + + Builder from(GetChannelsRequest other); + } + + public interface _FinalStage { + GetChannelsRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ChannelIdStage, _FinalStage { + private String channelId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetChannelsRequest other) { + channelId(other.getChannelId()); + return this; + } + + /** + *

    A channel id

    + *

    A channel id

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("channel_id") + public _FinalStage channelId(@NotNull String channelId) { + this.channelId = Objects.requireNonNull(channelId, "channelId must not be null"); + return this; + } + + @java.lang.Override + public GetChannelsRequest build() { + return new GetChannelsRequest(channelId, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/GetTransferOrdersRequest.java b/src/main/java/com/squareup/square/types/GetTransferOrdersRequest.java new file mode 100644 index 00000000..aff67216 --- /dev/null +++ b/src/main/java/com/squareup/square/types/GetTransferOrdersRequest.java @@ -0,0 +1,113 @@ +/** + * 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 = GetTransferOrdersRequest.Builder.class) +public final class GetTransferOrdersRequest { + private final String transferOrderId; + + private final Map additionalProperties; + + private GetTransferOrdersRequest(String transferOrderId, Map additionalProperties) { + this.transferOrderId = transferOrderId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the transfer order to retrieve + */ + @JsonProperty("transfer_order_id") + public String getTransferOrderId() { + return transferOrderId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetTransferOrdersRequest && equalTo((GetTransferOrdersRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetTransferOrdersRequest other) { + return transferOrderId.equals(other.transferOrderId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrderId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TransferOrderIdStage builder() { + return new Builder(); + } + + public interface TransferOrderIdStage { + /** + *

    The ID of the transfer order to retrieve

    + */ + _FinalStage transferOrderId(@NotNull String transferOrderId); + + Builder from(GetTransferOrdersRequest other); + } + + public interface _FinalStage { + GetTransferOrdersRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TransferOrderIdStage, _FinalStage { + private String transferOrderId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetTransferOrdersRequest other) { + transferOrderId(other.getTransferOrderId()); + return this; + } + + /** + *

    The ID of the transfer order to retrieve

    + *

    The ID of the transfer order to retrieve

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("transfer_order_id") + public _FinalStage transferOrderId(@NotNull String transferOrderId) { + this.transferOrderId = Objects.requireNonNull(transferOrderId, "transferOrderId must not be null"); + return this; + } + + @java.lang.Override + public GetTransferOrdersRequest build() { + return new GetTransferOrdersRequest(transferOrderId, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/ListChannelsRequest.java b/src/main/java/com/squareup/square/types/ListChannelsRequest.java new file mode 100644 index 00000000..784e4783 --- /dev/null +++ b/src/main/java/com/squareup/square/types/ListChannelsRequest.java @@ -0,0 +1,328 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = ListChannelsRequest.Builder.class) +public final class ListChannelsRequest { + private final Optional referenceType; + + private final Optional referenceId; + + private final Optional status; + + private final Optional cursor; + + private final Optional limit; + + private final Map additionalProperties; + + private ListChannelsRequest( + Optional referenceType, + Optional referenceId, + Optional status, + Optional cursor, + Optional limit, + Map additionalProperties) { + this.referenceType = referenceType; + this.referenceId = referenceId; + this.status = status; + this.cursor = cursor; + this.limit = limit; + this.additionalProperties = additionalProperties; + } + + /** + * @return Type of reference associated to channel + */ + @JsonIgnore + public Optional getReferenceType() { + if (referenceType == null) { + return Optional.empty(); + } + return referenceType; + } + + /** + * @return id of reference associated to channel + */ + @JsonIgnore + public Optional getReferenceId() { + if (referenceId == null) { + return Optional.empty(); + } + return referenceId; + } + + /** + * @return Status of channel + */ + @JsonIgnore + public Optional getStatus() { + if (status == null) { + return Optional.empty(); + } + return status; + } + + /** + * @return Cursor to fetch the next result + */ + @JsonIgnore + public Optional getCursor() { + if (cursor == null) { + return Optional.empty(); + } + return cursor; + } + + /** + * @return Maximum number of results to return. + * When not provided the returned results will be cap at 100 channels. + */ + @JsonIgnore + public Optional getLimit() { + if (limit == null) { + return Optional.empty(); + } + return limit; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("reference_type") + private Optional _getReferenceType() { + return referenceType; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("reference_id") + private Optional _getReferenceId() { + return referenceId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("status") + private Optional _getStatus() { + return status; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("cursor") + private Optional _getCursor() { + return cursor; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("limit") + private Optional _getLimit() { + return limit; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListChannelsRequest && equalTo((ListChannelsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListChannelsRequest other) { + return referenceType.equals(other.referenceType) + && referenceId.equals(other.referenceId) + && status.equals(other.status) + && cursor.equals(other.cursor) + && limit.equals(other.limit); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.referenceType, this.referenceId, this.status, this.cursor, this.limit); + } + + @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 referenceType = Optional.empty(); + + private Optional referenceId = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional cursor = Optional.empty(); + + private Optional limit = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListChannelsRequest other) { + referenceType(other.getReferenceType()); + referenceId(other.getReferenceId()); + status(other.getStatus()); + cursor(other.getCursor()); + limit(other.getLimit()); + return this; + } + + /** + *

    Type of reference associated to channel

    + */ + @JsonSetter(value = "reference_type", nulls = Nulls.SKIP) + public Builder referenceType(Optional referenceType) { + this.referenceType = referenceType; + return this; + } + + public Builder referenceType(ReferenceType referenceType) { + this.referenceType = Optional.ofNullable(referenceType); + return this; + } + + public Builder referenceType(Nullable referenceType) { + if (referenceType.isNull()) { + this.referenceType = null; + } else if (referenceType.isEmpty()) { + this.referenceType = Optional.empty(); + } else { + this.referenceType = Optional.of(referenceType.get()); + } + return this; + } + + /** + *

    id of reference associated to channel

    + */ + @JsonSetter(value = "reference_id", nulls = Nulls.SKIP) + public Builder referenceId(Optional referenceId) { + this.referenceId = referenceId; + return this; + } + + public Builder referenceId(String referenceId) { + this.referenceId = Optional.ofNullable(referenceId); + return this; + } + + public Builder referenceId(Nullable referenceId) { + if (referenceId.isNull()) { + this.referenceId = null; + } else if (referenceId.isEmpty()) { + this.referenceId = Optional.empty(); + } else { + this.referenceId = Optional.of(referenceId.get()); + } + return this; + } + + /** + *

    Status of channel

    + */ + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(ChannelStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + public Builder status(Nullable status) { + if (status.isNull()) { + this.status = null; + } else if (status.isEmpty()) { + this.status = Optional.empty(); + } else { + this.status = Optional.of(status.get()); + } + return this; + } + + /** + *

    Cursor to fetch the next result

    + */ + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); + return this; + } + + public Builder cursor(Nullable cursor) { + if (cursor.isNull()) { + this.cursor = null; + } else if (cursor.isEmpty()) { + this.cursor = Optional.empty(); + } else { + this.cursor = Optional.of(cursor.get()); + } + return this; + } + + /** + *

    Maximum number of results to return. + * When not provided the returned results will be cap at 100 channels.

    + */ + @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; + } + + public Builder limit(Nullable limit) { + if (limit.isNull()) { + this.limit = null; + } else if (limit.isEmpty()) { + this.limit = Optional.empty(); + } else { + this.limit = Optional.of(limit.get()); + } + return this; + } + + public ListChannelsRequest build() { + return new ListChannelsRequest(referenceType, referenceId, status, cursor, limit, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/ListChannelsResponse.java b/src/main/java/com/squareup/square/types/ListChannelsResponse.java new file mode 100644 index 00000000..20e37573 --- /dev/null +++ b/src/main/java/com/squareup/square/types/ListChannelsResponse.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.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListChannelsResponse.Builder.class) +public final class ListChannelsResponse { + private final Optional> errors; + + private final Optional> channels; + + private final Optional cursor; + + private final Map additionalProperties; + + private ListChannelsResponse( + Optional> errors, + Optional> channels, + Optional cursor, + Map additionalProperties) { + this.errors = errors; + this.channels = channels; + this.cursor = cursor; + this.additionalProperties = additionalProperties; + } + + /** + * @return Information about errors encountered during the request. + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + /** + * @return List of requested Channel. + */ + @JsonProperty("channels") + public Optional> getChannels() { + return channels; + } + + /** + * @return The token required to retrieve the next page of results. + */ + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListChannelsResponse && equalTo((ListChannelsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListChannelsResponse other) { + return errors.equals(other.errors) && channels.equals(other.channels) && cursor.equals(other.cursor); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.errors, this.channels, this.cursor); + } + + @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> errors = Optional.empty(); + + private Optional> channels = Optional.empty(); + + private Optional cursor = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListChannelsResponse other) { + errors(other.getErrors()); + channels(other.getChannels()); + cursor(other.getCursor()); + return this; + } + + /** + *

    Information about errors encountered during the request.

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + /** + *

    List of requested Channel.

    + */ + @JsonSetter(value = "channels", nulls = Nulls.SKIP) + public Builder channels(Optional> channels) { + this.channels = channels; + return this; + } + + public Builder channels(List channels) { + this.channels = Optional.ofNullable(channels); + return this; + } + + /** + *

    The token required to retrieve the next page of results.

    + */ + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); + return this; + } + + public ListChannelsResponse build() { + return new ListChannelsResponse(errors, channels, cursor, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/ReceiveTransferOrderRequest.java b/src/main/java/com/squareup/square/types/ReceiveTransferOrderRequest.java new file mode 100644 index 00000000..af5807be --- /dev/null +++ b/src/main/java/com/squareup/square/types/ReceiveTransferOrderRequest.java @@ -0,0 +1,231 @@ +/** + * 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 = ReceiveTransferOrderRequest.Builder.class) +public final class ReceiveTransferOrderRequest { + private final String transferOrderId; + + private final String idempotencyKey; + + private final TransferOrderGoodsReceipt receipt; + + private final Optional version; + + private final Map additionalProperties; + + private ReceiveTransferOrderRequest( + String transferOrderId, + String idempotencyKey, + TransferOrderGoodsReceipt receipt, + Optional version, + Map additionalProperties) { + this.transferOrderId = transferOrderId; + this.idempotencyKey = idempotencyKey; + this.receipt = receipt; + this.version = version; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the transfer order to receive items for + */ + @JsonProperty("transfer_order_id") + public String getTransferOrderId() { + return transferOrderId; + } + + /** + * @return A unique key to make this request idempotent + */ + @JsonProperty("idempotency_key") + public String getIdempotencyKey() { + return idempotencyKey; + } + + /** + * @return The receipt details + */ + @JsonProperty("receipt") + public TransferOrderGoodsReceipt getReceipt() { + return receipt; + } + + /** + * @return Version for optimistic concurrency + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReceiveTransferOrderRequest && equalTo((ReceiveTransferOrderRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReceiveTransferOrderRequest other) { + return transferOrderId.equals(other.transferOrderId) + && idempotencyKey.equals(other.idempotencyKey) + && receipt.equals(other.receipt) + && version.equals(other.version); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrderId, this.idempotencyKey, this.receipt, this.version); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TransferOrderIdStage builder() { + return new Builder(); + } + + public interface TransferOrderIdStage { + /** + *

    The ID of the transfer order to receive items for

    + */ + IdempotencyKeyStage transferOrderId(@NotNull String transferOrderId); + + Builder from(ReceiveTransferOrderRequest other); + } + + public interface IdempotencyKeyStage { + /** + *

    A unique key to make this request idempotent

    + */ + ReceiptStage idempotencyKey(@NotNull String idempotencyKey); + } + + public interface ReceiptStage { + /** + *

    The receipt details

    + */ + _FinalStage receipt(@NotNull TransferOrderGoodsReceipt receipt); + } + + public interface _FinalStage { + ReceiveTransferOrderRequest build(); + + /** + *

    Version for optimistic concurrency

    + */ + _FinalStage version(Optional version); + + _FinalStage version(Long version); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TransferOrderIdStage, IdempotencyKeyStage, ReceiptStage, _FinalStage { + private String transferOrderId; + + private String idempotencyKey; + + private TransferOrderGoodsReceipt receipt; + + private Optional version = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReceiveTransferOrderRequest other) { + transferOrderId(other.getTransferOrderId()); + idempotencyKey(other.getIdempotencyKey()); + receipt(other.getReceipt()); + version(other.getVersion()); + return this; + } + + /** + *

    The ID of the transfer order to receive items for

    + *

    The ID of the transfer order to receive items for

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

    A unique key to make this request idempotent

    + *

    A unique key to make this request idempotent

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

    The receipt details

    + *

    The receipt details

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

    Version for optimistic concurrency

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

    Version for optimistic concurrency

    + */ + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + @java.lang.Override + public ReceiveTransferOrderRequest build() { + return new ReceiveTransferOrderRequest( + transferOrderId, idempotencyKey, receipt, version, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/ReceiveTransferOrderResponse.java b/src/main/java/com/squareup/square/types/ReceiveTransferOrderResponse.java new file mode 100644 index 00000000..096ef3a5 --- /dev/null +++ b/src/main/java/com/squareup/square/types/ReceiveTransferOrderResponse.java @@ -0,0 +1,133 @@ +/** + * 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 = ReceiveTransferOrderResponse.Builder.class) +public final class ReceiveTransferOrderResponse { + private final Optional transferOrder; + + private final Optional> errors; + + private final Map additionalProperties; + + private ReceiveTransferOrderResponse( + Optional transferOrder, + Optional> errors, + Map additionalProperties) { + this.transferOrder = transferOrder; + this.errors = errors; + this.additionalProperties = additionalProperties; + } + + /** + * @return The updated transfer order + */ + @JsonProperty("transfer_order") + public Optional getTransferOrder() { + return transferOrder; + } + + /** + * @return Any errors that occurred during the request + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReceiveTransferOrderResponse && equalTo((ReceiveTransferOrderResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReceiveTransferOrderResponse other) { + return transferOrder.equals(other.transferOrder) && errors.equals(other.errors); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrder, this.errors); + } + + @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 transferOrder = Optional.empty(); + + private Optional> errors = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ReceiveTransferOrderResponse other) { + transferOrder(other.getTransferOrder()); + errors(other.getErrors()); + return this; + } + + /** + *

    The updated transfer order

    + */ + @JsonSetter(value = "transfer_order", nulls = Nulls.SKIP) + public Builder transferOrder(Optional transferOrder) { + this.transferOrder = transferOrder; + return this; + } + + public Builder transferOrder(TransferOrder transferOrder) { + this.transferOrder = Optional.ofNullable(transferOrder); + return this; + } + + /** + *

    Any errors that occurred during the request

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + public ReceiveTransferOrderResponse build() { + return new ReceiveTransferOrderResponse(transferOrder, errors, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/Reference.java b/src/main/java/com/squareup/square/types/Reference.java new file mode 100644 index 00000000..5f33591c --- /dev/null +++ b/src/main/java/com/squareup/square/types/Reference.java @@ -0,0 +1,131 @@ +/** + * 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 = Reference.Builder.class) +public final class Reference { + private final Optional type; + + private final Optional id; + + private final Map additionalProperties; + + private Reference(Optional type, Optional id, Map additionalProperties) { + this.type = type; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of entity a channel is associated with. + * See Type for possible values + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the entity a channel is associated with. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Reference && equalTo((Reference) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Reference other) { + return type.equals(other.type) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id); + } + + @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 type = Optional.empty(); + + private Optional id = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Reference other) { + type(other.getType()); + id(other.getId()); + return this; + } + + /** + *

    The type of entity a channel is associated with. + * See Type for possible values

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(ReferenceType type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

    The id of the entity a channel is associated with.

    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + public Reference build() { + return new Reference(type, id, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/ReferenceType.java b/src/main/java/com/squareup/square/types/ReferenceType.java new file mode 100644 index 00000000..37d61ac5 --- /dev/null +++ b/src/main/java/com/squareup/square/types/ReferenceType.java @@ -0,0 +1,218 @@ +/** + * 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 ReferenceType { + public static final ReferenceType ONLINE_SITE = new ReferenceType(Value.ONLINE_SITE, "ONLINE_SITE"); + + public static final ReferenceType FIRST_PARTY_INTEGRATION = + new ReferenceType(Value.FIRST_PARTY_INTEGRATION, "FIRST_PARTY_INTEGRATION"); + + public static final ReferenceType INVOICE = new ReferenceType(Value.INVOICE, "INVOICE"); + + public static final ReferenceType GIFT_CARD = new ReferenceType(Value.GIFT_CARD, "GIFT_CARD"); + + public static final ReferenceType UNKNOWN_TYPE = new ReferenceType(Value.UNKNOWN_TYPE, "UNKNOWN_TYPE"); + + public static final ReferenceType CASH_LOCAL = new ReferenceType(Value.CASH_LOCAL, "CASH_LOCAL"); + + public static final ReferenceType LOCATION = new ReferenceType(Value.LOCATION, "LOCATION"); + + public static final ReferenceType ONLINE_CHECKOUT = new ReferenceType(Value.ONLINE_CHECKOUT, "ONLINE_CHECKOUT"); + + public static final ReferenceType GIFT_CARD_MARKETPLACE = + new ReferenceType(Value.GIFT_CARD_MARKETPLACE, "GIFT_CARD_MARKETPLACE"); + + public static final ReferenceType KIOSK = new ReferenceType(Value.KIOSK, "KIOSK"); + + public static final ReferenceType POINT_OF_SALE = new ReferenceType(Value.POINT_OF_SALE, "POINT_OF_SALE"); + + public static final ReferenceType RECURRING_SUBSCRIPTION = + new ReferenceType(Value.RECURRING_SUBSCRIPTION, "RECURRING_SUBSCRIPTION"); + + public static final ReferenceType ONLINE_BOOKING_FLOW = + new ReferenceType(Value.ONLINE_BOOKING_FLOW, "ONLINE_BOOKING_FLOW"); + + public static final ReferenceType OAUTH_APPLICATION = + new ReferenceType(Value.OAUTH_APPLICATION, "OAUTH_APPLICATION"); + + public static final ReferenceType SQUARE_ASSISTANT = new ReferenceType(Value.SQUARE_ASSISTANT, "SQUARE_ASSISTANT"); + + private final Value value; + + private final String string; + + ReferenceType(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 ReferenceType && this.string.equals(((ReferenceType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ONLINE_SITE: + return visitor.visitOnlineSite(); + case FIRST_PARTY_INTEGRATION: + return visitor.visitFirstPartyIntegration(); + case INVOICE: + return visitor.visitInvoice(); + case GIFT_CARD: + return visitor.visitGiftCard(); + case UNKNOWN_TYPE: + return visitor.visitUnknownType(); + case CASH_LOCAL: + return visitor.visitCashLocal(); + case LOCATION: + return visitor.visitLocation(); + case ONLINE_CHECKOUT: + return visitor.visitOnlineCheckout(); + case GIFT_CARD_MARKETPLACE: + return visitor.visitGiftCardMarketplace(); + case KIOSK: + return visitor.visitKiosk(); + case POINT_OF_SALE: + return visitor.visitPointOfSale(); + case RECURRING_SUBSCRIPTION: + return visitor.visitRecurringSubscription(); + case ONLINE_BOOKING_FLOW: + return visitor.visitOnlineBookingFlow(); + case OAUTH_APPLICATION: + return visitor.visitOauthApplication(); + case SQUARE_ASSISTANT: + return visitor.visitSquareAssistant(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ReferenceType valueOf(String value) { + switch (value) { + case "ONLINE_SITE": + return ONLINE_SITE; + case "FIRST_PARTY_INTEGRATION": + return FIRST_PARTY_INTEGRATION; + case "INVOICE": + return INVOICE; + case "GIFT_CARD": + return GIFT_CARD; + case "UNKNOWN_TYPE": + return UNKNOWN_TYPE; + case "CASH_LOCAL": + return CASH_LOCAL; + case "LOCATION": + return LOCATION; + case "ONLINE_CHECKOUT": + return ONLINE_CHECKOUT; + case "GIFT_CARD_MARKETPLACE": + return GIFT_CARD_MARKETPLACE; + case "KIOSK": + return KIOSK; + case "POINT_OF_SALE": + return POINT_OF_SALE; + case "RECURRING_SUBSCRIPTION": + return RECURRING_SUBSCRIPTION; + case "ONLINE_BOOKING_FLOW": + return ONLINE_BOOKING_FLOW; + case "OAUTH_APPLICATION": + return OAUTH_APPLICATION; + case "SQUARE_ASSISTANT": + return SQUARE_ASSISTANT; + default: + return new ReferenceType(Value.UNKNOWN, value); + } + } + + public enum Value { + UNKNOWN_TYPE, + + LOCATION, + + FIRST_PARTY_INTEGRATION, + + OAUTH_APPLICATION, + + ONLINE_SITE, + + ONLINE_CHECKOUT, + + INVOICE, + + GIFT_CARD, + + GIFT_CARD_MARKETPLACE, + + RECURRING_SUBSCRIPTION, + + ONLINE_BOOKING_FLOW, + + SQUARE_ASSISTANT, + + CASH_LOCAL, + + POINT_OF_SALE, + + KIOSK, + + UNKNOWN + } + + public interface Visitor { + T visitUnknownType(); + + T visitLocation(); + + T visitFirstPartyIntegration(); + + T visitOauthApplication(); + + T visitOnlineSite(); + + T visitOnlineCheckout(); + + T visitInvoice(); + + T visitGiftCard(); + + T visitGiftCardMarketplace(); + + T visitRecurringSubscription(); + + T visitOnlineBookingFlow(); + + T visitSquareAssistant(); + + T visitCashLocal(); + + T visitPointOfSale(); + + T visitKiosk(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/squareup/square/types/RetrieveChannelResponse.java b/src/main/java/com/squareup/square/types/RetrieveChannelResponse.java new file mode 100644 index 00000000..3519b563 --- /dev/null +++ b/src/main/java/com/squareup/square/types/RetrieveChannelResponse.java @@ -0,0 +1,131 @@ +/** + * 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 = RetrieveChannelResponse.Builder.class) +public final class RetrieveChannelResponse { + private final Optional> errors; + + private final Optional channel; + + private final Map additionalProperties; + + private RetrieveChannelResponse( + Optional> errors, Optional channel, Map additionalProperties) { + this.errors = errors; + this.channel = channel; + this.additionalProperties = additionalProperties; + } + + /** + * @return Information about errors encountered during the request. + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + /** + * @return The requested Channel. + */ + @JsonProperty("channel") + public Optional getChannel() { + return channel; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveChannelResponse && equalTo((RetrieveChannelResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveChannelResponse other) { + return errors.equals(other.errors) && channel.equals(other.channel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.errors, this.channel); + } + + @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> errors = Optional.empty(); + + private Optional channel = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RetrieveChannelResponse other) { + errors(other.getErrors()); + channel(other.getChannel()); + return this; + } + + /** + *

    Information about errors encountered during the request.

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + /** + *

    The requested Channel.

    + */ + @JsonSetter(value = "channel", nulls = Nulls.SKIP) + public Builder channel(Optional channel) { + this.channel = channel; + return this; + } + + public Builder channel(Channel channel) { + this.channel = Optional.ofNullable(channel); + return this; + } + + public RetrieveChannelResponse build() { + return new RetrieveChannelResponse(errors, channel, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/RetrieveTransferOrderResponse.java b/src/main/java/com/squareup/square/types/RetrieveTransferOrderResponse.java new file mode 100644 index 00000000..c01efa96 --- /dev/null +++ b/src/main/java/com/squareup/square/types/RetrieveTransferOrderResponse.java @@ -0,0 +1,133 @@ +/** + * 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 = RetrieveTransferOrderResponse.Builder.class) +public final class RetrieveTransferOrderResponse { + private final Optional transferOrder; + + private final Optional> errors; + + private final Map additionalProperties; + + private RetrieveTransferOrderResponse( + Optional transferOrder, + Optional> errors, + Map additionalProperties) { + this.transferOrder = transferOrder; + this.errors = errors; + this.additionalProperties = additionalProperties; + } + + /** + * @return The requested transfer order + */ + @JsonProperty("transfer_order") + public Optional getTransferOrder() { + return transferOrder; + } + + /** + * @return Any errors that occurred during the request + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveTransferOrderResponse && equalTo((RetrieveTransferOrderResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveTransferOrderResponse other) { + return transferOrder.equals(other.transferOrder) && errors.equals(other.errors); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrder, this.errors); + } + + @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 transferOrder = Optional.empty(); + + private Optional> errors = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RetrieveTransferOrderResponse other) { + transferOrder(other.getTransferOrder()); + errors(other.getErrors()); + return this; + } + + /** + *

    The requested transfer order

    + */ + @JsonSetter(value = "transfer_order", nulls = Nulls.SKIP) + public Builder transferOrder(Optional transferOrder) { + this.transferOrder = transferOrder; + return this; + } + + public Builder transferOrder(TransferOrder transferOrder) { + this.transferOrder = Optional.ofNullable(transferOrder); + return this; + } + + /** + *

    Any errors that occurred during the request

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + public RetrieveTransferOrderResponse build() { + return new RetrieveTransferOrderResponse(transferOrder, errors, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/SearchTransferOrdersRequest.java b/src/main/java/com/squareup/square/types/SearchTransferOrdersRequest.java new file mode 100644 index 00000000..3f5bc659 --- /dev/null +++ b/src/main/java/com/squareup/square/types/SearchTransferOrdersRequest.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.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SearchTransferOrdersRequest.Builder.class) +public final class SearchTransferOrdersRequest { + private final Optional query; + + private final Optional cursor; + + private final Optional limit; + + private final Map additionalProperties; + + private SearchTransferOrdersRequest( + Optional query, + Optional cursor, + Optional limit, + Map additionalProperties) { + this.query = query; + this.cursor = cursor; + this.limit = limit; + this.additionalProperties = additionalProperties; + } + + /** + * @return The search query + */ + @JsonProperty("query") + public Optional getQuery() { + return query; + } + + /** + * @return Pagination cursor from a previous search response + */ + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; + } + + /** + * @return Maximum number of results to return (1-100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SearchTransferOrdersRequest && equalTo((SearchTransferOrdersRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SearchTransferOrdersRequest other) { + return query.equals(other.query) && cursor.equals(other.cursor) && limit.equals(other.limit); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.query, this.cursor, this.limit); + } + + @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 query = Optional.empty(); + + private Optional cursor = Optional.empty(); + + private Optional limit = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SearchTransferOrdersRequest other) { + query(other.getQuery()); + cursor(other.getCursor()); + limit(other.getLimit()); + return this; + } + + /** + *

    The search query

    + */ + @JsonSetter(value = "query", nulls = Nulls.SKIP) + public Builder query(Optional query) { + this.query = query; + return this; + } + + public Builder query(TransferOrderQuery query) { + this.query = Optional.ofNullable(query); + return this; + } + + /** + *

    Pagination cursor from a previous search response

    + */ + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); + return this; + } + + /** + *

    Maximum number of results to return (1-100)

    + */ + @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; + } + + public SearchTransferOrdersRequest build() { + return new SearchTransferOrdersRequest(query, cursor, limit, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/SearchTransferOrdersResponse.java b/src/main/java/com/squareup/square/types/SearchTransferOrdersResponse.java new file mode 100644 index 00000000..fbda5b4d --- /dev/null +++ b/src/main/java/com/squareup/square/types/SearchTransferOrdersResponse.java @@ -0,0 +1,164 @@ +/** + * 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 = SearchTransferOrdersResponse.Builder.class) +public final class SearchTransferOrdersResponse { + private final Optional> transferOrders; + + private final Optional cursor; + + private final Optional> errors; + + private final Map additionalProperties; + + private SearchTransferOrdersResponse( + Optional> transferOrders, + Optional cursor, + Optional> errors, + Map additionalProperties) { + this.transferOrders = transferOrders; + this.cursor = cursor; + this.errors = errors; + this.additionalProperties = additionalProperties; + } + + /** + * @return List of transfer orders matching the search criteria + */ + @JsonProperty("transfer_orders") + public Optional> getTransferOrders() { + return transferOrders; + } + + /** + * @return Pagination cursor for fetching the next page of results + */ + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; + } + + /** + * @return Any errors that occurred during the request + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SearchTransferOrdersResponse && equalTo((SearchTransferOrdersResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SearchTransferOrdersResponse other) { + return transferOrders.equals(other.transferOrders) + && cursor.equals(other.cursor) + && errors.equals(other.errors); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrders, this.cursor, this.errors); + } + + @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> transferOrders = Optional.empty(); + + private Optional cursor = Optional.empty(); + + private Optional> errors = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SearchTransferOrdersResponse other) { + transferOrders(other.getTransferOrders()); + cursor(other.getCursor()); + errors(other.getErrors()); + return this; + } + + /** + *

    List of transfer orders matching the search criteria

    + */ + @JsonSetter(value = "transfer_orders", nulls = Nulls.SKIP) + public Builder transferOrders(Optional> transferOrders) { + this.transferOrders = transferOrders; + return this; + } + + public Builder transferOrders(List transferOrders) { + this.transferOrders = Optional.ofNullable(transferOrders); + return this; + } + + /** + *

    Pagination cursor for fetching the next page of results

    + */ + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); + return this; + } + + /** + *

    Any errors that occurred during the request

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + public SearchTransferOrdersResponse build() { + return new SearchTransferOrdersResponse(transferOrders, cursor, errors, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/StartTransferOrderRequest.java b/src/main/java/com/squareup/square/types/StartTransferOrderRequest.java new file mode 100644 index 00000000..00797a50 --- /dev/null +++ b/src/main/java/com/squareup/square/types/StartTransferOrderRequest.java @@ -0,0 +1,199 @@ +/** + * 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 = StartTransferOrderRequest.Builder.class) +public final class StartTransferOrderRequest { + private final String transferOrderId; + + private final String idempotencyKey; + + private final Optional version; + + private final Map additionalProperties; + + private StartTransferOrderRequest( + String transferOrderId, + String idempotencyKey, + Optional version, + Map additionalProperties) { + this.transferOrderId = transferOrderId; + this.idempotencyKey = idempotencyKey; + this.version = version; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the transfer order to start. Must be in DRAFT status. + */ + @JsonProperty("transfer_order_id") + public String getTransferOrderId() { + return transferOrderId; + } + + /** + * @return A unique string that identifies this UpdateTransferOrder request. Keys can be + * any valid string but must be unique for every UpdateTransferOrder request. + */ + @JsonProperty("idempotency_key") + public String getIdempotencyKey() { + return idempotencyKey; + } + + /** + * @return Version for optimistic concurrency + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StartTransferOrderRequest && equalTo((StartTransferOrderRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(StartTransferOrderRequest other) { + return transferOrderId.equals(other.transferOrderId) + && idempotencyKey.equals(other.idempotencyKey) + && version.equals(other.version); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrderId, this.idempotencyKey, this.version); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TransferOrderIdStage builder() { + return new Builder(); + } + + public interface TransferOrderIdStage { + /** + *

    The ID of the transfer order to start. Must be in DRAFT status.

    + */ + IdempotencyKeyStage transferOrderId(@NotNull String transferOrderId); + + Builder from(StartTransferOrderRequest other); + } + + public interface IdempotencyKeyStage { + /** + *

    A unique string that identifies this UpdateTransferOrder request. Keys can be + * any valid string but must be unique for every UpdateTransferOrder request.

    + */ + _FinalStage idempotencyKey(@NotNull String idempotencyKey); + } + + public interface _FinalStage { + StartTransferOrderRequest build(); + + /** + *

    Version for optimistic concurrency

    + */ + _FinalStage version(Optional version); + + _FinalStage version(Long version); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TransferOrderIdStage, IdempotencyKeyStage, _FinalStage { + private String transferOrderId; + + private String idempotencyKey; + + private Optional version = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(StartTransferOrderRequest other) { + transferOrderId(other.getTransferOrderId()); + idempotencyKey(other.getIdempotencyKey()); + version(other.getVersion()); + return this; + } + + /** + *

    The ID of the transfer order to start. Must be in DRAFT status.

    + *

    The ID of the transfer order to start. Must be in DRAFT status.

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

    A unique string that identifies this UpdateTransferOrder request. Keys can be + * any valid string but must be unique for every UpdateTransferOrder request.

    + *

    A unique string that identifies this UpdateTransferOrder request. Keys can be + * any valid string but must be unique for every UpdateTransferOrder request.

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

    Version for optimistic concurrency

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

    Version for optimistic concurrency

    + */ + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + @java.lang.Override + public StartTransferOrderRequest build() { + return new StartTransferOrderRequest(transferOrderId, idempotencyKey, version, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/StartTransferOrderResponse.java b/src/main/java/com/squareup/square/types/StartTransferOrderResponse.java new file mode 100644 index 00000000..17517fa3 --- /dev/null +++ b/src/main/java/com/squareup/square/types/StartTransferOrderResponse.java @@ -0,0 +1,133 @@ +/** + * 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 = StartTransferOrderResponse.Builder.class) +public final class StartTransferOrderResponse { + private final Optional transferOrder; + + private final Optional> errors; + + private final Map additionalProperties; + + private StartTransferOrderResponse( + Optional transferOrder, + Optional> errors, + Map additionalProperties) { + this.transferOrder = transferOrder; + this.errors = errors; + this.additionalProperties = additionalProperties; + } + + /** + * @return The updated transfer order with status changed to STARTED + */ + @JsonProperty("transfer_order") + public Optional getTransferOrder() { + return transferOrder; + } + + /** + * @return Any errors that occurred during the request + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StartTransferOrderResponse && equalTo((StartTransferOrderResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(StartTransferOrderResponse other) { + return transferOrder.equals(other.transferOrder) && errors.equals(other.errors); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrder, this.errors); + } + + @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 transferOrder = Optional.empty(); + + private Optional> errors = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(StartTransferOrderResponse other) { + transferOrder(other.getTransferOrder()); + errors(other.getErrors()); + return this; + } + + /** + *

    The updated transfer order with status changed to STARTED

    + */ + @JsonSetter(value = "transfer_order", nulls = Nulls.SKIP) + public Builder transferOrder(Optional transferOrder) { + this.transferOrder = transferOrder; + return this; + } + + public Builder transferOrder(TransferOrder transferOrder) { + this.transferOrder = Optional.ofNullable(transferOrder); + return this; + } + + /** + *

    Any errors that occurred during the request

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + public StartTransferOrderResponse build() { + return new StartTransferOrderResponse(transferOrder, errors, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrder.java b/src/main/java/com/squareup/square/types/TransferOrder.java new file mode 100644 index 00000000..23cfa9bd --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrder.java @@ -0,0 +1,714 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrder.Builder.class) +public final class TransferOrder { + private final Optional id; + + private final Optional sourceLocationId; + + private final Optional destinationLocationId; + + private final Optional status; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional expectedAt; + + private final Optional completedAt; + + private final Optional notes; + + private final Optional trackingNumber; + + private final Optional createdByTeamMemberId; + + private final Optional> lineItems; + + private final Optional version; + + private final Map additionalProperties; + + private TransferOrder( + Optional id, + Optional sourceLocationId, + Optional destinationLocationId, + Optional status, + Optional createdAt, + Optional updatedAt, + Optional expectedAt, + Optional completedAt, + Optional notes, + Optional trackingNumber, + Optional createdByTeamMemberId, + Optional> lineItems, + Optional version, + Map additionalProperties) { + this.id = id; + this.sourceLocationId = sourceLocationId; + this.destinationLocationId = destinationLocationId; + this.status = status; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.expectedAt = expectedAt; + this.completedAt = completedAt; + this.notes = notes; + this.trackingNumber = trackingNumber; + this.createdByTeamMemberId = createdByTeamMemberId; + this.lineItems = lineItems; + this.version = version; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique system-generated identifier for this transfer order. Use this ID for: + *
      + *
    • Retrieving transfer order details
    • + *
    • Tracking status changes via webhooks
    • + *
    • Linking transfers in external systems
    • + *
    + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The source Location sending the CatalogItemVariations. + * This location must: + *
      + *
    • Be active in your Square organization
    • + *
    • Have sufficient inventory for the items being transferred
    • + *
    • Not be the same as the destination location
    • + *
    + *

    This field is not updatable.

    + */ + @JsonIgnore + public Optional getSourceLocationId() { + if (sourceLocationId == null) { + return Optional.empty(); + } + return sourceLocationId; + } + + /** + * @return The destination Location receiving the CatalogItemVariations. + * This location must: + *
      + *
    • Be active in your Square organization
    • + *
    • Not be the same as the source location
    • + *
    + *

    This field is not updatable.

    + */ + @JsonIgnore + public Optional getDestinationLocationId() { + if (destinationLocationId == null) { + return Optional.empty(); + } + return destinationLocationId; + } + + /** + * @return Current TransferOrderStatus indicating where the order is in its lifecycle. + * Status transitions follow this progression: + *
      + *
    1. DRAFT -> STARTED via StartTransferOrder
    2. + *
    3. STARTED -> PARTIALLY_RECEIVED via ReceiveTransferOrder
    4. + *
    5. PARTIALLY_RECEIVED -> COMPLETED after all items received
    6. + *
    + *

    Orders can be CANCELED from STARTED or + * PARTIALLY_RECEIVED status.

    + *

    This field is read-only and reflects the current state of the transfer order, and cannot be updated directly. Use the appropriate + * endpoints (e.g. StartPurchaseOrder, to change the status. + * See TransferOrderStatus for possible values

    + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return Timestamp when the transfer order was created, in RFC 3339 format. + * Used for: + *
      + *
    • Auditing transfer history
    • + *
    • Tracking order age
    • + *
    • Reporting and analytics
    • + *
    + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Timestamp when the transfer order was last updated, in RFC 3339 format. + * Updated when: + *
      + *
    • Order status changes
    • + *
    • Items are received
    • + *
    • Notes or metadata are modified
    • + *
    + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return Expected transfer completion date, in RFC 3339 format. + * Used for: + *
      + *
    • Planning inventory availability
    • + *
    • Scheduling receiving staff
    • + *
    • Monitoring transfer timeliness
    • + *
    + */ + @JsonIgnore + public Optional getExpectedAt() { + if (expectedAt == null) { + return Optional.empty(); + } + return expectedAt; + } + + /** + * @return Timestamp when the transfer order was completed or canceled, in RFC 3339 format (e.g. "2023-10-01T12:00:00Z"). + */ + @JsonProperty("completed_at") + public Optional getCompletedAt() { + return completedAt; + } + + /** + * @return Optional notes about the transfer. + */ + @JsonIgnore + public Optional getNotes() { + if (notes == null) { + return Optional.empty(); + } + return notes; + } + + /** + * @return Shipment tracking number for monitoring transfer progress. + */ + @JsonIgnore + public Optional getTrackingNumber() { + if (trackingNumber == null) { + return Optional.empty(); + } + return trackingNumber; + } + + /** + * @return ID of the TeamMember who created this transfer order. This field is not writeable by the Connect V2 API. + */ + @JsonProperty("created_by_team_member_id") + public Optional getCreatedByTeamMemberId() { + return createdByTeamMemberId; + } + + /** + * @return List of CatalogItemVariations being transferred. + */ + @JsonIgnore + public Optional> getLineItems() { + if (lineItems == null) { + return Optional.empty(); + } + return lineItems; + } + + /** + * @return Version for optimistic concurrency control. This is a monotonically increasing integer + * that changes whenever the transfer order is modified. Use this when calling + * UpdateTransferOrder and other endpoints to ensure you're + * not overwriting concurrent changes. + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("source_location_id") + private Optional _getSourceLocationId() { + return sourceLocationId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("destination_location_id") + private Optional _getDestinationLocationId() { + return destinationLocationId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("expected_at") + private Optional _getExpectedAt() { + return expectedAt; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("notes") + private Optional _getNotes() { + return notes; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("tracking_number") + private Optional _getTrackingNumber() { + return trackingNumber; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("line_items") + private Optional> _getLineItems() { + return lineItems; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrder && equalTo((TransferOrder) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrder other) { + return id.equals(other.id) + && sourceLocationId.equals(other.sourceLocationId) + && destinationLocationId.equals(other.destinationLocationId) + && status.equals(other.status) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && expectedAt.equals(other.expectedAt) + && completedAt.equals(other.completedAt) + && notes.equals(other.notes) + && trackingNumber.equals(other.trackingNumber) + && createdByTeamMemberId.equals(other.createdByTeamMemberId) + && lineItems.equals(other.lineItems) + && version.equals(other.version); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.sourceLocationId, + this.destinationLocationId, + this.status, + this.createdAt, + this.updatedAt, + this.expectedAt, + this.completedAt, + this.notes, + this.trackingNumber, + this.createdByTeamMemberId, + this.lineItems, + this.version); + } + + @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 id = Optional.empty(); + + private Optional sourceLocationId = Optional.empty(); + + private Optional destinationLocationId = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional expectedAt = Optional.empty(); + + private Optional completedAt = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional trackingNumber = Optional.empty(); + + private Optional createdByTeamMemberId = Optional.empty(); + + private Optional> lineItems = Optional.empty(); + + private Optional version = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrder other) { + id(other.getId()); + sourceLocationId(other.getSourceLocationId()); + destinationLocationId(other.getDestinationLocationId()); + status(other.getStatus()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + expectedAt(other.getExpectedAt()); + completedAt(other.getCompletedAt()); + notes(other.getNotes()); + trackingNumber(other.getTrackingNumber()); + createdByTeamMemberId(other.getCreatedByTeamMemberId()); + lineItems(other.getLineItems()); + version(other.getVersion()); + return this; + } + + /** + *

    Unique system-generated identifier for this transfer order. Use this ID for:

    + *
      + *
    • Retrieving transfer order details
    • + *
    • Tracking status changes via webhooks
    • + *
    • Linking transfers in external systems
    • + *
    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

    The source Location sending the CatalogItemVariations. + * This location must:

    + *
      + *
    • Be active in your Square organization
    • + *
    • Have sufficient inventory for the items being transferred
    • + *
    • Not be the same as the destination location
    • + *
    + *

    This field is not updatable.

    + */ + @JsonSetter(value = "source_location_id", nulls = Nulls.SKIP) + public Builder sourceLocationId(Optional sourceLocationId) { + this.sourceLocationId = sourceLocationId; + return this; + } + + public Builder sourceLocationId(String sourceLocationId) { + this.sourceLocationId = Optional.ofNullable(sourceLocationId); + return this; + } + + public Builder sourceLocationId(Nullable sourceLocationId) { + if (sourceLocationId.isNull()) { + this.sourceLocationId = null; + } else if (sourceLocationId.isEmpty()) { + this.sourceLocationId = Optional.empty(); + } else { + this.sourceLocationId = Optional.of(sourceLocationId.get()); + } + return this; + } + + /** + *

    The destination Location receiving the CatalogItemVariations. + * This location must:

    + *
      + *
    • Be active in your Square organization
    • + *
    • Not be the same as the source location
    • + *
    + *

    This field is not updatable.

    + */ + @JsonSetter(value = "destination_location_id", nulls = Nulls.SKIP) + public Builder destinationLocationId(Optional destinationLocationId) { + this.destinationLocationId = destinationLocationId; + return this; + } + + public Builder destinationLocationId(String destinationLocationId) { + this.destinationLocationId = Optional.ofNullable(destinationLocationId); + return this; + } + + public Builder destinationLocationId(Nullable destinationLocationId) { + if (destinationLocationId.isNull()) { + this.destinationLocationId = null; + } else if (destinationLocationId.isEmpty()) { + this.destinationLocationId = Optional.empty(); + } else { + this.destinationLocationId = Optional.of(destinationLocationId.get()); + } + return this; + } + + /** + *

    Current TransferOrderStatus indicating where the order is in its lifecycle. + * Status transitions follow this progression:

    + *
      + *
    1. DRAFT -> STARTED via StartTransferOrder
    2. + *
    3. STARTED -> PARTIALLY_RECEIVED via ReceiveTransferOrder
    4. + *
    5. PARTIALLY_RECEIVED -> COMPLETED after all items received
    6. + *
    + *

    Orders can be CANCELED from STARTED or + * PARTIALLY_RECEIVED status.

    + *

    This field is read-only and reflects the current state of the transfer order, and cannot be updated directly. Use the appropriate + * endpoints (e.g. StartPurchaseOrder, to change the status. + * See TransferOrderStatus for possible values

    + */ + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(TransferOrderStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + /** + *

    Timestamp when the transfer order was created, in RFC 3339 format. + * Used for:

    + *
      + *
    • Auditing transfer history
    • + *
    • Tracking order age
    • + *
    • Reporting and analytics
    • + *
    + */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(String createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    Timestamp when the transfer order was last updated, in RFC 3339 format. + * Updated when:

    + *
      + *
    • Order status changes
    • + *
    • Items are received
    • + *
    • Notes or metadata are modified
    • + *
    + */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(String updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

    Expected transfer completion date, in RFC 3339 format. + * Used for:

    + *
      + *
    • Planning inventory availability
    • + *
    • Scheduling receiving staff
    • + *
    • Monitoring transfer timeliness
    • + *
    + */ + @JsonSetter(value = "expected_at", nulls = Nulls.SKIP) + public Builder expectedAt(Optional expectedAt) { + this.expectedAt = expectedAt; + return this; + } + + public Builder expectedAt(String expectedAt) { + this.expectedAt = Optional.ofNullable(expectedAt); + return this; + } + + public Builder expectedAt(Nullable expectedAt) { + if (expectedAt.isNull()) { + this.expectedAt = null; + } else if (expectedAt.isEmpty()) { + this.expectedAt = Optional.empty(); + } else { + this.expectedAt = Optional.of(expectedAt.get()); + } + return this; + } + + /** + *

    Timestamp when the transfer order was completed or canceled, in RFC 3339 format (e.g. "2023-10-01T12:00:00Z").

    + */ + @JsonSetter(value = "completed_at", nulls = Nulls.SKIP) + public Builder completedAt(Optional completedAt) { + this.completedAt = completedAt; + return this; + } + + public Builder completedAt(String completedAt) { + this.completedAt = Optional.ofNullable(completedAt); + return this; + } + + /** + *

    Optional notes about the transfer.

    + */ + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(String notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + public Builder notes(Nullable notes) { + if (notes.isNull()) { + this.notes = null; + } else if (notes.isEmpty()) { + this.notes = Optional.empty(); + } else { + this.notes = Optional.of(notes.get()); + } + return this; + } + + /** + *

    Shipment tracking number for monitoring transfer progress.

    + */ + @JsonSetter(value = "tracking_number", nulls = Nulls.SKIP) + public Builder trackingNumber(Optional trackingNumber) { + this.trackingNumber = trackingNumber; + return this; + } + + public Builder trackingNumber(String trackingNumber) { + this.trackingNumber = Optional.ofNullable(trackingNumber); + return this; + } + + public Builder trackingNumber(Nullable trackingNumber) { + if (trackingNumber.isNull()) { + this.trackingNumber = null; + } else if (trackingNumber.isEmpty()) { + this.trackingNumber = Optional.empty(); + } else { + this.trackingNumber = Optional.of(trackingNumber.get()); + } + return this; + } + + /** + *

    ID of the TeamMember who created this transfer order. This field is not writeable by the Connect V2 API.

    + */ + @JsonSetter(value = "created_by_team_member_id", nulls = Nulls.SKIP) + public Builder createdByTeamMemberId(Optional createdByTeamMemberId) { + this.createdByTeamMemberId = createdByTeamMemberId; + return this; + } + + public Builder createdByTeamMemberId(String createdByTeamMemberId) { + this.createdByTeamMemberId = Optional.ofNullable(createdByTeamMemberId); + return this; + } + + /** + *

    List of CatalogItemVariations being transferred.

    + */ + @JsonSetter(value = "line_items", nulls = Nulls.SKIP) + public Builder lineItems(Optional> lineItems) { + this.lineItems = lineItems; + return this; + } + + public Builder lineItems(List lineItems) { + this.lineItems = Optional.ofNullable(lineItems); + return this; + } + + public Builder lineItems(Nullable> lineItems) { + if (lineItems.isNull()) { + this.lineItems = null; + } else if (lineItems.isEmpty()) { + this.lineItems = Optional.empty(); + } else { + this.lineItems = Optional.of(lineItems.get()); + } + return this; + } + + /** + *

    Version for optimistic concurrency control. This is a monotonically increasing integer + * that changes whenever the transfer order is modified. Use this when calling + * UpdateTransferOrder and other endpoints to ensure you're + * not overwriting concurrent changes.

    + */ + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public Builder version(Optional version) { + this.version = version; + return this; + } + + public Builder version(Long version) { + this.version = Optional.ofNullable(version); + return this; + } + + public TransferOrder build() { + return new TransferOrder( + id, + sourceLocationId, + destinationLocationId, + status, + createdAt, + updatedAt, + expectedAt, + completedAt, + notes, + trackingNumber, + createdByTeamMemberId, + lineItems, + version, + additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderCreatedEvent.java b/src/main/java/com/squareup/square/types/TransferOrderCreatedEvent.java new file mode 100644 index 00000000..a0f89be4 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderCreatedEvent.java @@ -0,0 +1,286 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrderCreatedEvent.Builder.class) +public final class TransferOrderCreatedEvent { + private final Optional merchantId; + + private final Optional type; + + private final Optional eventId; + + private final Optional createdAt; + + private final Optional data; + + private final Map additionalProperties; + + private TransferOrderCreatedEvent( + Optional merchantId, + Optional type, + Optional eventId, + Optional createdAt, + Optional data, + Map additionalProperties) { + this.merchantId = merchantId; + this.type = type; + this.eventId = eventId; + this.createdAt = createdAt; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the target merchant associated with the event. + */ + @JsonIgnore + public Optional getMerchantId() { + if (merchantId == null) { + return Optional.empty(); + } + return merchantId; + } + + /** + * @return The type of event this represents, "transfer_order.created". + */ + @JsonIgnore + public Optional getType() { + if (type == null) { + return Optional.empty(); + } + return type; + } + + /** + * @return A unique ID for the event. + */ + @JsonIgnore + public Optional getEventId() { + if (eventId == null) { + return Optional.empty(); + } + return eventId; + } + + /** + * @return Timestamp of when the event was created, in RFC 3339 format. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Data associated with the event. + */ + @JsonProperty("data") + public Optional getData() { + return data; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("merchant_id") + private Optional _getMerchantId() { + return merchantId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("type") + private Optional _getType() { + return type; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("event_id") + private Optional _getEventId() { + return eventId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderCreatedEvent && equalTo((TransferOrderCreatedEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderCreatedEvent other) { + return merchantId.equals(other.merchantId) + && type.equals(other.type) + && eventId.equals(other.eventId) + && createdAt.equals(other.createdAt) + && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.merchantId, this.type, this.eventId, this.createdAt, this.data); + } + + @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 merchantId = Optional.empty(); + + private Optional type = Optional.empty(); + + private Optional eventId = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderCreatedEvent other) { + merchantId(other.getMerchantId()); + type(other.getType()); + eventId(other.getEventId()); + createdAt(other.getCreatedAt()); + data(other.getData()); + return this; + } + + /** + *

    The ID of the target merchant associated with the event.

    + */ + @JsonSetter(value = "merchant_id", nulls = Nulls.SKIP) + public Builder merchantId(Optional merchantId) { + this.merchantId = merchantId; + return this; + } + + public Builder merchantId(String merchantId) { + this.merchantId = Optional.ofNullable(merchantId); + return this; + } + + public Builder merchantId(Nullable merchantId) { + if (merchantId.isNull()) { + this.merchantId = null; + } else if (merchantId.isEmpty()) { + this.merchantId = Optional.empty(); + } else { + this.merchantId = Optional.of(merchantId.get()); + } + return this; + } + + /** + *

    The type of event this represents, "transfer_order.created".

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + public Builder type(Nullable type) { + if (type.isNull()) { + this.type = null; + } else if (type.isEmpty()) { + this.type = Optional.empty(); + } else { + this.type = Optional.of(type.get()); + } + return this; + } + + /** + *

    A unique ID for the event.

    + */ + @JsonSetter(value = "event_id", nulls = Nulls.SKIP) + public Builder eventId(Optional eventId) { + this.eventId = eventId; + return this; + } + + public Builder eventId(String eventId) { + this.eventId = Optional.ofNullable(eventId); + return this; + } + + public Builder eventId(Nullable eventId) { + if (eventId.isNull()) { + this.eventId = null; + } else if (eventId.isEmpty()) { + this.eventId = Optional.empty(); + } else { + this.eventId = Optional.of(eventId.get()); + } + return this; + } + + /** + *

    Timestamp of when the event was created, in RFC 3339 format.

    + */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(String createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    Data associated with the event.

    + */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(TransferOrderCreatedEventData data) { + this.data = Optional.ofNullable(data); + return this; + } + + public TransferOrderCreatedEvent build() { + return new TransferOrderCreatedEvent(merchantId, type, eventId, createdAt, data, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderCreatedEventData.java b/src/main/java/com/squareup/square/types/TransferOrderCreatedEventData.java new file mode 100644 index 00000000..17c31749 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderCreatedEventData.java @@ -0,0 +1,184 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrderCreatedEventData.Builder.class) +public final class TransferOrderCreatedEventData { + private final Optional type; + + private final Optional id; + + private final Optional object; + + private final Map additionalProperties; + + private TransferOrderCreatedEventData( + Optional type, + Optional id, + Optional object, + Map additionalProperties) { + this.type = type; + this.id = id; + this.object = object; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name of the affected object’s type, "transfer_order". + */ + @JsonIgnore + public Optional getType() { + if (type == null) { + return Optional.empty(); + } + return type; + } + + /** + * @return ID of the affected transfer_order. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return An object containing the created transfer_order. + */ + @JsonProperty("object") + public Optional getObject() { + return object; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("type") + private Optional _getType() { + return type; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderCreatedEventData && equalTo((TransferOrderCreatedEventData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderCreatedEventData other) { + return type.equals(other.type) && id.equals(other.id) && object.equals(other.object); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.object); + } + + @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 type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional object = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderCreatedEventData other) { + type(other.getType()); + id(other.getId()); + object(other.getObject()); + return this; + } + + /** + *

    Name of the affected object’s type, "transfer_order".

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + public Builder type(Nullable type) { + if (type.isNull()) { + this.type = null; + } else if (type.isEmpty()) { + this.type = Optional.empty(); + } else { + this.type = Optional.of(type.get()); + } + return this; + } + + /** + *

    ID of the affected transfer_order.

    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

    An object containing the created transfer_order.

    + */ + @JsonSetter(value = "object", nulls = Nulls.SKIP) + public Builder object(Optional object) { + this.object = object; + return this; + } + + public Builder object(TransferOrderCreatedEventObject object) { + this.object = Optional.ofNullable(object); + return this; + } + + public TransferOrderCreatedEventData build() { + return new TransferOrderCreatedEventData(type, id, object, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderCreatedEventObject.java b/src/main/java/com/squareup/square/types/TransferOrderCreatedEventObject.java new file mode 100644 index 00000000..1e455596 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderCreatedEventObject.java @@ -0,0 +1,102 @@ +/** + * 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 = TransferOrderCreatedEventObject.Builder.class) +public final class TransferOrderCreatedEventObject { + private final Optional transferOrder; + + private final Map additionalProperties; + + private TransferOrderCreatedEventObject( + Optional transferOrder, Map additionalProperties) { + this.transferOrder = transferOrder; + this.additionalProperties = additionalProperties; + } + + /** + * @return The created transfer_order. + */ + @JsonProperty("transfer_order") + public Optional getTransferOrder() { + return transferOrder; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderCreatedEventObject && equalTo((TransferOrderCreatedEventObject) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderCreatedEventObject other) { + return transferOrder.equals(other.transferOrder); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrder); + } + + @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 transferOrder = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderCreatedEventObject other) { + transferOrder(other.getTransferOrder()); + return this; + } + + /** + *

    The created transfer_order.

    + */ + @JsonSetter(value = "transfer_order", nulls = Nulls.SKIP) + public Builder transferOrder(Optional transferOrder) { + this.transferOrder = transferOrder; + return this; + } + + public Builder transferOrder(TransferOrder transferOrder) { + this.transferOrder = Optional.ofNullable(transferOrder); + return this; + } + + public TransferOrderCreatedEventObject build() { + return new TransferOrderCreatedEventObject(transferOrder, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderDeletedEvent.java b/src/main/java/com/squareup/square/types/TransferOrderDeletedEvent.java new file mode 100644 index 00000000..4e85b206 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderDeletedEvent.java @@ -0,0 +1,286 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrderDeletedEvent.Builder.class) +public final class TransferOrderDeletedEvent { + private final Optional merchantId; + + private final Optional type; + + private final Optional eventId; + + private final Optional createdAt; + + private final Optional data; + + private final Map additionalProperties; + + private TransferOrderDeletedEvent( + Optional merchantId, + Optional type, + Optional eventId, + Optional createdAt, + Optional data, + Map additionalProperties) { + this.merchantId = merchantId; + this.type = type; + this.eventId = eventId; + this.createdAt = createdAt; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the target merchant associated with the event. + */ + @JsonIgnore + public Optional getMerchantId() { + if (merchantId == null) { + return Optional.empty(); + } + return merchantId; + } + + /** + * @return The type of event this represents, "transfer_order.deleted". + */ + @JsonIgnore + public Optional getType() { + if (type == null) { + return Optional.empty(); + } + return type; + } + + /** + * @return A unique ID for the event. + */ + @JsonIgnore + public Optional getEventId() { + if (eventId == null) { + return Optional.empty(); + } + return eventId; + } + + /** + * @return Timestamp of when the event was created, in RFC 3339 format. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Data associated with the event. + */ + @JsonProperty("data") + public Optional getData() { + return data; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("merchant_id") + private Optional _getMerchantId() { + return merchantId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("type") + private Optional _getType() { + return type; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("event_id") + private Optional _getEventId() { + return eventId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderDeletedEvent && equalTo((TransferOrderDeletedEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderDeletedEvent other) { + return merchantId.equals(other.merchantId) + && type.equals(other.type) + && eventId.equals(other.eventId) + && createdAt.equals(other.createdAt) + && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.merchantId, this.type, this.eventId, this.createdAt, this.data); + } + + @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 merchantId = Optional.empty(); + + private Optional type = Optional.empty(); + + private Optional eventId = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderDeletedEvent other) { + merchantId(other.getMerchantId()); + type(other.getType()); + eventId(other.getEventId()); + createdAt(other.getCreatedAt()); + data(other.getData()); + return this; + } + + /** + *

    The ID of the target merchant associated with the event.

    + */ + @JsonSetter(value = "merchant_id", nulls = Nulls.SKIP) + public Builder merchantId(Optional merchantId) { + this.merchantId = merchantId; + return this; + } + + public Builder merchantId(String merchantId) { + this.merchantId = Optional.ofNullable(merchantId); + return this; + } + + public Builder merchantId(Nullable merchantId) { + if (merchantId.isNull()) { + this.merchantId = null; + } else if (merchantId.isEmpty()) { + this.merchantId = Optional.empty(); + } else { + this.merchantId = Optional.of(merchantId.get()); + } + return this; + } + + /** + *

    The type of event this represents, "transfer_order.deleted".

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + public Builder type(Nullable type) { + if (type.isNull()) { + this.type = null; + } else if (type.isEmpty()) { + this.type = Optional.empty(); + } else { + this.type = Optional.of(type.get()); + } + return this; + } + + /** + *

    A unique ID for the event.

    + */ + @JsonSetter(value = "event_id", nulls = Nulls.SKIP) + public Builder eventId(Optional eventId) { + this.eventId = eventId; + return this; + } + + public Builder eventId(String eventId) { + this.eventId = Optional.ofNullable(eventId); + return this; + } + + public Builder eventId(Nullable eventId) { + if (eventId.isNull()) { + this.eventId = null; + } else if (eventId.isEmpty()) { + this.eventId = Optional.empty(); + } else { + this.eventId = Optional.of(eventId.get()); + } + return this; + } + + /** + *

    Timestamp of when the event was created, in RFC 3339 format.

    + */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(String createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    Data associated with the event.

    + */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(TransferOrderDeletedEventData data) { + this.data = Optional.ofNullable(data); + return this; + } + + public TransferOrderDeletedEvent build() { + return new TransferOrderDeletedEvent(merchantId, type, eventId, createdAt, data, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderDeletedEventData.java b/src/main/java/com/squareup/square/types/TransferOrderDeletedEventData.java new file mode 100644 index 00000000..b4a91784 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderDeletedEventData.java @@ -0,0 +1,204 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrderDeletedEventData.Builder.class) +public final class TransferOrderDeletedEventData { + private final Optional type; + + private final Optional id; + + private final Optional deleted; + + private final Map additionalProperties; + + private TransferOrderDeletedEventData( + Optional type, + Optional id, + Optional deleted, + Map additionalProperties) { + this.type = type; + this.id = id; + this.deleted = deleted; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name of the affected object’s type, "transfer_order". + */ + @JsonIgnore + public Optional getType() { + if (type == null) { + return Optional.empty(); + } + return type; + } + + /** + * @return ID of the affected transfer_order. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return Is true if the affected object was deleted. Otherwise absent. + */ + @JsonIgnore + public Optional getDeleted() { + if (deleted == null) { + return Optional.empty(); + } + return deleted; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("type") + private Optional _getType() { + return type; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("deleted") + private Optional _getDeleted() { + return deleted; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderDeletedEventData && equalTo((TransferOrderDeletedEventData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderDeletedEventData other) { + return type.equals(other.type) && id.equals(other.id) && deleted.equals(other.deleted); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.deleted); + } + + @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 type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional deleted = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderDeletedEventData other) { + type(other.getType()); + id(other.getId()); + deleted(other.getDeleted()); + return this; + } + + /** + *

    Name of the affected object’s type, "transfer_order".

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + public Builder type(Nullable type) { + if (type.isNull()) { + this.type = null; + } else if (type.isEmpty()) { + this.type = Optional.empty(); + } else { + this.type = Optional.of(type.get()); + } + return this; + } + + /** + *

    ID of the affected transfer_order.

    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

    Is true if the affected object was deleted. Otherwise absent.

    + */ + @JsonSetter(value = "deleted", nulls = Nulls.SKIP) + public Builder deleted(Optional deleted) { + this.deleted = deleted; + return this; + } + + public Builder deleted(Boolean deleted) { + this.deleted = Optional.ofNullable(deleted); + return this; + } + + public Builder deleted(Nullable deleted) { + if (deleted.isNull()) { + this.deleted = null; + } else if (deleted.isEmpty()) { + this.deleted = Optional.empty(); + } else { + this.deleted = Optional.of(deleted.get()); + } + return this; + } + + public TransferOrderDeletedEventData build() { + return new TransferOrderDeletedEventData(type, id, deleted, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderFilter.java b/src/main/java/com/squareup/square/types/TransferOrderFilter.java new file mode 100644 index 00000000..2e1c52ce --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderFilter.java @@ -0,0 +1,229 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrderFilter.Builder.class) +public final class TransferOrderFilter { + private final Optional> sourceLocationIds; + + private final Optional> destinationLocationIds; + + private final Optional> statuses; + + private final Map additionalProperties; + + private TransferOrderFilter( + Optional> sourceLocationIds, + Optional> destinationLocationIds, + Optional> statuses, + Map additionalProperties) { + this.sourceLocationIds = sourceLocationIds; + this.destinationLocationIds = destinationLocationIds; + this.statuses = statuses; + this.additionalProperties = additionalProperties; + } + + /** + * @return Filter by source location IDs + */ + @JsonIgnore + public Optional> getSourceLocationIds() { + if (sourceLocationIds == null) { + return Optional.empty(); + } + return sourceLocationIds; + } + + /** + * @return Filter by destination location IDs + */ + @JsonIgnore + public Optional> getDestinationLocationIds() { + if (destinationLocationIds == null) { + return Optional.empty(); + } + return destinationLocationIds; + } + + /** + * @return Filter by order statuses + * See TransferOrderStatus for possible values + */ + @JsonIgnore + public Optional> getStatuses() { + if (statuses == null) { + return Optional.empty(); + } + return statuses; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("source_location_ids") + private Optional> _getSourceLocationIds() { + return sourceLocationIds; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("destination_location_ids") + private Optional> _getDestinationLocationIds() { + return destinationLocationIds; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("statuses") + private Optional> _getStatuses() { + return statuses; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderFilter && equalTo((TransferOrderFilter) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderFilter other) { + return sourceLocationIds.equals(other.sourceLocationIds) + && destinationLocationIds.equals(other.destinationLocationIds) + && statuses.equals(other.statuses); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.sourceLocationIds, this.destinationLocationIds, this.statuses); + } + + @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> sourceLocationIds = Optional.empty(); + + private Optional> destinationLocationIds = Optional.empty(); + + private Optional> statuses = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderFilter other) { + sourceLocationIds(other.getSourceLocationIds()); + destinationLocationIds(other.getDestinationLocationIds()); + statuses(other.getStatuses()); + return this; + } + + /** + *

    Filter by source location IDs

    + */ + @JsonSetter(value = "source_location_ids", nulls = Nulls.SKIP) + public Builder sourceLocationIds(Optional> sourceLocationIds) { + this.sourceLocationIds = sourceLocationIds; + return this; + } + + public Builder sourceLocationIds(List sourceLocationIds) { + this.sourceLocationIds = Optional.ofNullable(sourceLocationIds); + return this; + } + + public Builder sourceLocationIds(Nullable> sourceLocationIds) { + if (sourceLocationIds.isNull()) { + this.sourceLocationIds = null; + } else if (sourceLocationIds.isEmpty()) { + this.sourceLocationIds = Optional.empty(); + } else { + this.sourceLocationIds = Optional.of(sourceLocationIds.get()); + } + return this; + } + + /** + *

    Filter by destination location IDs

    + */ + @JsonSetter(value = "destination_location_ids", nulls = Nulls.SKIP) + public Builder destinationLocationIds(Optional> destinationLocationIds) { + this.destinationLocationIds = destinationLocationIds; + return this; + } + + public Builder destinationLocationIds(List destinationLocationIds) { + this.destinationLocationIds = Optional.ofNullable(destinationLocationIds); + return this; + } + + public Builder destinationLocationIds(Nullable> destinationLocationIds) { + if (destinationLocationIds.isNull()) { + this.destinationLocationIds = null; + } else if (destinationLocationIds.isEmpty()) { + this.destinationLocationIds = Optional.empty(); + } else { + this.destinationLocationIds = Optional.of(destinationLocationIds.get()); + } + return this; + } + + /** + *

    Filter by order statuses + * See TransferOrderStatus for possible values

    + */ + @JsonSetter(value = "statuses", nulls = Nulls.SKIP) + public Builder statuses(Optional> statuses) { + this.statuses = statuses; + return this; + } + + public Builder statuses(List statuses) { + this.statuses = Optional.ofNullable(statuses); + return this; + } + + public Builder statuses(Nullable> statuses) { + if (statuses.isNull()) { + this.statuses = null; + } else if (statuses.isEmpty()) { + this.statuses = Optional.empty(); + } else { + this.statuses = Optional.of(statuses.get()); + } + return this; + } + + public TransferOrderFilter build() { + return new TransferOrderFilter(sourceLocationIds, destinationLocationIds, statuses, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderGoodsReceipt.java b/src/main/java/com/squareup/square/types/TransferOrderGoodsReceipt.java new file mode 100644 index 00000000..d9474aba --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderGoodsReceipt.java @@ -0,0 +1,152 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrderGoodsReceipt.Builder.class) +public final class TransferOrderGoodsReceipt { + private final Optional> lineItems; + + private final Map additionalProperties; + + private TransferOrderGoodsReceipt( + Optional> lineItems, Map additionalProperties) { + this.lineItems = lineItems; + this.additionalProperties = additionalProperties; + } + + /** + * @return Line items being received. Each line item specifies: + *
      + *
    • The item being received
    • + *
    • Quantity received in good condition
    • + *
    • Quantity received damaged
    • + *
    • Quantity canceled
    • + *
    + *

    Constraints:

    + *
      + *
    • Must include at least one line item
    • + *
    • Maximum of 1000 line items per receipt
    • + *
    • Each line item must reference a valid item from the transfer order
    • + *
    • Total of received, damaged, and canceled quantities cannot exceed ordered quantity
    • + *
    + */ + @JsonIgnore + public Optional> getLineItems() { + if (lineItems == null) { + return Optional.empty(); + } + return lineItems; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("line_items") + private Optional> _getLineItems() { + return lineItems; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderGoodsReceipt && equalTo((TransferOrderGoodsReceipt) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderGoodsReceipt other) { + return lineItems.equals(other.lineItems); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.lineItems); + } + + @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> lineItems = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderGoodsReceipt other) { + lineItems(other.getLineItems()); + return this; + } + + /** + *

    Line items being received. Each line item specifies:

    + *
      + *
    • The item being received
    • + *
    • Quantity received in good condition
    • + *
    • Quantity received damaged
    • + *
    • Quantity canceled
    • + *
    + *

    Constraints:

    + *
      + *
    • Must include at least one line item
    • + *
    • Maximum of 1000 line items per receipt
    • + *
    • Each line item must reference a valid item from the transfer order
    • + *
    • Total of received, damaged, and canceled quantities cannot exceed ordered quantity
    • + *
    + */ + @JsonSetter(value = "line_items", nulls = Nulls.SKIP) + public Builder lineItems(Optional> lineItems) { + this.lineItems = lineItems; + return this; + } + + public Builder lineItems(List lineItems) { + this.lineItems = Optional.ofNullable(lineItems); + return this; + } + + public Builder lineItems(Nullable> lineItems) { + if (lineItems.isNull()) { + this.lineItems = null; + } else if (lineItems.isEmpty()) { + this.lineItems = Optional.empty(); + } else { + this.lineItems = Optional.of(lineItems.get()); + } + return this; + } + + public TransferOrderGoodsReceipt build() { + return new TransferOrderGoodsReceipt(lineItems, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderGoodsReceiptLineItem.java b/src/main/java/com/squareup/square/types/TransferOrderGoodsReceiptLineItem.java new file mode 100644 index 00000000..8b777afa --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderGoodsReceiptLineItem.java @@ -0,0 +1,343 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrderGoodsReceiptLineItem.Builder.class) +public final class TransferOrderGoodsReceiptLineItem { + private final String transferOrderLineUid; + + private final Optional quantityReceived; + + private final Optional quantityDamaged; + + private final Optional quantityCanceled; + + private final Map additionalProperties; + + private TransferOrderGoodsReceiptLineItem( + String transferOrderLineUid, + Optional quantityReceived, + Optional quantityDamaged, + Optional quantityCanceled, + Map additionalProperties) { + this.transferOrderLineUid = transferOrderLineUid; + this.quantityReceived = quantityReceived; + this.quantityDamaged = quantityDamaged; + this.quantityCanceled = quantityCanceled; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the Transfer Order line being received + */ + @JsonProperty("transfer_order_line_uid") + public String getTransferOrderLineUid() { + return transferOrderLineUid; + } + + /** + * @return The quantity received for this line item as a decimal string (e.g. "10.5"). + * These items will be added to the destination Location's inventory with InventoryState of IN_STOCK. + */ + @JsonIgnore + public Optional getQuantityReceived() { + if (quantityReceived == null) { + return Optional.empty(); + } + return quantityReceived; + } + + /** + * @return The quantity that was damaged during shipping/handling as a decimal string (e.g. "1.5"). + * These items will be added to the destination Location's inventory with InventoryState of WASTE. + */ + @JsonIgnore + public Optional getQuantityDamaged() { + if (quantityDamaged == null) { + return Optional.empty(); + } + return quantityDamaged; + } + + /** + * @return The quantity that was canceled during shipping/handling as a decimal string (e.g. "1.5"). These will be immediately added to inventory in the source location. + */ + @JsonIgnore + public Optional getQuantityCanceled() { + if (quantityCanceled == null) { + return Optional.empty(); + } + return quantityCanceled; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("quantity_received") + private Optional _getQuantityReceived() { + return quantityReceived; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("quantity_damaged") + private Optional _getQuantityDamaged() { + return quantityDamaged; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("quantity_canceled") + private Optional _getQuantityCanceled() { + return quantityCanceled; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderGoodsReceiptLineItem && equalTo((TransferOrderGoodsReceiptLineItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderGoodsReceiptLineItem other) { + return transferOrderLineUid.equals(other.transferOrderLineUid) + && quantityReceived.equals(other.quantityReceived) + && quantityDamaged.equals(other.quantityDamaged) + && quantityCanceled.equals(other.quantityCanceled); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.transferOrderLineUid, this.quantityReceived, this.quantityDamaged, this.quantityCanceled); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TransferOrderLineUidStage builder() { + return new Builder(); + } + + public interface TransferOrderLineUidStage { + /** + *

    The unique identifier of the Transfer Order line being received

    + */ + _FinalStage transferOrderLineUid(@NotNull String transferOrderLineUid); + + Builder from(TransferOrderGoodsReceiptLineItem other); + } + + public interface _FinalStage { + TransferOrderGoodsReceiptLineItem build(); + + /** + *

    The quantity received for this line item as a decimal string (e.g. "10.5"). + * These items will be added to the destination Location's inventory with InventoryState of IN_STOCK.

    + */ + _FinalStage quantityReceived(Optional quantityReceived); + + _FinalStage quantityReceived(String quantityReceived); + + _FinalStage quantityReceived(Nullable quantityReceived); + + /** + *

    The quantity that was damaged during shipping/handling as a decimal string (e.g. "1.5"). + * These items will be added to the destination Location's inventory with InventoryState of WASTE.

    + */ + _FinalStage quantityDamaged(Optional quantityDamaged); + + _FinalStage quantityDamaged(String quantityDamaged); + + _FinalStage quantityDamaged(Nullable quantityDamaged); + + /** + *

    The quantity that was canceled during shipping/handling as a decimal string (e.g. "1.5"). These will be immediately added to inventory in the source location.

    + */ + _FinalStage quantityCanceled(Optional quantityCanceled); + + _FinalStage quantityCanceled(String quantityCanceled); + + _FinalStage quantityCanceled(Nullable quantityCanceled); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TransferOrderLineUidStage, _FinalStage { + private String transferOrderLineUid; + + private Optional quantityCanceled = Optional.empty(); + + private Optional quantityDamaged = Optional.empty(); + + private Optional quantityReceived = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TransferOrderGoodsReceiptLineItem other) { + transferOrderLineUid(other.getTransferOrderLineUid()); + quantityReceived(other.getQuantityReceived()); + quantityDamaged(other.getQuantityDamaged()); + quantityCanceled(other.getQuantityCanceled()); + return this; + } + + /** + *

    The unique identifier of the Transfer Order line being received

    + *

    The unique identifier of the Transfer Order line being received

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

    The quantity that was canceled during shipping/handling as a decimal string (e.g. "1.5"). These will be immediately added to inventory in the source location.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage quantityCanceled(Nullable quantityCanceled) { + if (quantityCanceled.isNull()) { + this.quantityCanceled = null; + } else if (quantityCanceled.isEmpty()) { + this.quantityCanceled = Optional.empty(); + } else { + this.quantityCanceled = Optional.of(quantityCanceled.get()); + } + return this; + } + + /** + *

    The quantity that was canceled during shipping/handling as a decimal string (e.g. "1.5"). These will be immediately added to inventory in the source location.

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

    The quantity that was canceled during shipping/handling as a decimal string (e.g. "1.5"). These will be immediately added to inventory in the source location.

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

    The quantity that was damaged during shipping/handling as a decimal string (e.g. "1.5"). + * These items will be added to the destination Location's inventory with InventoryState of WASTE.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage quantityDamaged(Nullable quantityDamaged) { + if (quantityDamaged.isNull()) { + this.quantityDamaged = null; + } else if (quantityDamaged.isEmpty()) { + this.quantityDamaged = Optional.empty(); + } else { + this.quantityDamaged = Optional.of(quantityDamaged.get()); + } + return this; + } + + /** + *

    The quantity that was damaged during shipping/handling as a decimal string (e.g. "1.5"). + * These items will be added to the destination Location's inventory with InventoryState of WASTE.

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

    The quantity that was damaged during shipping/handling as a decimal string (e.g. "1.5"). + * These items will be added to the destination Location's inventory with InventoryState of WASTE.

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

    The quantity received for this line item as a decimal string (e.g. "10.5"). + * These items will be added to the destination Location's inventory with InventoryState of IN_STOCK.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage quantityReceived(Nullable quantityReceived) { + if (quantityReceived.isNull()) { + this.quantityReceived = null; + } else if (quantityReceived.isEmpty()) { + this.quantityReceived = Optional.empty(); + } else { + this.quantityReceived = Optional.of(quantityReceived.get()); + } + return this; + } + + /** + *

    The quantity received for this line item as a decimal string (e.g. "10.5"). + * These items will be added to the destination Location's inventory with InventoryState of IN_STOCK.

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

    The quantity received for this line item as a decimal string (e.g. "10.5"). + * These items will be added to the destination Location's inventory with InventoryState of IN_STOCK.

    + */ + @java.lang.Override + @JsonSetter(value = "quantity_received", nulls = Nulls.SKIP) + public _FinalStage quantityReceived(Optional quantityReceived) { + this.quantityReceived = quantityReceived; + return this; + } + + @java.lang.Override + public TransferOrderGoodsReceiptLineItem build() { + return new TransferOrderGoodsReceiptLineItem( + transferOrderLineUid, quantityReceived, quantityDamaged, quantityCanceled, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderLine.java b/src/main/java/com/squareup/square/types/TransferOrderLine.java new file mode 100644 index 00000000..11ba0959 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderLine.java @@ -0,0 +1,410 @@ +/** + * 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 = TransferOrderLine.Builder.class) +public final class TransferOrderLine { + private final Optional uid; + + private final String itemVariationId; + + private final String quantityOrdered; + + private final Optional quantityPending; + + private final Optional quantityReceived; + + private final Optional quantityDamaged; + + private final Optional quantityCanceled; + + private final Map additionalProperties; + + private TransferOrderLine( + Optional uid, + String itemVariationId, + String quantityOrdered, + Optional quantityPending, + Optional quantityReceived, + Optional quantityDamaged, + Optional quantityCanceled, + Map additionalProperties) { + this.uid = uid; + this.itemVariationId = itemVariationId; + this.quantityOrdered = quantityOrdered; + this.quantityPending = quantityPending; + this.quantityReceived = quantityReceived; + this.quantityDamaged = quantityDamaged; + this.quantityCanceled = quantityCanceled; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique system-generated identifier for the line item. Provide when updating/removing a line via UpdateTransferOrder. + */ + @JsonProperty("uid") + public Optional getUid() { + return uid; + } + + /** + * @return The required identifier of the CatalogItemVariation being transferred. Must reference + * a valid catalog item variation that exists in the Catalog. + */ + @JsonProperty("item_variation_id") + public String getItemVariationId() { + return itemVariationId; + } + + /** + * @return Total quantity ordered, formatted as a decimal string (e.g. "10 or 10.0000"). Required to be a positive number. + *

    To remove a line item, set remove to true in UpdateTransferOrder.

    + */ + @JsonProperty("quantity_ordered") + public String getQuantityOrdered() { + return quantityOrdered; + } + + /** + * @return Calculated quantity of this line item's yet to be received stock. This is the difference between the total quantity ordered and the sum of quantities received, canceled, and damaged. + */ + @JsonProperty("quantity_pending") + public Optional getQuantityPending() { + return quantityPending; + } + + /** + * @return Quantity received at destination. These items are added to the destination + * Location's inventory with InventoryState of IN_STOCK. + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder.

    + */ + @JsonProperty("quantity_received") + public Optional getQuantityReceived() { + return quantityReceived; + } + + /** + * @return Quantity received in damaged condition. These items are added to the destination + * Location's inventory with InventoryState of WASTE. + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder.

    + */ + @JsonProperty("quantity_damaged") + public Optional getQuantityDamaged() { + return quantityDamaged; + } + + /** + * @return Quantity that was canceled. These items will be immediately added to inventory in the source location. + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder or CancelTransferOrder.

    + */ + @JsonProperty("quantity_canceled") + public Optional getQuantityCanceled() { + return quantityCanceled; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderLine && equalTo((TransferOrderLine) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderLine other) { + return uid.equals(other.uid) + && itemVariationId.equals(other.itemVariationId) + && quantityOrdered.equals(other.quantityOrdered) + && quantityPending.equals(other.quantityPending) + && quantityReceived.equals(other.quantityReceived) + && quantityDamaged.equals(other.quantityDamaged) + && quantityCanceled.equals(other.quantityCanceled); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.uid, + this.itemVariationId, + this.quantityOrdered, + this.quantityPending, + this.quantityReceived, + this.quantityDamaged, + this.quantityCanceled); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ItemVariationIdStage builder() { + return new Builder(); + } + + public interface ItemVariationIdStage { + /** + *

    The required identifier of the CatalogItemVariation being transferred. Must reference + * a valid catalog item variation that exists in the Catalog.

    + */ + QuantityOrderedStage itemVariationId(@NotNull String itemVariationId); + + Builder from(TransferOrderLine other); + } + + public interface QuantityOrderedStage { + /** + *

    Total quantity ordered, formatted as a decimal string (e.g. "10 or 10.0000"). Required to be a positive number.

    + *

    To remove a line item, set remove to true in UpdateTransferOrder.

    + */ + _FinalStage quantityOrdered(@NotNull String quantityOrdered); + } + + public interface _FinalStage { + TransferOrderLine build(); + + /** + *

    Unique system-generated identifier for the line item. Provide when updating/removing a line via UpdateTransferOrder.

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

    Calculated quantity of this line item's yet to be received stock. This is the difference between the total quantity ordered and the sum of quantities received, canceled, and damaged.

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

    Quantity received at destination. These items are added to the destination + * Location's inventory with InventoryState of IN_STOCK.

    + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder.

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

    Quantity received in damaged condition. These items are added to the destination + * Location's inventory with InventoryState of WASTE.

    + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder.

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

    Quantity that was canceled. These items will be immediately added to inventory in the source location.

    + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder or CancelTransferOrder.

    + */ + _FinalStage quantityCanceled(Optional quantityCanceled); + + _FinalStage quantityCanceled(String quantityCanceled); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ItemVariationIdStage, QuantityOrderedStage, _FinalStage { + private String itemVariationId; + + private String quantityOrdered; + + private Optional quantityCanceled = Optional.empty(); + + private Optional quantityDamaged = Optional.empty(); + + private Optional quantityReceived = Optional.empty(); + + private Optional quantityPending = Optional.empty(); + + private Optional uid = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TransferOrderLine other) { + uid(other.getUid()); + itemVariationId(other.getItemVariationId()); + quantityOrdered(other.getQuantityOrdered()); + quantityPending(other.getQuantityPending()); + quantityReceived(other.getQuantityReceived()); + quantityDamaged(other.getQuantityDamaged()); + quantityCanceled(other.getQuantityCanceled()); + return this; + } + + /** + *

    The required identifier of the CatalogItemVariation being transferred. Must reference + * a valid catalog item variation that exists in the Catalog.

    + *

    The required identifier of the CatalogItemVariation being transferred. Must reference + * a valid catalog item variation that exists in the Catalog.

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

    Total quantity ordered, formatted as a decimal string (e.g. "10 or 10.0000"). Required to be a positive number.

    + *

    To remove a line item, set remove to true in UpdateTransferOrder.

    + *

    Total quantity ordered, formatted as a decimal string (e.g. "10 or 10.0000"). Required to be a positive number.

    + *

    To remove a line item, set remove to true in UpdateTransferOrder.

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

    Quantity that was canceled. These items will be immediately added to inventory in the source location.

    + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder or CancelTransferOrder.

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

    Quantity that was canceled. These items will be immediately added to inventory in the source location.

    + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder or CancelTransferOrder.

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

    Quantity received in damaged condition. These items are added to the destination + * Location's inventory with InventoryState of WASTE.

    + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder.

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

    Quantity received in damaged condition. These items are added to the destination + * Location's inventory with InventoryState of WASTE.

    + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder.

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

    Quantity received at destination. These items are added to the destination + * Location's inventory with InventoryState of IN_STOCK.

    + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder.

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

    Quantity received at destination. These items are added to the destination + * Location's inventory with InventoryState of IN_STOCK.

    + *

    This field cannot be updated directly in Create/Update operations, instead use ReceiveTransferOrder.

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

    Calculated quantity of this line item's yet to be received stock. This is the difference between the total quantity ordered and the sum of quantities received, canceled, and damaged.

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

    Calculated quantity of this line item's yet to be received stock. This is the difference between the total quantity ordered and the sum of quantities received, canceled, and damaged.

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

    Unique system-generated identifier for the line item. Provide when updating/removing a line via UpdateTransferOrder.

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

    Unique system-generated identifier for the line item. Provide when updating/removing a line via UpdateTransferOrder.

    + */ + @java.lang.Override + @JsonSetter(value = "uid", nulls = Nulls.SKIP) + public _FinalStage uid(Optional uid) { + this.uid = uid; + return this; + } + + @java.lang.Override + public TransferOrderLine build() { + return new TransferOrderLine( + uid, + itemVariationId, + quantityOrdered, + quantityPending, + quantityReceived, + quantityDamaged, + quantityCanceled, + additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderQuery.java b/src/main/java/com/squareup/square/types/TransferOrderQuery.java new file mode 100644 index 00000000..735cffe8 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderQuery.java @@ -0,0 +1,132 @@ +/** + * 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 = TransferOrderQuery.Builder.class) +public final class TransferOrderQuery { + private final Optional filter; + + private final Optional sort; + + private final Map additionalProperties; + + private TransferOrderQuery( + Optional filter, + Optional sort, + Map additionalProperties) { + this.filter = filter; + this.sort = sort; + this.additionalProperties = additionalProperties; + } + + /** + * @return Filter criteria + */ + @JsonProperty("filter") + public Optional getFilter() { + return filter; + } + + /** + * @return Sort configuration + */ + @JsonProperty("sort") + public Optional getSort() { + return sort; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderQuery && equalTo((TransferOrderQuery) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderQuery other) { + return filter.equals(other.filter) && sort.equals(other.sort); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.filter, this.sort); + } + + @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 filter = Optional.empty(); + + private Optional sort = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderQuery other) { + filter(other.getFilter()); + sort(other.getSort()); + return this; + } + + /** + *

    Filter criteria

    + */ + @JsonSetter(value = "filter", nulls = Nulls.SKIP) + public Builder filter(Optional filter) { + this.filter = filter; + return this; + } + + public Builder filter(TransferOrderFilter filter) { + this.filter = Optional.ofNullable(filter); + return this; + } + + /** + *

    Sort configuration

    + */ + @JsonSetter(value = "sort", nulls = Nulls.SKIP) + public Builder sort(Optional sort) { + this.sort = sort; + return this; + } + + public Builder sort(TransferOrderSort sort) { + this.sort = Optional.ofNullable(sort); + return this; + } + + public TransferOrderQuery build() { + return new TransferOrderQuery(filter, sort, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderSort.java b/src/main/java/com/squareup/square/types/TransferOrderSort.java new file mode 100644 index 00000000..748a3763 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderSort.java @@ -0,0 +1,136 @@ +/** + * 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 = TransferOrderSort.Builder.class) +public final class TransferOrderSort { + private final Optional field; + + private final Optional order; + + private final Map additionalProperties; + + private TransferOrderSort( + Optional field, + Optional order, + Map additionalProperties) { + this.field = field; + this.order = order; + this.additionalProperties = additionalProperties; + } + + /** + * @return Field to sort by + * See TransferOrderSortField for possible values + */ + @JsonProperty("field") + public Optional getField() { + return field; + } + + /** + * @return Sort order direction + * See SortOrder for possible values + */ + @JsonProperty("order") + public Optional getOrder() { + return order; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderSort && equalTo((TransferOrderSort) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderSort other) { + return field.equals(other.field) && order.equals(other.order); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.field, this.order); + } + + @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 field = Optional.empty(); + + private Optional order = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderSort other) { + field(other.getField()); + order(other.getOrder()); + return this; + } + + /** + *

    Field to sort by + * See TransferOrderSortField for possible values

    + */ + @JsonSetter(value = "field", nulls = Nulls.SKIP) + public Builder field(Optional field) { + this.field = field; + return this; + } + + public Builder field(TransferOrderSortField field) { + this.field = Optional.ofNullable(field); + return this; + } + + /** + *

    Sort order direction + * See SortOrder for possible values

    + */ + @JsonSetter(value = "order", nulls = Nulls.SKIP) + public Builder order(Optional order) { + this.order = order; + return this; + } + + public Builder order(SortOrder order) { + this.order = Optional.ofNullable(order); + return this; + } + + public TransferOrderSort build() { + return new TransferOrderSort(field, order, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderSortField.java b/src/main/java/com/squareup/square/types/TransferOrderSortField.java new file mode 100644 index 00000000..37061f51 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderSortField.java @@ -0,0 +1,84 @@ +/** + * 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 TransferOrderSortField { + public static final TransferOrderSortField UPDATED_AT = new TransferOrderSortField(Value.UPDATED_AT, "UPDATED_AT"); + + public static final TransferOrderSortField CREATED_AT = new TransferOrderSortField(Value.CREATED_AT, "CREATED_AT"); + + private final Value value; + + private final String string; + + TransferOrderSortField(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 TransferOrderSortField + && this.string.equals(((TransferOrderSortField) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case UPDATED_AT: + return visitor.visitUpdatedAt(); + case CREATED_AT: + return visitor.visitCreatedAt(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static TransferOrderSortField valueOf(String value) { + switch (value) { + case "UPDATED_AT": + return UPDATED_AT; + case "CREATED_AT": + return CREATED_AT; + default: + return new TransferOrderSortField(Value.UNKNOWN, value); + } + } + + public enum Value { + CREATED_AT, + + UPDATED_AT, + + UNKNOWN + } + + public interface Visitor { + T visitCreatedAt(); + + T visitUpdatedAt(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderStatus.java b/src/main/java/com/squareup/square/types/TransferOrderStatus.java new file mode 100644 index 00000000..2cc6285a --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderStatus.java @@ -0,0 +1,114 @@ +/** + * 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 TransferOrderStatus { + public static final TransferOrderStatus CANCELED = new TransferOrderStatus(Value.CANCELED, "CANCELED"); + + public static final TransferOrderStatus PARTIALLY_RECEIVED = + new TransferOrderStatus(Value.PARTIALLY_RECEIVED, "PARTIALLY_RECEIVED"); + + public static final TransferOrderStatus STARTED = new TransferOrderStatus(Value.STARTED, "STARTED"); + + public static final TransferOrderStatus DRAFT = new TransferOrderStatus(Value.DRAFT, "DRAFT"); + + public static final TransferOrderStatus COMPLETED = new TransferOrderStatus(Value.COMPLETED, "COMPLETED"); + + private final Value value; + + private final String string; + + TransferOrderStatus(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 TransferOrderStatus && this.string.equals(((TransferOrderStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CANCELED: + return visitor.visitCanceled(); + case PARTIALLY_RECEIVED: + return visitor.visitPartiallyReceived(); + case STARTED: + return visitor.visitStarted(); + case DRAFT: + return visitor.visitDraft(); + case COMPLETED: + return visitor.visitCompleted(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static TransferOrderStatus valueOf(String value) { + switch (value) { + case "CANCELED": + return CANCELED; + case "PARTIALLY_RECEIVED": + return PARTIALLY_RECEIVED; + case "STARTED": + return STARTED; + case "DRAFT": + return DRAFT; + case "COMPLETED": + return COMPLETED; + default: + return new TransferOrderStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + DRAFT, + + STARTED, + + PARTIALLY_RECEIVED, + + COMPLETED, + + CANCELED, + + UNKNOWN + } + + public interface Visitor { + T visitDraft(); + + T visitStarted(); + + T visitPartiallyReceived(); + + T visitCompleted(); + + T visitCanceled(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderUpdatedEvent.java b/src/main/java/com/squareup/square/types/TransferOrderUpdatedEvent.java new file mode 100644 index 00000000..f87698f0 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderUpdatedEvent.java @@ -0,0 +1,286 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrderUpdatedEvent.Builder.class) +public final class TransferOrderUpdatedEvent { + private final Optional merchantId; + + private final Optional type; + + private final Optional eventId; + + private final Optional createdAt; + + private final Optional data; + + private final Map additionalProperties; + + private TransferOrderUpdatedEvent( + Optional merchantId, + Optional type, + Optional eventId, + Optional createdAt, + Optional data, + Map additionalProperties) { + this.merchantId = merchantId; + this.type = type; + this.eventId = eventId; + this.createdAt = createdAt; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the target merchant associated with the event. + */ + @JsonIgnore + public Optional getMerchantId() { + if (merchantId == null) { + return Optional.empty(); + } + return merchantId; + } + + /** + * @return The type of event this represents, "transfer_order.updated". + */ + @JsonIgnore + public Optional getType() { + if (type == null) { + return Optional.empty(); + } + return type; + } + + /** + * @return A unique ID for the event. + */ + @JsonIgnore + public Optional getEventId() { + if (eventId == null) { + return Optional.empty(); + } + return eventId; + } + + /** + * @return Timestamp of when the event was created, in RFC 3339 format. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Data associated with the event. + */ + @JsonProperty("data") + public Optional getData() { + return data; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("merchant_id") + private Optional _getMerchantId() { + return merchantId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("type") + private Optional _getType() { + return type; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("event_id") + private Optional _getEventId() { + return eventId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderUpdatedEvent && equalTo((TransferOrderUpdatedEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderUpdatedEvent other) { + return merchantId.equals(other.merchantId) + && type.equals(other.type) + && eventId.equals(other.eventId) + && createdAt.equals(other.createdAt) + && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.merchantId, this.type, this.eventId, this.createdAt, this.data); + } + + @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 merchantId = Optional.empty(); + + private Optional type = Optional.empty(); + + private Optional eventId = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderUpdatedEvent other) { + merchantId(other.getMerchantId()); + type(other.getType()); + eventId(other.getEventId()); + createdAt(other.getCreatedAt()); + data(other.getData()); + return this; + } + + /** + *

    The ID of the target merchant associated with the event.

    + */ + @JsonSetter(value = "merchant_id", nulls = Nulls.SKIP) + public Builder merchantId(Optional merchantId) { + this.merchantId = merchantId; + return this; + } + + public Builder merchantId(String merchantId) { + this.merchantId = Optional.ofNullable(merchantId); + return this; + } + + public Builder merchantId(Nullable merchantId) { + if (merchantId.isNull()) { + this.merchantId = null; + } else if (merchantId.isEmpty()) { + this.merchantId = Optional.empty(); + } else { + this.merchantId = Optional.of(merchantId.get()); + } + return this; + } + + /** + *

    The type of event this represents, "transfer_order.updated".

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + public Builder type(Nullable type) { + if (type.isNull()) { + this.type = null; + } else if (type.isEmpty()) { + this.type = Optional.empty(); + } else { + this.type = Optional.of(type.get()); + } + return this; + } + + /** + *

    A unique ID for the event.

    + */ + @JsonSetter(value = "event_id", nulls = Nulls.SKIP) + public Builder eventId(Optional eventId) { + this.eventId = eventId; + return this; + } + + public Builder eventId(String eventId) { + this.eventId = Optional.ofNullable(eventId); + return this; + } + + public Builder eventId(Nullable eventId) { + if (eventId.isNull()) { + this.eventId = null; + } else if (eventId.isEmpty()) { + this.eventId = Optional.empty(); + } else { + this.eventId = Optional.of(eventId.get()); + } + return this; + } + + /** + *

    Timestamp of when the event was created, in RFC 3339 format.

    + */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(String createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    Data associated with the event.

    + */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(TransferOrderUpdatedEventData data) { + this.data = Optional.ofNullable(data); + return this; + } + + public TransferOrderUpdatedEvent build() { + return new TransferOrderUpdatedEvent(merchantId, type, eventId, createdAt, data, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderUpdatedEventData.java b/src/main/java/com/squareup/square/types/TransferOrderUpdatedEventData.java new file mode 100644 index 00000000..b2ee5242 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderUpdatedEventData.java @@ -0,0 +1,184 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = TransferOrderUpdatedEventData.Builder.class) +public final class TransferOrderUpdatedEventData { + private final Optional type; + + private final Optional id; + + private final Optional object; + + private final Map additionalProperties; + + private TransferOrderUpdatedEventData( + Optional type, + Optional id, + Optional object, + Map additionalProperties) { + this.type = type; + this.id = id; + this.object = object; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name of the affected object’s type, "transfer_order". + */ + @JsonIgnore + public Optional getType() { + if (type == null) { + return Optional.empty(); + } + return type; + } + + /** + * @return ID of the affected transfer_order. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return An object containing the updated transfer_order. + */ + @JsonProperty("object") + public Optional getObject() { + return object; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("type") + private Optional _getType() { + return type; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderUpdatedEventData && equalTo((TransferOrderUpdatedEventData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderUpdatedEventData other) { + return type.equals(other.type) && id.equals(other.id) && object.equals(other.object); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.object); + } + + @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 type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional object = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderUpdatedEventData other) { + type(other.getType()); + id(other.getId()); + object(other.getObject()); + return this; + } + + /** + *

    Name of the affected object’s type, "transfer_order".

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + public Builder type(Nullable type) { + if (type.isNull()) { + this.type = null; + } else if (type.isEmpty()) { + this.type = Optional.empty(); + } else { + this.type = Optional.of(type.get()); + } + return this; + } + + /** + *

    ID of the affected transfer_order.

    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

    An object containing the updated transfer_order.

    + */ + @JsonSetter(value = "object", nulls = Nulls.SKIP) + public Builder object(Optional object) { + this.object = object; + return this; + } + + public Builder object(TransferOrderUpdatedEventObject object) { + this.object = Optional.ofNullable(object); + return this; + } + + public TransferOrderUpdatedEventData build() { + return new TransferOrderUpdatedEventData(type, id, object, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/TransferOrderUpdatedEventObject.java b/src/main/java/com/squareup/square/types/TransferOrderUpdatedEventObject.java new file mode 100644 index 00000000..9ee30429 --- /dev/null +++ b/src/main/java/com/squareup/square/types/TransferOrderUpdatedEventObject.java @@ -0,0 +1,102 @@ +/** + * 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 = TransferOrderUpdatedEventObject.Builder.class) +public final class TransferOrderUpdatedEventObject { + private final Optional transferOrder; + + private final Map additionalProperties; + + private TransferOrderUpdatedEventObject( + Optional transferOrder, Map additionalProperties) { + this.transferOrder = transferOrder; + this.additionalProperties = additionalProperties; + } + + /** + * @return The updated transfer_order. + */ + @JsonProperty("transfer_order") + public Optional getTransferOrder() { + return transferOrder; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransferOrderUpdatedEventObject && equalTo((TransferOrderUpdatedEventObject) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransferOrderUpdatedEventObject other) { + return transferOrder.equals(other.transferOrder); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrder); + } + + @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 transferOrder = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransferOrderUpdatedEventObject other) { + transferOrder(other.getTransferOrder()); + return this; + } + + /** + *

    The updated transfer_order.

    + */ + @JsonSetter(value = "transfer_order", nulls = Nulls.SKIP) + public Builder transferOrder(Optional transferOrder) { + this.transferOrder = transferOrder; + return this; + } + + public Builder transferOrder(TransferOrder transferOrder) { + this.transferOrder = Optional.ofNullable(transferOrder); + return this; + } + + public TransferOrderUpdatedEventObject build() { + return new TransferOrderUpdatedEventObject(transferOrder, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/UpdateTransferOrderData.java b/src/main/java/com/squareup/square/types/UpdateTransferOrderData.java new file mode 100644 index 00000000..04b2e88f --- /dev/null +++ b/src/main/java/com/squareup/square/types/UpdateTransferOrderData.java @@ -0,0 +1,394 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = UpdateTransferOrderData.Builder.class) +public final class UpdateTransferOrderData { + private final Optional sourceLocationId; + + private final Optional destinationLocationId; + + private final Optional expectedAt; + + private final Optional notes; + + private final Optional trackingNumber; + + private final Optional> lineItems; + + private final Map additionalProperties; + + private UpdateTransferOrderData( + Optional sourceLocationId, + Optional destinationLocationId, + Optional expectedAt, + Optional notes, + Optional trackingNumber, + Optional> lineItems, + Map additionalProperties) { + this.sourceLocationId = sourceLocationId; + this.destinationLocationId = destinationLocationId; + this.expectedAt = expectedAt; + this.notes = notes; + this.trackingNumber = trackingNumber; + this.lineItems = lineItems; + this.additionalProperties = additionalProperties; + } + + /** + * @return The source Location that will send the items. Must be an active location + * in your Square account with sufficient inventory of the requested items. + */ + @JsonIgnore + public Optional getSourceLocationId() { + if (sourceLocationId == null) { + return Optional.empty(); + } + return sourceLocationId; + } + + /** + * @return The destination Location that will receive the items. Must be an active location + * in your Square account. + */ + @JsonIgnore + public Optional getDestinationLocationId() { + if (destinationLocationId == null) { + return Optional.empty(); + } + return destinationLocationId; + } + + /** + * @return Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z"). + */ + @JsonIgnore + public Optional getExpectedAt() { + if (expectedAt == null) { + return Optional.empty(); + } + return expectedAt; + } + + /** + * @return Optional notes about the transfer + */ + @JsonIgnore + public Optional getNotes() { + if (notes == null) { + return Optional.empty(); + } + return notes; + } + + /** + * @return Shipment tracking number + */ + @JsonIgnore + public Optional getTrackingNumber() { + if (trackingNumber == null) { + return Optional.empty(); + } + return trackingNumber; + } + + /** + * @return List of items being transferred + */ + @JsonIgnore + public Optional> getLineItems() { + if (lineItems == null) { + return Optional.empty(); + } + return lineItems; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("source_location_id") + private Optional _getSourceLocationId() { + return sourceLocationId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("destination_location_id") + private Optional _getDestinationLocationId() { + return destinationLocationId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("expected_at") + private Optional _getExpectedAt() { + return expectedAt; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("notes") + private Optional _getNotes() { + return notes; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("tracking_number") + private Optional _getTrackingNumber() { + return trackingNumber; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("line_items") + private Optional> _getLineItems() { + return lineItems; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateTransferOrderData && equalTo((UpdateTransferOrderData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateTransferOrderData other) { + return sourceLocationId.equals(other.sourceLocationId) + && destinationLocationId.equals(other.destinationLocationId) + && expectedAt.equals(other.expectedAt) + && notes.equals(other.notes) + && trackingNumber.equals(other.trackingNumber) + && lineItems.equals(other.lineItems); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.sourceLocationId, + this.destinationLocationId, + this.expectedAt, + this.notes, + this.trackingNumber, + this.lineItems); + } + + @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 sourceLocationId = Optional.empty(); + + private Optional destinationLocationId = Optional.empty(); + + private Optional expectedAt = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional trackingNumber = Optional.empty(); + + private Optional> lineItems = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateTransferOrderData other) { + sourceLocationId(other.getSourceLocationId()); + destinationLocationId(other.getDestinationLocationId()); + expectedAt(other.getExpectedAt()); + notes(other.getNotes()); + trackingNumber(other.getTrackingNumber()); + lineItems(other.getLineItems()); + return this; + } + + /** + *

    The source Location that will send the items. Must be an active location + * in your Square account with sufficient inventory of the requested items.

    + */ + @JsonSetter(value = "source_location_id", nulls = Nulls.SKIP) + public Builder sourceLocationId(Optional sourceLocationId) { + this.sourceLocationId = sourceLocationId; + return this; + } + + public Builder sourceLocationId(String sourceLocationId) { + this.sourceLocationId = Optional.ofNullable(sourceLocationId); + return this; + } + + public Builder sourceLocationId(Nullable sourceLocationId) { + if (sourceLocationId.isNull()) { + this.sourceLocationId = null; + } else if (sourceLocationId.isEmpty()) { + this.sourceLocationId = Optional.empty(); + } else { + this.sourceLocationId = Optional.of(sourceLocationId.get()); + } + return this; + } + + /** + *

    The destination Location that will receive the items. Must be an active location + * in your Square account.

    + */ + @JsonSetter(value = "destination_location_id", nulls = Nulls.SKIP) + public Builder destinationLocationId(Optional destinationLocationId) { + this.destinationLocationId = destinationLocationId; + return this; + } + + public Builder destinationLocationId(String destinationLocationId) { + this.destinationLocationId = Optional.ofNullable(destinationLocationId); + return this; + } + + public Builder destinationLocationId(Nullable destinationLocationId) { + if (destinationLocationId.isNull()) { + this.destinationLocationId = null; + } else if (destinationLocationId.isEmpty()) { + this.destinationLocationId = Optional.empty(); + } else { + this.destinationLocationId = Optional.of(destinationLocationId.get()); + } + return this; + } + + /** + *

    Expected transfer date in RFC 3339 format (e.g. "2023-10-01T12:00:00Z").

    + */ + @JsonSetter(value = "expected_at", nulls = Nulls.SKIP) + public Builder expectedAt(Optional expectedAt) { + this.expectedAt = expectedAt; + return this; + } + + public Builder expectedAt(String expectedAt) { + this.expectedAt = Optional.ofNullable(expectedAt); + return this; + } + + public Builder expectedAt(Nullable expectedAt) { + if (expectedAt.isNull()) { + this.expectedAt = null; + } else if (expectedAt.isEmpty()) { + this.expectedAt = Optional.empty(); + } else { + this.expectedAt = Optional.of(expectedAt.get()); + } + return this; + } + + /** + *

    Optional notes about the transfer

    + */ + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(String notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + public Builder notes(Nullable notes) { + if (notes.isNull()) { + this.notes = null; + } else if (notes.isEmpty()) { + this.notes = Optional.empty(); + } else { + this.notes = Optional.of(notes.get()); + } + return this; + } + + /** + *

    Shipment tracking number

    + */ + @JsonSetter(value = "tracking_number", nulls = Nulls.SKIP) + public Builder trackingNumber(Optional trackingNumber) { + this.trackingNumber = trackingNumber; + return this; + } + + public Builder trackingNumber(String trackingNumber) { + this.trackingNumber = Optional.ofNullable(trackingNumber); + return this; + } + + public Builder trackingNumber(Nullable trackingNumber) { + if (trackingNumber.isNull()) { + this.trackingNumber = null; + } else if (trackingNumber.isEmpty()) { + this.trackingNumber = Optional.empty(); + } else { + this.trackingNumber = Optional.of(trackingNumber.get()); + } + return this; + } + + /** + *

    List of items being transferred

    + */ + @JsonSetter(value = "line_items", nulls = Nulls.SKIP) + public Builder lineItems(Optional> lineItems) { + this.lineItems = lineItems; + return this; + } + + public Builder lineItems(List lineItems) { + this.lineItems = Optional.ofNullable(lineItems); + return this; + } + + public Builder lineItems(Nullable> lineItems) { + if (lineItems.isNull()) { + this.lineItems = null; + } else if (lineItems.isEmpty()) { + this.lineItems = Optional.empty(); + } else { + this.lineItems = Optional.of(lineItems.get()); + } + return this; + } + + public UpdateTransferOrderData build() { + return new UpdateTransferOrderData( + sourceLocationId, + destinationLocationId, + expectedAt, + notes, + trackingNumber, + lineItems, + additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/UpdateTransferOrderLineData.java b/src/main/java/com/squareup/square/types/UpdateTransferOrderLineData.java new file mode 100644 index 00000000..ab1bf4a9 --- /dev/null +++ b/src/main/java/com/squareup/square/types/UpdateTransferOrderLineData.java @@ -0,0 +1,278 @@ +/** + * 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.JsonIgnore; +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.Nullable; +import com.squareup.square.core.NullableNonemptyFilter; +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 = UpdateTransferOrderLineData.Builder.class) +public final class UpdateTransferOrderLineData { + private final Optional uid; + + private final Optional itemVariationId; + + private final Optional quantityOrdered; + + private final Optional remove; + + private final Map additionalProperties; + + private UpdateTransferOrderLineData( + Optional uid, + Optional itemVariationId, + Optional quantityOrdered, + Optional remove, + Map additionalProperties) { + this.uid = uid; + this.itemVariationId = itemVariationId; + this.quantityOrdered = quantityOrdered; + this.remove = remove; + this.additionalProperties = additionalProperties; + } + + /** + * @return Line item id being updated. Required for updating/removing existing line items, but should not be set for new line items. + */ + @JsonIgnore + public Optional getUid() { + if (uid == null) { + return Optional.empty(); + } + return uid; + } + + /** + * @return Catalog item variation being transferred + *

    Required for new line items, but otherwise is not updatable.

    + */ + @JsonIgnore + public Optional getItemVariationId() { + if (itemVariationId == null) { + return Optional.empty(); + } + return itemVariationId; + } + + /** + * @return Total quantity ordered + */ + @JsonIgnore + public Optional getQuantityOrdered() { + if (quantityOrdered == null) { + return Optional.empty(); + } + return quantityOrdered; + } + + /** + * @return Flag to remove the line item during update. Must include uid in removal request + */ + @JsonIgnore + public Optional getRemove() { + if (remove == null) { + return Optional.empty(); + } + return remove; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("uid") + private Optional _getUid() { + return uid; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("item_variation_id") + private Optional _getItemVariationId() { + return itemVariationId; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("quantity_ordered") + private Optional _getQuantityOrdered() { + return quantityOrdered; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("remove") + private Optional _getRemove() { + return remove; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateTransferOrderLineData && equalTo((UpdateTransferOrderLineData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateTransferOrderLineData other) { + return uid.equals(other.uid) + && itemVariationId.equals(other.itemVariationId) + && quantityOrdered.equals(other.quantityOrdered) + && remove.equals(other.remove); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.uid, this.itemVariationId, this.quantityOrdered, this.remove); + } + + @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 uid = Optional.empty(); + + private Optional itemVariationId = Optional.empty(); + + private Optional quantityOrdered = Optional.empty(); + + private Optional remove = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateTransferOrderLineData other) { + uid(other.getUid()); + itemVariationId(other.getItemVariationId()); + quantityOrdered(other.getQuantityOrdered()); + remove(other.getRemove()); + return this; + } + + /** + *

    Line item id being updated. Required for updating/removing existing line items, but should not be set for new line items.

    + */ + @JsonSetter(value = "uid", nulls = Nulls.SKIP) + public Builder uid(Optional uid) { + this.uid = uid; + return this; + } + + public Builder uid(String uid) { + this.uid = Optional.ofNullable(uid); + return this; + } + + public Builder uid(Nullable uid) { + if (uid.isNull()) { + this.uid = null; + } else if (uid.isEmpty()) { + this.uid = Optional.empty(); + } else { + this.uid = Optional.of(uid.get()); + } + return this; + } + + /** + *

    Catalog item variation being transferred

    + *

    Required for new line items, but otherwise is not updatable.

    + */ + @JsonSetter(value = "item_variation_id", nulls = Nulls.SKIP) + public Builder itemVariationId(Optional itemVariationId) { + this.itemVariationId = itemVariationId; + return this; + } + + public Builder itemVariationId(String itemVariationId) { + this.itemVariationId = Optional.ofNullable(itemVariationId); + return this; + } + + public Builder itemVariationId(Nullable itemVariationId) { + if (itemVariationId.isNull()) { + this.itemVariationId = null; + } else if (itemVariationId.isEmpty()) { + this.itemVariationId = Optional.empty(); + } else { + this.itemVariationId = Optional.of(itemVariationId.get()); + } + return this; + } + + /** + *

    Total quantity ordered

    + */ + @JsonSetter(value = "quantity_ordered", nulls = Nulls.SKIP) + public Builder quantityOrdered(Optional quantityOrdered) { + this.quantityOrdered = quantityOrdered; + return this; + } + + public Builder quantityOrdered(String quantityOrdered) { + this.quantityOrdered = Optional.ofNullable(quantityOrdered); + return this; + } + + public Builder quantityOrdered(Nullable quantityOrdered) { + if (quantityOrdered.isNull()) { + this.quantityOrdered = null; + } else if (quantityOrdered.isEmpty()) { + this.quantityOrdered = Optional.empty(); + } else { + this.quantityOrdered = Optional.of(quantityOrdered.get()); + } + return this; + } + + /** + *

    Flag to remove the line item during update. Must include uid in removal request

    + */ + @JsonSetter(value = "remove", nulls = Nulls.SKIP) + public Builder remove(Optional remove) { + this.remove = remove; + return this; + } + + public Builder remove(Boolean remove) { + this.remove = Optional.ofNullable(remove); + return this; + } + + public Builder remove(Nullable remove) { + if (remove.isNull()) { + this.remove = null; + } else if (remove.isEmpty()) { + this.remove = Optional.empty(); + } else { + this.remove = Optional.of(remove.get()); + } + return this; + } + + public UpdateTransferOrderLineData build() { + return new UpdateTransferOrderLineData(uid, itemVariationId, quantityOrdered, remove, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/UpdateTransferOrderRequest.java b/src/main/java/com/squareup/square/types/UpdateTransferOrderRequest.java new file mode 100644 index 00000000..a6e0b568 --- /dev/null +++ b/src/main/java/com/squareup/square/types/UpdateTransferOrderRequest.java @@ -0,0 +1,232 @@ +/** + * 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 = UpdateTransferOrderRequest.Builder.class) +public final class UpdateTransferOrderRequest { + private final String transferOrderId; + + private final String idempotencyKey; + + private final UpdateTransferOrderData transferOrder; + + private final Optional version; + + private final Map additionalProperties; + + private UpdateTransferOrderRequest( + String transferOrderId, + String idempotencyKey, + UpdateTransferOrderData transferOrder, + Optional version, + Map additionalProperties) { + this.transferOrderId = transferOrderId; + this.idempotencyKey = idempotencyKey; + this.transferOrder = transferOrder; + this.version = version; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the transfer order to update + */ + @JsonProperty("transfer_order_id") + public String getTransferOrderId() { + return transferOrderId; + } + + /** + * @return A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores + */ + @JsonProperty("idempotency_key") + public String getIdempotencyKey() { + return idempotencyKey; + } + + /** + * @return The transfer order updates to apply + */ + @JsonProperty("transfer_order") + public UpdateTransferOrderData getTransferOrder() { + return transferOrder; + } + + /** + * @return Version for optimistic concurrency + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateTransferOrderRequest && equalTo((UpdateTransferOrderRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateTransferOrderRequest other) { + return transferOrderId.equals(other.transferOrderId) + && idempotencyKey.equals(other.idempotencyKey) + && transferOrder.equals(other.transferOrder) + && version.equals(other.version); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrderId, this.idempotencyKey, this.transferOrder, this.version); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TransferOrderIdStage builder() { + return new Builder(); + } + + public interface TransferOrderIdStage { + /** + *

    The ID of the transfer order to update

    + */ + IdempotencyKeyStage transferOrderId(@NotNull String transferOrderId); + + Builder from(UpdateTransferOrderRequest other); + } + + public interface IdempotencyKeyStage { + /** + *

    A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores

    + */ + TransferOrderStage idempotencyKey(@NotNull String idempotencyKey); + } + + public interface TransferOrderStage { + /** + *

    The transfer order updates to apply

    + */ + _FinalStage transferOrder(@NotNull UpdateTransferOrderData transferOrder); + } + + public interface _FinalStage { + UpdateTransferOrderRequest build(); + + /** + *

    Version for optimistic concurrency

    + */ + _FinalStage version(Optional version); + + _FinalStage version(Long version); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements TransferOrderIdStage, IdempotencyKeyStage, TransferOrderStage, _FinalStage { + private String transferOrderId; + + private String idempotencyKey; + + private UpdateTransferOrderData transferOrder; + + private Optional version = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateTransferOrderRequest other) { + transferOrderId(other.getTransferOrderId()); + idempotencyKey(other.getIdempotencyKey()); + transferOrder(other.getTransferOrder()); + version(other.getVersion()); + return this; + } + + /** + *

    The ID of the transfer order to update

    + *

    The ID of the transfer order to update

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

    A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores

    + *

    A unique string that identifies this UpdateTransferOrder request. Keys must contain only alphanumeric characters, dashes and underscores

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

    The transfer order updates to apply

    + *

    The transfer order updates to apply

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

    Version for optimistic concurrency

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

    Version for optimistic concurrency

    + */ + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + @java.lang.Override + public UpdateTransferOrderRequest build() { + return new UpdateTransferOrderRequest( + transferOrderId, idempotencyKey, transferOrder, version, additionalProperties); + } + } +} diff --git a/src/main/java/com/squareup/square/types/UpdateTransferOrderResponse.java b/src/main/java/com/squareup/square/types/UpdateTransferOrderResponse.java new file mode 100644 index 00000000..06fafaa5 --- /dev/null +++ b/src/main/java/com/squareup/square/types/UpdateTransferOrderResponse.java @@ -0,0 +1,133 @@ +/** + * 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 = UpdateTransferOrderResponse.Builder.class) +public final class UpdateTransferOrderResponse { + private final Optional transferOrder; + + private final Optional> errors; + + private final Map additionalProperties; + + private UpdateTransferOrderResponse( + Optional transferOrder, + Optional> errors, + Map additionalProperties) { + this.transferOrder = transferOrder; + this.errors = errors; + this.additionalProperties = additionalProperties; + } + + /** + * @return The updated transfer order + */ + @JsonProperty("transfer_order") + public Optional getTransferOrder() { + return transferOrder; + } + + /** + * @return Any errors that occurred during the request + */ + @JsonProperty("errors") + public Optional> getErrors() { + return errors; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateTransferOrderResponse && equalTo((UpdateTransferOrderResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateTransferOrderResponse other) { + return transferOrder.equals(other.transferOrder) && errors.equals(other.errors); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.transferOrder, this.errors); + } + + @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 transferOrder = Optional.empty(); + + private Optional> errors = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateTransferOrderResponse other) { + transferOrder(other.getTransferOrder()); + errors(other.getErrors()); + return this; + } + + /** + *

    The updated transfer order

    + */ + @JsonSetter(value = "transfer_order", nulls = Nulls.SKIP) + public Builder transferOrder(Optional transferOrder) { + this.transferOrder = transferOrder; + return this; + } + + public Builder transferOrder(TransferOrder transferOrder) { + this.transferOrder = Optional.ofNullable(transferOrder); + return this; + } + + /** + *

    Any errors that occurred during the request

    + */ + @JsonSetter(value = "errors", nulls = Nulls.SKIP) + public Builder errors(Optional> errors) { + this.errors = errors; + return this; + } + + public Builder errors(List errors) { + this.errors = Optional.ofNullable(errors); + return this; + } + + public UpdateTransferOrderResponse build() { + return new UpdateTransferOrderResponse(transferOrder, errors, additionalProperties); + } + } +}