From 20a32171a4423a1e895681d74b50e8519218dc2e Mon Sep 17 00:00:00 2001 From: Jenkins Square SDK Update Date: Wed, 12 Aug 2020 16:49:52 +0000 Subject: [PATCH] release --- CHANGELOG.md | 62 +- README.md | 666 +++++++++--------- doc/models/action-cancel-reason.md | 6 +- doc/models/bank-account-status.md | 2 +- doc/models/bank-account-type.md | 2 +- doc/models/cancel-subscription-response.md | 37 + doc/models/card-brand.md | 12 +- doc/models/card-prepaid-type.md | 4 +- doc/models/card-type.md | 2 +- doc/models/cash-drawer-event-type.md | 18 +- ...tom-attribute-definition-app-visibility.md | 6 +- ...-attribute-definition-seller-visibility.md | 4 +- .../catalog-custom-attribute-definition.md | 6 +- .../catalog-discount-modify-tax-basis.md | 4 +- doc/models/catalog-discount-type.md | 8 +- doc/models/catalog-item-product-type.md | 4 +- doc/models/catalog-object-batch.md | 6 +- doc/models/catalog-object-type.md | 21 +- doc/models/catalog-object.md | 6 +- doc/models/catalog-pricing-type.md | 4 +- doc/models/catalog-quick-amount-type.md | 4 +- doc/models/catalog-subscription-plan.md | 25 + doc/models/create-customer-request.md | 2 +- doc/models/create-subscription-request.md | 43 ++ doc/models/create-subscription-response.md | 40 ++ doc/models/currency.md | 2 +- doc/models/customer-creation-source.md | 14 +- doc/models/customer-sort-field.md | 2 +- doc/models/dispute-evidence-type.md | 28 +- doc/models/dispute-reason.md | 14 +- doc/models/dispute-state.md | 12 +- doc/models/error-category.md | 12 +- doc/models/error-code.md | 240 +++---- doc/models/exclude-strategy.md | 4 +- doc/models/inventory-alert-type.md | 2 +- doc/models/inventory-change-type.md | 2 +- doc/models/inventory-state.md | 16 +- doc/models/invoice-payment-reminder-status.md | 2 +- doc/models/invoice-request-method.md | 4 +- doc/models/invoice-sort-field.md | 2 +- doc/models/invoice-status.md | 4 +- .../list-subscription-events-request.md | 26 + .../list-subscription-events-response.md | 39 + doc/models/location-capability.md | 2 +- doc/models/loyalty-event-source.md | 2 +- doc/models/loyalty-event-type.md | 12 +- .../loyalty-program-accrual-rule-type.md | 2 +- ...loyalty-program-reward-definition-scope.md | 2 +- .../loyalty-program-reward-definition-type.md | 4 +- doc/models/measurement-unit-area.md | 16 +- doc/models/measurement-unit-length.md | 16 +- doc/models/measurement-unit-time.md | 10 +- doc/models/measurement-unit-unit-type.md | 12 +- doc/models/measurement-unit-volume.md | 22 +- doc/models/measurement-unit-weight.md | 12 +- doc/models/order-line-item-discount-scope.md | 4 +- doc/models/order-line-item-discount-type.md | 10 +- doc/models/order-line-item-tax-scope.md | 4 +- doc/models/order-line-item-tax-type.md | 2 +- .../order-service-charge-calculation-phase.md | 4 +- doc/models/product-type.md | 2 +- doc/models/product.md | 8 +- doc/models/retrieve-subscription-response.md | 43 ++ doc/models/search-orders-sort-field.md | 6 +- doc/models/search-subscriptions-filter.md | 24 + doc/models/search-subscriptions-query.md | 22 + doc/models/search-subscriptions-request.md | 35 + doc/models/search-subscriptions-response.md | 76 ++ doc/models/shift-sort-field.md | 8 +- doc/models/shift-workday-matcher.md | 4 +- doc/models/subscription-cadence.md | 26 + ...scription-event-subscription-event-type.md | 16 + doc/models/subscription-event.md | 28 + doc/models/subscription-phase.md | 34 + doc/models/subscription-status.md | 17 + doc/models/subscription.md | 52 ++ doc/models/tax-calculation-phase.md | 4 +- ...mber-assigned-locations-assignment-type.md | 4 +- .../tender-card-details-entry-method.md | 2 +- doc/models/tender-type.md | 6 +- doc/models/transaction-product.md | 4 +- doc/models/update-subscription-request.md | 30 + doc/models/update-subscription-response.md | 37 + ...djust-inventory-request-adjustment-type.md | 4 +- doc/models/v1-bank-account-type.md | 2 +- doc/models/v1-cash-drawer-event-event-type.md | 18 +- doc/models/v1-discount-color.md | 18 +- doc/models/v1-discount-discount-type.md | 4 +- doc/models/v1-employee-role-permissions.md | 14 +- doc/models/v1-fee-calculation-phase.md | 4 +- doc/models/v1-fee-type.md | 14 +- doc/models/v1-item-color.md | 18 +- doc/models/v1-item-type.md | 2 +- doc/models/v1-merchant-business-type.md | 82 +-- doc/models/v1-order-history-entry-action.md | 4 +- doc/models/v1-page-cell-placeholder-type.md | 6 +- ...v1-payment-itemization-itemization-type.md | 8 +- doc/models/v1-payment-surcharge-type.md | 2 +- doc/models/v1-settlement-entry-type.md | 34 +- doc/models/v1-tender-card-brand.md | 12 +- doc/models/v1-tender-entry-method.md | 6 +- doc/models/v1-tender-type.md | 10 +- doc/models/v1-timecard-event-event-type.md | 16 +- .../v1-variation-inventory-alert-type.md | 2 +- doc/models/v1-variation-pricing-type.md | 4 +- doc/subscriptions.md | 285 ++++++++ pom.xml | 4 +- .../square/AccessTokenCredentials.java | 2 +- .../squareup/square/AccessTokenManager.java | 2 +- .../java/com/squareup/square/ApiHelper.java | 2 +- .../java/com/squareup/square/Environment.java | 2 +- src/main/java/com/squareup/square/Server.java | 2 +- .../com/squareup/square/SquareClient.java | 18 +- .../square/SquareClientInterface.java | 9 +- .../com/squareup/square/api/ApplePayApi.java | 2 +- .../squareup/square/api/BankAccountsApi.java | 2 +- .../java/com/squareup/square/api/BaseApi.java | 2 +- .../squareup/square/api/CashDrawersApi.java | 2 +- .../com/squareup/square/api/CatalogApi.java | 2 +- .../com/squareup/square/api/CheckoutApi.java | 2 +- .../square/api/CustomerGroupsApi.java | 2 +- .../square/api/CustomerSegmentsApi.java | 2 +- .../com/squareup/square/api/CustomersApi.java | 2 +- .../square/api/DefaultApplePayApi.java | 2 +- .../square/api/DefaultBankAccountsApi.java | 2 +- .../square/api/DefaultCashDrawersApi.java | 2 +- .../square/api/DefaultCatalogApi.java | 2 +- .../square/api/DefaultCheckoutApi.java | 2 +- .../square/api/DefaultCustomerGroupsApi.java | 2 +- .../api/DefaultCustomerSegmentsApi.java | 2 +- .../square/api/DefaultCustomersApi.java | 2 +- .../square/api/DefaultDevicesApi.java | 2 +- .../square/api/DefaultDisputesApi.java | 2 +- .../square/api/DefaultEmployeesApi.java | 2 +- .../square/api/DefaultInventoryApi.java | 2 +- .../square/api/DefaultInvoicesApi.java | 2 +- .../squareup/square/api/DefaultLaborApi.java | 2 +- .../square/api/DefaultLocationsApi.java | 2 +- .../square/api/DefaultLoyaltyApi.java | 2 +- .../square/api/DefaultMerchantsApi.java | 2 +- .../api/DefaultMobileAuthorizationApi.java | 2 +- .../squareup/square/api/DefaultOAuthApi.java | 2 +- .../squareup/square/api/DefaultOrdersApi.java | 2 +- .../square/api/DefaultPaymentsApi.java | 2 +- .../square/api/DefaultRefundsApi.java | 2 +- .../square/api/DefaultReportingApi.java | 2 +- .../square/api/DefaultSubscriptionsApi.java | 664 +++++++++++++++++ .../squareup/square/api/DefaultTeamApi.java | 2 +- .../square/api/DefaultTerminalApi.java | 2 +- .../square/api/DefaultTransactionsApi.java | 2 +- .../square/api/DefaultV1EmployeesApi.java | 2 +- .../square/api/DefaultV1ItemsApi.java | 2 +- .../square/api/DefaultV1LocationsApi.java | 2 +- .../square/api/DefaultV1TransactionsApi.java | 2 +- .../com/squareup/square/api/DevicesApi.java | 2 +- .../com/squareup/square/api/DisputesApi.java | 2 +- .../com/squareup/square/api/EmployeesApi.java | 2 +- .../com/squareup/square/api/InventoryApi.java | 2 +- .../com/squareup/square/api/InvoicesApi.java | 2 +- .../com/squareup/square/api/LaborApi.java | 2 +- .../com/squareup/square/api/LocationsApi.java | 2 +- .../com/squareup/square/api/LoyaltyApi.java | 2 +- .../com/squareup/square/api/MerchantsApi.java | 2 +- .../square/api/MobileAuthorizationApi.java | 2 +- .../com/squareup/square/api/OAuthApi.java | 2 +- .../com/squareup/square/api/OrdersApi.java | 2 +- .../com/squareup/square/api/PaymentsApi.java | 2 +- .../com/squareup/square/api/RefundsApi.java | 2 +- .../com/squareup/square/api/ReportingApi.java | 2 +- .../squareup/square/api/SubscriptionsApi.java | 181 +++++ .../java/com/squareup/square/api/TeamApi.java | 2 +- .../com/squareup/square/api/TerminalApi.java | 2 +- .../squareup/square/api/TransactionsApi.java | 2 +- .../squareup/square/api/V1EmployeesApi.java | 2 +- .../com/squareup/square/api/V1ItemsApi.java | 2 +- .../squareup/square/api/V1LocationsApi.java | 2 +- .../square/api/V1TransactionsApi.java | 2 +- .../square/exceptions/ApiException.java | 2 +- .../square/http/client/HttpCallback.java | 2 +- .../square/http/client/HttpClient.java | 2 +- .../http/client/HttpClientConfiguration.java | 2 +- .../square/http/client/HttpContext.java | 2 +- .../ReadonlyHttpClientConfiguration.java | 2 +- .../square/http/response/HttpResponse.java | 2 +- .../models/CancelSubscriptionResponse.java | 142 ++++ .../squareup/square/models/CatalogObject.java | 31 +- .../models/CatalogSubscriptionPlan.java | 121 ++++ .../square/models/CreateCustomerRequest.java | 2 +- .../models/CreateSubscriptionRequest.java | 355 ++++++++++ .../models/CreateSubscriptionResponse.java | 142 ++++ .../models/ListSubscriptionEventsRequest.java | 124 ++++ .../ListSubscriptionEventsResponse.java | 169 +++++ .../models/RetrieveSubscriptionResponse.java | 142 ++++ .../models/SearchSubscriptionsFilter.java | 121 ++++ .../models/SearchSubscriptionsQuery.java | 94 +++ .../models/SearchSubscriptionsRequest.java | 150 ++++ .../models/SearchSubscriptionsResponse.java | 169 +++++ .../squareup/square/models/Subscription.java | 489 +++++++++++++ .../square/models/SubscriptionEvent.java | 178 +++++ .../square/models/SubscriptionPhase.java | 204 ++++++ .../models/UpdateSubscriptionRequest.java | 96 +++ .../models/UpdateSubscriptionResponse.java | 142 ++++ 202 files changed, 5586 insertions(+), 919 deletions(-) create mode 100644 doc/models/cancel-subscription-response.md create mode 100644 doc/models/catalog-subscription-plan.md create mode 100644 doc/models/create-subscription-request.md create mode 100644 doc/models/create-subscription-response.md create mode 100644 doc/models/list-subscription-events-request.md create mode 100644 doc/models/list-subscription-events-response.md create mode 100644 doc/models/retrieve-subscription-response.md create mode 100644 doc/models/search-subscriptions-filter.md create mode 100644 doc/models/search-subscriptions-query.md create mode 100644 doc/models/search-subscriptions-request.md create mode 100644 doc/models/search-subscriptions-response.md create mode 100644 doc/models/subscription-cadence.md create mode 100644 doc/models/subscription-event-subscription-event-type.md create mode 100644 doc/models/subscription-event.md create mode 100644 doc/models/subscription-phase.md create mode 100644 doc/models/subscription-status.md create mode 100644 doc/models/subscription.md create mode 100644 doc/models/update-subscription-request.md create mode 100644 doc/models/update-subscription-response.md create mode 100644 doc/subscriptions.md create mode 100644 src/main/java/com/squareup/square/api/DefaultSubscriptionsApi.java create mode 100644 src/main/java/com/squareup/square/api/SubscriptionsApi.java create mode 100644 src/main/java/com/squareup/square/models/CancelSubscriptionResponse.java create mode 100644 src/main/java/com/squareup/square/models/CatalogSubscriptionPlan.java create mode 100644 src/main/java/com/squareup/square/models/CreateSubscriptionRequest.java create mode 100644 src/main/java/com/squareup/square/models/CreateSubscriptionResponse.java create mode 100644 src/main/java/com/squareup/square/models/ListSubscriptionEventsRequest.java create mode 100644 src/main/java/com/squareup/square/models/ListSubscriptionEventsResponse.java create mode 100644 src/main/java/com/squareup/square/models/RetrieveSubscriptionResponse.java create mode 100644 src/main/java/com/squareup/square/models/SearchSubscriptionsFilter.java create mode 100644 src/main/java/com/squareup/square/models/SearchSubscriptionsQuery.java create mode 100644 src/main/java/com/squareup/square/models/SearchSubscriptionsRequest.java create mode 100644 src/main/java/com/squareup/square/models/SearchSubscriptionsResponse.java create mode 100644 src/main/java/com/squareup/square/models/Subscription.java create mode 100644 src/main/java/com/squareup/square/models/SubscriptionEvent.java create mode 100644 src/main/java/com/squareup/square/models/SubscriptionPhase.java create mode 100644 src/main/java/com/squareup/square/models/UpdateSubscriptionRequest.java create mode 100644 src/main/java/com/squareup/square/models/UpdateSubscriptionResponse.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 93238350..e1b7cd5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Change Log +## Version 6.2.0.20200812 (2020-08-12) +## API releases +* Subscriptions API (beta): + * For an overview, see [Square Subscriptions.](https://developer.squareup.com/docs/subscriptions/overview) + * For technical reference, see [Subscriptions API.](https://developer.squareup.com/reference/square_2020-08-12/subscriptions-api) + +## Existing API updates +* Catalog API + * [CatalogSubscriptionPlan](https://developer.squareup.com/reference/square_2020-08-12/objects/CatalogSubscriptionPlan) (beta). This catalog type is added in support of the Subscriptions API. Subscription plans are stored as catalog object of the `SUBSCRIPTION_PLAN` type. For more information, see [Set Up and Manage a Subscription Plan.](https://developer.squareup.com/docs/subscriptions-api/setup-plan) + +## SqPaymentForm SDK updates +* [SqPaymentForm.masterpassImageURL.](https://developer.squareup.com/docs/api/paymentform#masterpassimageurl) This function is updated to return a Secure Remote Commerce background image URL. + +## Documentation updates +* Locations API + * [About the main location.](https://developer.squareup.com/docs/locations-api#about-the-main-location) Added clarifying information about the main location concept. +* OAuth API + * [Migrate to the Square API OAuth Flow.](https://developer.squareup.com/docs/oauth-api/migrate-to-square-oauth-flow) Added a new topic to document migration from a v1 location-scoped OAuth access token to the Square seller-scoped OAuth access token. +* Payment Form SDK + * Renamed the Add a Masterpass Button topic to [Add a Secure Remote Commerce Button.](https://developer.squareup.com/docs/payment-form/add-digital-wallets/masterpass) Updated the instructions to add a Secure Remote Commerce button to replace a legacy Masterpass button. + * [Payment form technical reference.](https://developer.squareup.com/docs/api/paymentform) Updated the reference to show code examples for adding a Secure Remote Commerce button. + ## Version 6.1.0.20200722 (2020-07-22) ## API releases @@ -114,7 +136,7 @@ * For an overview, see [Overview](/customer-segmentss-api/what-it-does) * For technical reference, see [Customer Segments]( https://developer.squareup.com/reference/square/customer-segments-api). - + * **New webhooks.** v2 Webhooks (beta) now supports webhooks for the following APIs: * Orders API. `order.created`, `order.updated`, and `order.fulfillment.updated` * Terminal API. `terminal.checkout.created` and `terminal.checkout.updated` @@ -187,49 +209,19 @@ All SDKs have been updated to support the following changes: * **Shared object updates** * **Card object** — New fields added: `card_type`, `prepaid_type`. Currently, only the Payments API responses populate these fields. - -## Version 4.1.0.20200122 (2020-01-22) +## Version 4.1.0.20200122 (2020-01-22) * New field: The **Employee** object now has an `is_owner` field. * New enumeration: The **CardBrand** enumeration has a new `SQUARE_CAPITAL_CARD` enum value to support a Square one-time Installments payment. * New request body field constraint: The __Refund__ Payment request now requires a payment_id. -## Version 4.0.0-20191217 (2019-12-17) -!!!important -Square is excited to announce the public release of customized SDKs for [Java](https://github.com/square/square-java-sdk) and [.NET](https://github.com/square/square-dotnet-sdk). For more information, see [Square SDKs](/sdks). -!!! +## Version 4.0.0.20191217 (2019-12-17) +* Square is excited to announce the public release of customized SDK for Java * __GA release:__ SDKs updated to support new `receipt_url` and `receipt_number` fields added to the [Payment](https://developer.squareup.com/reference/square/objects/Payment) type. * __Beta release:__ SDKs updated to support the new [CashDrawerShifts](cashdrawershift-api/reporting) API. * Square now follows the semantic versioning scheme for all SDKs except PHP and Node.js. This versioning scheme uses three numbers to delineate MAJOR, MINOR, and PATCH versions of our SDK. In addition, the SDK version also includes the API version so you know what Square API version the SDK is related to. For more information, see [Versioning and SDKs](build-basics/versioning-overview#versioning-and-sdks). -* Java, .Net, Python, and Ruby SDKs are now version 4.0.0. Java and .Net SDKs have breaking changes in version 4.0.0. Ruby and Python do not have breaking changes. - -## Version 3.20191120.0 (2019-11-20) -!!!important -Square has begun the retirement process for Connect v1 APIs. See the [Connect v1 Retirement](/migrate-from-v1) information page for details. -!!! - -* __GA releases:__ SDKs now support the new `modify_tax_basis` field to Discounts and v2 Sandbox -* __BETA releases:__ SDKs now support the Shifts API webhooks for Labor shift created, updated, deleted, CreateLocation endpoint, and the ability to customize statement description in Payments API. -* **Deprecated**: Support for v1Items API and v1Locations API is fully deprecated. - -## 3.20191023.0 (2019-10-23) -* **GA release**: Merchants.ListMerchant is GA for all SDKs. -* **Beta release**: All SDKs support exclusion strategies for pricing rules. - -## 3.20190925.0 (2019-09-25) - -* **GA release**: All SDKs have been updated to support the new Merchants API. - -* **Beta release**: All SDKs have been updated to support the new endpoints (RetrieveLocation, UpdateLocation) added to the Locations API. - -* **Beta release**: All SDKs have been updated to support the new field (`mcc`) added to the `Location` type. - -* **GA release**: All SDKs have been updated to support the new field (`bin`) added to the `Card` type. - -* **GA release**: All SDKs have been updated to support the new `CardPaymentDetails` fields (`verification_results`, `statement_description`, and `verification_method`). - -* **GA release**: All SDKs have been updated to support the new `Payment` field, (`employee_id`). \ No newline at end of file +* Java, .Net, Python, and Ruby SDKs are now version 4.0.0. Java and .Net SDKs have breaking changes in version 4.0.0. Ruby and Python do not have breaking changes. \ No newline at end of file diff --git a/README.md b/README.md index 152cf317..59c7a09b 100644 --- a/README.md +++ b/README.md @@ -1,331 +1,335 @@ -![Square logo] - -# Square Java SDK - -[![Travis status](https://travis-ci.com/square/square-java-sdk.svg?branch=master)](https://travis-ci.com/square/square-java-sdk) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.squareup/square/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.squareup/square) -[![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0) - -Use this library to integrate Square payments into your app and grow your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, and Orders. - -## Requirements - -Use of the Square Java SDK requires: - -* Java 8 or better -* Maven or Gradle to build and install the SDK. - -## Installation - -### Install with Maven - -Install the API client library to your local Maven repository: - -``` -mvn install -DskipTests -``` - -**OR** - -Install the client dynamically by adding a dependency to the POM for your project: - -``` - - com.squareup - square - 6.1.0.20200722 - -``` - -### Install with Gradle - -Install the client by adding the following dependency to the build file for your project: - -``` -implementation "com.squareup:square:6.1.0.20200722" -``` - -## API documentation - -### Payments -* [Payments] -* [Refunds] -* [Disputes] -* [Checkout] -* [Apple Pay] -* [Terminal] - -### Orders -* [Orders] - -### Invoices -* [Invoices] - -### Items -* [Catalog] -* [Inventory] - -### Customers -* [Customers] -* [Customer Groups] -* [Customer Segments] - -### Loyalty -* [Loyalty] - -### Business -* [Merchants] -* [Locations] -* [Devices] - -### Team -* [Team] -* [Employees] -* [Labor] -* [Cash Drawers] - -### Financials -* [Bank Accounts] - -### Authorization APIs -* [Mobile Authorization] -* [O Auth] - -### Deprecated APIs -* [V1 Locations] -* [V1 Employees] -* [V1 Transactions] -* [V1 Items] -* [Transactions] -* [Reporting] - -## Usage - -First time using Square? Here’s how to get started: - -1. **Create a Square account.** If you don’t have one already, [sign up for a developer account]. -1. **Create an application.** Go to your [Developer Dashboard] and create your first application. All you need to do is give it a name. When you’re doing this for your production application, enter the name as you would want a customer to see it. -1. **Make your first API call.** Almost all Square API calls require a location ID. You’ll make your first call to `listLocations`, which happens to be one of the API calls that don’t require a location ID. For more information about locations, see the [Locations] API documentation. - -Now let’s call your first Square API. - -```java -import java.util.List; -import java.io.IOException; - -import com.squareup.square.Environment; -import com.squareup.square.SquareClient; -import com.squareup.square.exceptions.ApiException; -import com.squareup.square.http.client.HttpContext; -import com.squareup.square.api.LocationsApi; -import com.squareup.square.models.Location; -import com.squareup.square.models.Error; - -public class Example { - public static void main(String[] args) { - SquareClient client = new SquareClient.Builder() - .environment(Environment.SANDBOX) - .accessToken("YOUR_SANDBOX_ACCESS_TOKEN") - .build(); - - LocationsApi api = client.getLocationsApi(); - - try { - List locations = api.listLocations().getLocations(); - // Your business logic code - System.out.println("calling listLocations successfully"); - } catch (ApiException e) { - List errors = e.getErrors(); - int statusCode = e.getResponseCode(); - HttpContext httpContext = e.getHttpContext(); - - // Your error handling code - System.err.println("ApiException when calling API"); - e.printStackTrace(); - } - catch (IOException e) { - // Your error handling code - System.err.println("IOException when calling API"); - e.printStackTrace(); - } - } -} -``` - -Next, get an access token and reference it in your code: - -1. Open the Developer Dashboard and select your application. The **Credentials** page for your app opens by default. -1. Set the dashboard mode to **Sandbox Settings** for a sandbox access token. -1. Copy the Access Token in the Credentials section of the page and replace `YOUR_SANDBOX_ACCESS_TOKEN` with the token. - -**Important** When you eventually switch from trying things out on sandbox to actually working with your real production resources, you should not embed the access token in your code. Make sure you store and access your production access tokens securely. - -## SDK patterns -If you know a few patterns, you’ll be able to call any API in the SDK. Here are some important ones: - -### Get an access token - -To use the Square API to manage the resources of a Square account (payments, orders, customers, etc.), you need to create an application (or use an existing one) in the Developer Dashboard and get an access token. Access tokens have specific permissions to resources in a specific Square account that can be accessed by a specific application in a specific developer account. -Use an access token that is appropriate for your use case. There are two options: - -- To manage the resources for your own Square account, use the **Personal Access Token** for the application created in your Square account. -- To manage resources for other Square accounts, use OAuth to ask owners of the accounts you want to manage so that you can work on their behalf. When you implement OAuth, you ask the Square account holder for permission to manage resources in their account and get an OAuth access token and refresh token for their account. You define the specific resources you want to access as part of the OAuth call. - -**Important** For both use cases, make sure you store and access the tokens securely. - -### Import and Instantiate the Client Class - -To use the Square API, you import the Client class, instantiate a Client object, and initialize it with the appropriate access token. Here’s how: - -- Initialize the `SquareClient` with environment set to sandbox: - -```java -SquareClient client = new SquareClient.Builder() - .environment(Environment.SANDBOX) - .accessToken("SANDBOX ACCESS TOKEN HERE") - .build(); -``` - -- To access production resources, set environment to production: - -```java -SquareClient client = new SquareClient.Builder() - .environment(Environment.PRODUCTION) - .accessToken("ACCESS TOKEN HERE") - .build(); -``` - -### Get an Instance of an API object and call its methods - -Each API is implemented as a class. The Client object instantiates every API class and exposes them as properties so you can easily start using any Square API. You work with an API by calling methods on an instance of an API class. Here’s how: - -- Work with an API by calling the methods on the API object. For example, you would call listCustomers to get a list of all customers in the Square account: - -```java -CustomersApi api = client.getCustomersApi(); -ListCustomersResponse listCustomersRes = api.listCustomers(null, null, null); -``` - -See the SDK documentation for the list of methods for each API class. - -- Pass complex parameters such as create, update, or search as a model. For example, you would pass a model containing the values used to create a new customer using create_customer: - -```java -CustomersApi api = client.getCustomersApi(); - -Address address = new Address.Builder() - .addressLine1("1455 Market St") - .addressLine2("San Francisco, CA 94103") - .build(); - -// Create a unique key(idempotency) for this creation operation so you don't accidentally -// create the customer multiple times if you need to retry this operation. -// For the purpose of example, we mark it as `unique_idempotency_key` -CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest.Builder() - .idempotencyKey("unique_idempotency_key") - .givenName("John") - .familyName("Smith") - .address(address) - .build(); - -// Call createCustomer method to create a new customer in this Square account -try { - CreateCustomerResponse response = api.createCustomer(createCustomerRequest); -} catch (ApiException e) { - List errors = e.getErrors(); - int statusCode = e.getResponseCode(); - HttpContext httpContext = e.getHttpContext(); - - // Your error handling code - System.err.println("ApiException when calling API"); - e.printStackTrace(); -} - -``` - -- Use idempotency for create, update, or other calls that you want to avoid calling twice. To make an idempotent API call, you add the idempotency_key with a unique value in the Hash for the API call’s request. -- Specify a location ID for APIs such as Transactions, Orders, and Checkout that deal with payments. When a payment or order is created in Square, it is always associated with a location. - -### Handle the response - -If your API call succeeds, Square API returns a response object containing an `HttpContext` that describe both the request and the response. Otherwise, the API throws an `ApiException`: - -```java -try { - List locations = api.listLocations().getLocations(); -} catch (ApiException e) { - List errors = e.getErrors(); - int statusCode = e.getResponseCode(); - HttpContext httpContext = e.getHttpContext(); - - // Your error handling code - System.err.println("ApiException when calling API"); - e.printStackTrace(); -} -``` - -## Tests - -First, clone the repo locally and `cd` into the directory. - -```sh -git clone https://github.com/square/square-java-sdk.git -cd square-java-sdk -``` - -Before running the tests, find a sandbox token in your [Developer Dashboard] and set a `SQUARE_ACCESS_TOKEN` environment variable. - -```sh -export SQUARE_ENVIRONMENT=sandbox -export SQUARE_ACCESS_TOKEN="YOUR_SANDBOX_ACCESS_TOKEN" -``` - -If you are using Maven, run the tests with below command - -```sh -mvn test -``` - -## Learn more - -The Square Platform is built on the [Square API]. Square has a number of other SDKs that enable you to securely handle credit card information on both mobile and web so that you can process payments via the Square API. - -You can also use the Square API to create applications or services that work with payments, orders, inventory, etc. that have been created and managed in Square’s in-person hardware products (Square Point of Sale and Square Register). - - -[//]: # "Link anchor definitions" -[Square Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg -[Developer Dashboard]: https://developer.squareup.com/apps -[Square API]: https://squareup.com/developers -[sign up for a developer account]: https://squareup.com/signup?v=developers -[Client]: doc/client.md -[Devices]: doc/devices.md -[Disputes]: doc/disputes.md -[Terminal]: doc/terminal.md -[Cash Drawers]: doc/cash-drawers.md -[Customer Groups]: doc/customer-groups.md -[Customer Segments]: doc/customer-segments.md -[Bank Accounts]: doc/bank-accounts -[Payments]: doc/payments.md -[Checkout]: doc/checkout.md -[Catalog]: doc/catalog.md -[Customers]: doc/customers.md -[Employees]: doc/employees.md -[Inventory]: doc/inventory.md -[Labor]: doc/labor.md -[Loyalty]: doc/loyalty.md -[Locations]: doc/locations.md -[Merchants]: doc/merchants.md -[Orders]: doc/orders.md -[Invoices]: doc/invoices.md -[Apple Pay]: doc/apple-pay.md -[Refunds]: doc/refunds.md -[Reporting]: doc/reporting.md -[Mobile Authorization]: doc/mobile-authorization.md -[O Auth]: doc/o-auth.md -[V1 Locations]: doc/v1-locations.md -[V1 Employees]: doc/v1-employees.md -[V1 Transactions]: doc/v1-transactions.md -[V1 Items]: doc/v1-items.md -[Team]: doc/team.md -[Transactions]: doc/transactions.md \ No newline at end of file +![Square logo] + +# Square Java SDK + +[![Travis status](https://travis-ci.com/square/square-java-sdk.svg?branch=master)](https://travis-ci.com/square/square-java-sdk) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.squareup/square/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.squareup/square) +[![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0) + +Use this library to integrate Square payments into your app and grow your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, and Orders. + +## Requirements + +Use of the Square Java SDK requires: + +* Java 8 or better +* Maven or Gradle to build and install the SDK. + +## Installation + +### Install with Maven + +Install the API client library to your local Maven repository: + +``` +mvn install -DskipTests +``` + +**OR** + +Install the client dynamically by adding a dependency to the POM for your project: + +``` + + com.squareup + square + 6.2.0.20200812 + +``` + +### Install with Gradle + +Install the client by adding the following dependency to the build file for your project: + +``` +implementation "com.squareup:square:6.2.0.20200812" +``` + +## API documentation + +### Payments +* [Payments] +* [Refunds] +* [Disputes] +* [Checkout] +* [Apple Pay] +* [Terminal] + +### Orders +* [Orders] + +### Subscriptions +* [Subscriptions] + +### Invoices +* [Invoices] + +### Items +* [Catalog] +* [Inventory] + +### Customers +* [Customers] +* [Customer Groups] +* [Customer Segments] + +### Loyalty +* [Loyalty] + +### Business +* [Merchants] +* [Locations] +* [Devices] + +### Team +* [Team] +* [Employees] +* [Labor] +* [Cash Drawers] + +### Financials +* [Bank Accounts] + +### Authorization APIs +* [Mobile Authorization] +* [O Auth] + +### Deprecated APIs +* [V1 Locations] +* [V1 Employees] +* [V1 Transactions] +* [V1 Items] +* [Transactions] +* [Reporting] + +## Usage + +First time using Square? Here’s how to get started: + +1. **Create a Square account.** If you don’t have one already, [sign up for a developer account]. +1. **Create an application.** Go to your [Developer Dashboard] and create your first application. All you need to do is give it a name. When you’re doing this for your production application, enter the name as you would want a customer to see it. +1. **Make your first API call.** Almost all Square API calls require a location ID. You’ll make your first call to `listLocations`, which happens to be one of the API calls that don’t require a location ID. For more information about locations, see the [Locations] API documentation. + +Now let’s call your first Square API. + +```java +import java.util.List; +import java.io.IOException; + +import com.squareup.square.Environment; +import com.squareup.square.SquareClient; +import com.squareup.square.exceptions.ApiException; +import com.squareup.square.http.client.HttpContext; +import com.squareup.square.api.LocationsApi; +import com.squareup.square.models.Location; +import com.squareup.square.models.Error; + +public class Example { + public static void main(String[] args) { + SquareClient client = new SquareClient.Builder() + .environment(Environment.SANDBOX) + .accessToken("YOUR_SANDBOX_ACCESS_TOKEN") + .build(); + + LocationsApi api = client.getLocationsApi(); + + try { + List locations = api.listLocations().getLocations(); + // Your business logic code + System.out.println("calling listLocations successfully"); + } catch (ApiException e) { + List errors = e.getErrors(); + int statusCode = e.getResponseCode(); + HttpContext httpContext = e.getHttpContext(); + + // Your error handling code + System.err.println("ApiException when calling API"); + e.printStackTrace(); + } + catch (IOException e) { + // Your error handling code + System.err.println("IOException when calling API"); + e.printStackTrace(); + } + } +} +``` + +Next, get an access token and reference it in your code: + +1. Open the Developer Dashboard and select your application. The **Credentials** page for your app opens by default. +1. Set the dashboard mode to **Sandbox Settings** for a sandbox access token. +1. Copy the Access Token in the Credentials section of the page and replace `YOUR_SANDBOX_ACCESS_TOKEN` with the token. + +**Important** When you eventually switch from trying things out on sandbox to actually working with your real production resources, you should not embed the access token in your code. Make sure you store and access your production access tokens securely. + +## SDK patterns +If you know a few patterns, you’ll be able to call any API in the SDK. Here are some important ones: + +### Get an access token + +To use the Square API to manage the resources of a Square account (payments, orders, customers, etc.), you need to create an application (or use an existing one) in the Developer Dashboard and get an access token. Access tokens have specific permissions to resources in a specific Square account that can be accessed by a specific application in a specific developer account. +Use an access token that is appropriate for your use case. There are two options: + +- To manage the resources for your own Square account, use the **Personal Access Token** for the application created in your Square account. +- To manage resources for other Square accounts, use OAuth to ask owners of the accounts you want to manage so that you can work on their behalf. When you implement OAuth, you ask the Square account holder for permission to manage resources in their account and get an OAuth access token and refresh token for their account. You define the specific resources you want to access as part of the OAuth call. + +**Important** For both use cases, make sure you store and access the tokens securely. + +### Import and Instantiate the Client Class + +To use the Square API, you import the Client class, instantiate a Client object, and initialize it with the appropriate access token. Here’s how: + +- Initialize the `SquareClient` with environment set to sandbox: + +```java +SquareClient client = new SquareClient.Builder() + .environment(Environment.SANDBOX) + .accessToken("SANDBOX ACCESS TOKEN HERE") + .build(); +``` + +- To access production resources, set environment to production: + +```java +SquareClient client = new SquareClient.Builder() + .environment(Environment.PRODUCTION) + .accessToken("ACCESS TOKEN HERE") + .build(); +``` + +### Get an Instance of an API object and call its methods + +Each API is implemented as a class. The Client object instantiates every API class and exposes them as properties so you can easily start using any Square API. You work with an API by calling methods on an instance of an API class. Here’s how: + +- Work with an API by calling the methods on the API object. For example, you would call listCustomers to get a list of all customers in the Square account: + +```java +CustomersApi api = client.getCustomersApi(); +ListCustomersResponse listCustomersRes = api.listCustomers(null, null, null); +``` + +See the SDK documentation for the list of methods for each API class. + +- Pass complex parameters such as create, update, or search as a model. For example, you would pass a model containing the values used to create a new customer using create_customer: + +```java +CustomersApi api = client.getCustomersApi(); + +Address address = new Address.Builder() + .addressLine1("1455 Market St") + .addressLine2("San Francisco, CA 94103") + .build(); + +// Create a unique key(idempotency) for this creation operation so you don't accidentally +// create the customer multiple times if you need to retry this operation. +// For the purpose of example, we mark it as `unique_idempotency_key` +CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest.Builder() + .idempotencyKey("unique_idempotency_key") + .givenName("John") + .familyName("Smith") + .address(address) + .build(); + +// Call createCustomer method to create a new customer in this Square account +try { + CreateCustomerResponse response = api.createCustomer(createCustomerRequest); +} catch (ApiException e) { + List errors = e.getErrors(); + int statusCode = e.getResponseCode(); + HttpContext httpContext = e.getHttpContext(); + + // Your error handling code + System.err.println("ApiException when calling API"); + e.printStackTrace(); +} + +``` + +- Use idempotency for create, update, or other calls that you want to avoid calling twice. To make an idempotent API call, you add the idempotency_key with a unique value in the Hash for the API call’s request. +- Specify a location ID for APIs such as Transactions, Orders, and Checkout that deal with payments. When a payment or order is created in Square, it is always associated with a location. + +### Handle the response + +If your API call succeeds, Square API returns a response object containing an `HttpContext` that describe both the request and the response. Otherwise, the API throws an `ApiException`: + +```java +try { + List locations = api.listLocations().getLocations(); +} catch (ApiException e) { + List errors = e.getErrors(); + int statusCode = e.getResponseCode(); + HttpContext httpContext = e.getHttpContext(); + + // Your error handling code + System.err.println("ApiException when calling API"); + e.printStackTrace(); +} +``` + +## Tests + +First, clone the repo locally and `cd` into the directory. + +```sh +git clone https://github.com/square/square-java-sdk.git +cd square-java-sdk +``` + +Before running the tests, find a sandbox token in your [Developer Dashboard] and set a `SQUARE_ACCESS_TOKEN` environment variable. + +```sh +export SQUARE_ENVIRONMENT=sandbox +export SQUARE_ACCESS_TOKEN="YOUR_SANDBOX_ACCESS_TOKEN" +``` + +If you are using Maven, run the tests with below command + +```sh +mvn test +``` + +## Learn more + +The Square Platform is built on the [Square API]. Square has a number of other SDKs that enable you to securely handle credit card information on both mobile and web so that you can process payments via the Square API. + +You can also use the Square API to create applications or services that work with payments, orders, inventory, etc. that have been created and managed in Square’s in-person hardware products (Square Point of Sale and Square Register). + + +[//]: # "Link anchor definitions" +[Square Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg +[Developer Dashboard]: https://developer.squareup.com/apps +[Square API]: https://squareup.com/developers +[sign up for a developer account]: https://squareup.com/signup?v=developers +[Client]: doc/client.md +[Devices]: doc/devices.md +[Disputes]: doc/disputes.md +[Terminal]: doc/terminal.md +[Cash Drawers]: doc/cash-drawers.md +[Customer Groups]: doc/customer-groups.md +[Customer Segments]: doc/customer-segments.md +[Bank Accounts]: doc/bank-accounts +[Payments]: doc/payments.md +[Checkout]: doc/checkout.md +[Catalog]: doc/catalog.md +[Customers]: doc/customers.md +[Employees]: doc/employees.md +[Inventory]: doc/inventory.md +[Labor]: doc/labor.md +[Loyalty]: doc/loyalty.md +[Locations]: doc/locations.md +[Merchants]: doc/merchants.md +[Orders]: doc/orders.md +[Invoices]: doc/invoices.md +[Apple Pay]: doc/apple-pay.md +[Refunds]: doc/refunds.md +[Reporting]: doc/reporting.md +[Mobile Authorization]: doc/mobile-authorization.md +[O Auth]: doc/o-auth.md +[V1 Locations]: doc/v1-locations.md +[V1 Employees]: doc/v1-employees.md +[V1 Transactions]: doc/v1-transactions.md +[V1 Items]: doc/v1-items.md +[Team]: doc/team.md +[Transactions]: doc/transactions.md +[Subscriptions]: doc/subscriptions.md \ No newline at end of file diff --git a/doc/models/action-cancel-reason.md b/doc/models/action-cancel-reason.md index 609fc866..7de7eae4 100644 --- a/doc/models/action-cancel-reason.md +++ b/doc/models/action-cancel-reason.md @@ -8,7 +8,7 @@ | Name | Description | | --- | --- | -| `BUYERCANCELED` | A person canceled the `TerminalCheckout` from a Square device. | -| `SELLERCANCELED` | A client canceled the `TerminalCheckout` using the API. | -| `TIMEDOUT` | The `TerminalCheckout` timed out (see `deadline_duration` on the `TerminalCheckout`). | +| `BUYER_CANCELED` | A person canceled the `TerminalCheckout` from a Square device. | +| `SELLER_CANCELED` | A client canceled the `TerminalCheckout` using the API. | +| `TIMED_OUT` | The `TerminalCheckout` timed out (see `deadline_duration` on the `TerminalCheckout`). | diff --git a/doc/models/bank-account-status.md b/doc/models/bank-account-status.md index 0352b352..72bf7b1a 100644 --- a/doc/models/bank-account-status.md +++ b/doc/models/bank-account-status.md @@ -10,7 +10,7 @@ Indicates the current verification status of a `BankAccount` object. | Name | Description | | --- | --- | -| `VERIFICATIONINPROGRESS` | Indicates that the verification process has started. Some features
(for example, creditable or debitable) may be provisionally enabled on the bank
account. | +| `VERIFICATION_IN_PROGRESS` | Indicates that the verification process has started. Some features
(for example, creditable or debitable) may be provisionally enabled on the bank
account. | | `VERIFIED` | Indicates that the bank account was successfully verified. | | `DISABLED` | Indicates that the bank account is disabled and is permanently unusable
for funds transfer. A bank account can be disabled because of a failed verification
attempt or a failed deposit attempt. | diff --git a/doc/models/bank-account-type.md b/doc/models/bank-account-type.md index 0ef8bab9..62027ea8 100644 --- a/doc/models/bank-account-type.md +++ b/doc/models/bank-account-type.md @@ -14,5 +14,5 @@ Indicates the financial purpose of the bank account. | `SAVINGS` | An account at a financial institution that pays interest but cannot be
used directly as money in the narrow sense of a medium of exchange. | | `INVESTMENT` | An account at a financial institution that contains a deposit of funds
and/or securities. | | `OTHER` | An account at a financial institution which cannot be described by the
other types. | -| `BUSINESSCHECKING` | An account at a financial institution against which checks can be
drawn specifically for business purposes (non-personal use). | +| `BUSINESS_CHECKING` | An account at a financial institution against which checks can be
drawn specifically for business purposes (non-personal use). | diff --git a/doc/models/cancel-subscription-response.md b/doc/models/cancel-subscription-response.md new file mode 100644 index 00000000..381ff58b --- /dev/null +++ b/doc/models/cancel-subscription-response.md @@ -0,0 +1,37 @@ +## Cancel Subscription Response + +Defines fields that are included in a +[CancelSubscription](#endpoint-subscriptions-cancelsubscription) response. + +### Structure + +`CancelSubscriptionResponse` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Errors` | [`List`](/doc/models/error.md) | Optional | Information about errors encountered during the request. | +| `Subscription` | [`Subscription`](/doc/models/subscription.md) | Optional | Represents a customer subscription to a subscription plan.
For an overview of the `Subscription` type, see
[Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). | + +### Example (as JSON) + +```json +{ + "subscription": { + "id": "910afd30-464a-4e00-a8d8-2296eEXAMPLE", + "location_id": "S8GWD5R9QB376", + "plan_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "card_id": "ccof:qy5x8hHGYsgLrp4Q4GB", + "start_date": "2020-04-24", + "canceled_date": "2020-05-01", + "paid_until_date": "2020-05-01", + "status": "ACTIVE", + "created_at": "2020-08-03T21:53:10Z", + "version": 1594311617331, + "timezone": "America/Los_Angeles" + } +} +``` + diff --git a/doc/models/card-brand.md b/doc/models/card-brand.md index 4448ac05..d43a6b36 100644 --- a/doc/models/card-brand.md +++ b/doc/models/card-brand.md @@ -10,16 +10,16 @@ Indicates a card's brand, such as `VISA` or `MASTERCARD`. | Name | | --- | -| `OTHERBRAND` | +| `OTHER_BRAND` | | `VISA` | | `MASTERCARD` | -| `AMERICANEXPRESS` | +| `AMERICAN_EXPRESS` | | `DISCOVER` | -| `DISCOVERDINERS` | +| `DISCOVER_DINERS` | | `JCB` | -| `CHINAUNIONPAY` | -| `SQUAREGIFTCARD` | -| `SQUARECAPITALCARD` | +| `CHINA_UNIONPAY` | +| `SQUARE_GIFT_CARD` | +| `SQUARE_CAPITAL_CARD` | | `INTERAC` | | `EFTPOS` | | `FELICA` | diff --git a/doc/models/card-prepaid-type.md b/doc/models/card-prepaid-type.md index d2b80d3b..f000a38c 100644 --- a/doc/models/card-prepaid-type.md +++ b/doc/models/card-prepaid-type.md @@ -10,7 +10,7 @@ Indicates a card's prepaid type, such as `NOT_PREPAID` or `PREPAID`. | Name | | --- | -| `UNKNOWNPREPAIDTYPE` | -| `NOTPREPAID` | +| `UNKNOWN_PREPAID_TYPE` | +| `NOT_PREPAID` | | `PREPAID` | diff --git a/doc/models/card-type.md b/doc/models/card-type.md index 084e2a67..e320fb3d 100644 --- a/doc/models/card-type.md +++ b/doc/models/card-type.md @@ -10,7 +10,7 @@ Indicates a card's type, such as `CREDIT` or `DEBIT`. | Name | | --- | -| `UNKNOWNCARDTYPE` | +| `UNKNOWN_CARD_TYPE` | | `CREDIT` | | `DEBIT` | diff --git a/doc/models/cash-drawer-event-type.md b/doc/models/cash-drawer-event-type.md index 58188aee..f0f9f506 100644 --- a/doc/models/cash-drawer-event-type.md +++ b/doc/models/cash-drawer-event-type.md @@ -12,13 +12,13 @@ represented by a CashDrawerShift. | Name | Description | | --- | --- | -| `NOSALE` | Triggered when a no sale occurs on a cash drawer.
A CashDrawerEvent of this type must have a zero money amount. | -| `CASHTENDERPAYMENT` | Triggered when a cash tender payment occurs on a cash drawer.
A CashDrawerEvent of this type can must not have a negative amount. | -| `OTHERTENDERPAYMENT` | Triggered when a check, gift card, or other non-cash payment occurs
on a cash drawer.
A CashDrawerEvent of this type must have a zero money amount. | -| `CASHTENDERCANCELLEDPAYMENT` | Triggered when a split tender bill is cancelled after cash has been
tendered.
A CASH_TENDER_CANCELLED_PAYMENT should have a corresponding CASH_TENDER_PAYMENT.
A CashDrawerEvent of this type must not have a negative amount. | -| `OTHERTENDERCANCELLEDPAYMENT` | Triggered when a split tender bill is cancelled after a non-cash tender
has been tendered. An OTHER_TENDER_CANCELLED_PAYMENT should have a corresponding
OTHER_TENDER_PAYMENT. A CashDrawerEvent of this type must have a zero money
amount. | -| `CASHTENDERREFUND` | Triggered when a cash tender refund occurs.
A CashDrawerEvent of this type must not have a negative amount. | -| `OTHERTENDERREFUND` | Triggered when an other tender refund occurs.
A CashDrawerEvent of this type must have a zero money amount. | -| `PAIDIN` | Triggered when money unrelated to a payment is added to the cash drawer.
For example, an employee adds coins to the drawer.
A CashDrawerEvent of this type must not have a negative amount. | -| `PAIDOUT` | Triggered when money is removed from the drawer for other reasons
than making change.
For example, an employee pays a delivery person with cash from the cash drawer.
A CashDrawerEvent of this type must not have a negative amount. | +| `NO_SALE` | Triggered when a no sale occurs on a cash drawer.
A CashDrawerEvent of this type must have a zero money amount. | +| `CASH_TENDER_PAYMENT` | Triggered when a cash tender payment occurs on a cash drawer.
A CashDrawerEvent of this type can must not have a negative amount. | +| `OTHER_TENDER_PAYMENT` | Triggered when a check, gift card, or other non-cash payment occurs
on a cash drawer.
A CashDrawerEvent of this type must have a zero money amount. | +| `CASH_TENDER_CANCELLED_PAYMENT` | Triggered when a split tender bill is cancelled after cash has been
tendered.
A CASH_TENDER_CANCELLED_PAYMENT should have a corresponding CASH_TENDER_PAYMENT.
A CashDrawerEvent of this type must not have a negative amount. | +| `OTHER_TENDER_CANCELLED_PAYMENT` | Triggered when a split tender bill is cancelled after a non-cash tender
has been tendered. An OTHER_TENDER_CANCELLED_PAYMENT should have a corresponding
OTHER_TENDER_PAYMENT. A CashDrawerEvent of this type must have a zero money
amount. | +| `CASH_TENDER_REFUND` | Triggered when a cash tender refund occurs.
A CashDrawerEvent of this type must not have a negative amount. | +| `OTHER_TENDER_REFUND` | Triggered when an other tender refund occurs.
A CashDrawerEvent of this type must have a zero money amount. | +| `PAID_IN` | Triggered when money unrelated to a payment is added to the cash drawer.
For example, an employee adds coins to the drawer.
A CashDrawerEvent of this type must not have a negative amount. | +| `PAID_OUT` | Triggered when money is removed from the drawer for other reasons
than making change.
For example, an employee pays a delivery person with cash from the cash drawer.
A CashDrawerEvent of this type must not have a negative amount. | diff --git a/doc/models/catalog-custom-attribute-definition-app-visibility.md b/doc/models/catalog-custom-attribute-definition-app-visibility.md index d49adc20..3303da21 100644 --- a/doc/models/catalog-custom-attribute-definition-app-visibility.md +++ b/doc/models/catalog-custom-attribute-definition-app-visibility.md @@ -11,7 +11,7 @@ creating application. | Name | Description | | --- | --- | -| `APPVISIBILITYHIDDEN` | Other applications cannot read this custom attribute. | -| `APPVISIBILITYREADONLY` | Other applications can read this custom attribute definition and
values. | -| `APPVISIBILITYREADWRITEVALUES` | Other applications can read and write custom attribute values on objects.
They can read but cannot edit the custom attribute definition. | +| `APP_VISIBILITY_HIDDEN` | Other applications cannot read this custom attribute. | +| `APP_VISIBILITY_READ_ONLY` | Other applications can read this custom attribute definition and
values. | +| `APP_VISIBILITY_READ_WRITE_VALUES` | Other applications can read and write custom attribute values on objects.
They can read but cannot edit the custom attribute definition. | diff --git a/doc/models/catalog-custom-attribute-definition-seller-visibility.md b/doc/models/catalog-custom-attribute-definition-seller-visibility.md index 0790c9b3..a5a7d940 100644 --- a/doc/models/catalog-custom-attribute-definition-seller-visibility.md +++ b/doc/models/catalog-custom-attribute-definition-seller-visibility.md @@ -12,6 +12,6 @@ of Sale applications and Square Dashboard). | Name | Description | | --- | --- | -| `SELLERVISIBILITYHIDDEN` | Sellers cannot read this custom attribute in Square client
applications or Square APIs. | -| `SELLERVISIBILITYREADWRITEVALUES` | Sellers can read and write this custom attribute value in catalog objects,
but cannot edit the custom attribute definition. | +| `SELLER_VISIBILITY_HIDDEN` | Sellers cannot read this custom attribute in Square client
applications or Square APIs. | +| `SELLER_VISIBILITY_READ_WRITE_VALUES` | Sellers can read and write this custom attribute value in catalog objects,
but cannot edit the custom attribute definition. | diff --git a/doc/models/catalog-custom-attribute-definition.md b/doc/models/catalog-custom-attribute-definition.md index 7a2af894..83e3af3d 100644 --- a/doc/models/catalog-custom-attribute-definition.md +++ b/doc/models/catalog-custom-attribute-definition.md @@ -36,9 +36,9 @@ to store any sensitive information (personally identifiable information, card de "description": null, "source_application": null, "allowed_object_types": [ - "TIME_PERIOD", - "MEASUREMENT_UNIT", - "ITEM_OPTION" + "PRICING_RULE", + "PRODUCT_SET", + "TIME_PERIOD" ], "seller_visibility": null, "app_visibility": null, diff --git a/doc/models/catalog-discount-modify-tax-basis.md b/doc/models/catalog-discount-modify-tax-basis.md index 588d9317..6fd1b7f4 100644 --- a/doc/models/catalog-discount-modify-tax-basis.md +++ b/doc/models/catalog-discount-modify-tax-basis.md @@ -8,6 +8,6 @@ | Name | Description | | --- | --- | -| `MODIFYTAXBASIS` | Application of the discount will modify the tax basis. | -| `DONOTMODIFYTAXBASIS` | Application of the discount will not modify the tax basis. | +| `MODIFY_TAX_BASIS` | Application of the discount will modify the tax basis. | +| `DO_NOT_MODIFY_TAX_BASIS` | Application of the discount will not modify the tax basis. | diff --git a/doc/models/catalog-discount-type.md b/doc/models/catalog-discount-type.md index 350a7b6d..6842dc9a 100644 --- a/doc/models/catalog-discount-type.md +++ b/doc/models/catalog-discount-type.md @@ -10,8 +10,8 @@ How to apply a CatalogDiscount to a CatalogItem. | Name | Description | | --- | --- | -| `FIXEDPERCENTAGE` | Apply the discount as a fixed percentage (e.g., 5%) off the item price. | -| `FIXEDAMOUNT` | Apply the discount as a fixed amount (e.g., $1.00) off the item price. | -| `VARIABLEPERCENTAGE` | Apply the discount as a variable percentage off the item price. The percentage will be specified at the time of sale. | -| `VARIABLEAMOUNT` | Apply the discount as a variable amount off the item price. The amount will be specified at the time of sale. | +| `FIXED_PERCENTAGE` | Apply the discount as a fixed percentage (e.g., 5%) off the item price. | +| `FIXED_AMOUNT` | Apply the discount as a fixed amount (e.g., $1.00) off the item price. | +| `VARIABLE_PERCENTAGE` | Apply the discount as a variable percentage off the item price. The percentage will be specified at the time of sale. | +| `VARIABLE_AMOUNT` | Apply the discount as a variable amount off the item price. The amount will be specified at the time of sale. | diff --git a/doc/models/catalog-item-product-type.md b/doc/models/catalog-item-product-type.md index e2406994..46999a4a 100644 --- a/doc/models/catalog-item-product-type.md +++ b/doc/models/catalog-item-product-type.md @@ -11,6 +11,6 @@ The type of a CatalogItem. Connect V2 only allows the creation of `REGULAR` or ` | Name | Description | | --- | --- | | `REGULAR` | An ordinary item. | -| `GIFTCARD` | A Square gift card. | -| `APPOINTMENTSSERVICE` | A service that can be booked using the Square Appointments app. | +| `GIFT_CARD` | A Square gift card. | +| `APPOINTMENTS_SERVICE` | A service that can be booked using the Square Appointments app. | diff --git a/doc/models/catalog-object-batch.md b/doc/models/catalog-object-batch.md index b8489cf6..e0bf89e4 100644 --- a/doc/models/catalog-object-batch.md +++ b/doc/models/catalog-object-batch.md @@ -18,7 +18,7 @@ A batch of catalog objects. { "objects": [ { - "type": "MODIFIER_LIST", + "type": "ITEM_OPTION_VAL", "id": "id8", "updated_at": null, "version": null, @@ -41,13 +41,14 @@ A batch of catalog objects. "pricing_rule_data": null, "image_data": null, "measurement_unit_data": null, + "subscription_plan_data": null, "item_option_data": null, "item_option_value_data": null, "custom_attribute_definition_data": null, "quick_amounts_settings_data": null }, { - "type": "DISCOUNT", + "type": "ITEM_OPTION", "id": "id9", "updated_at": null, "version": null, @@ -70,6 +71,7 @@ A batch of catalog objects. "pricing_rule_data": null, "image_data": null, "measurement_unit_data": null, + "subscription_plan_data": null, "item_option_data": null, "item_option_value_data": null, "custom_attribute_definition_data": null, diff --git a/doc/models/catalog-object-type.md b/doc/models/catalog-object-type.md index d0dcd9f7..69aec8f5 100644 --- a/doc/models/catalog-object-type.md +++ b/doc/models/catalog-object-type.md @@ -14,17 +14,18 @@ containing type-specific properties in the `*_data` field corresponding to the o | `ITEM` | An item, corresponding to `CatalogItem`. The item-specific data
will be stored in the `item_data` field. | | `IMAGE` | An image, corresponding to `CatalogImage`. The image-specific data
will be stored in the `image_data` field. | | `CATEGORY` | A category, corresponding to `CatalogCategory`. The category-specific data
will be stored in the `category_data` field. | -| `ITEMVARIATION` | An item variation, corresponding to `CatalogItemVariation`. The
item variation-specific data will be stored in the `item_variation_data` field. | +| `ITEM_VARIATION` | An item variation, corresponding to `CatalogItemVariation`. The
item variation-specific data will be stored in the `item_variation_data` field. | | `TAX` | A tax, corresponding to `CatalogTax`. The tax-specific data
will be stored in the `tax_data` field. | | `DISCOUNT` | A discount, corresponding to `CatalogDiscount`. The discount-specific data
will be stored in the `discount_data` field. | -| `MODIFIERLIST` | A modifier list, corresponding to `CatalogModifierList`.
The modifier list-specific data will be stored in the `modifier_list_data` field. | +| `MODIFIER_LIST` | A modifier list, corresponding to `CatalogModifierList`.
The modifier list-specific data will be stored in the `modifier_list_data` field. | | `MODIFIER` | A modifier, corresponding to `CatalogModifier`. The modifier-specific data
will be stored in the `modifier_data` field. | -| `PRICINGRULE` | A pricing rule, corresponding to `CatalogPricingRule`. The pricing-rule-specific data
will be stored in the `pricing_rule_data` field. | -| `PRODUCTSET` | A product set, corresponding to `CatalogProductSet`.
The product-set-specific data will be stored in the `product_set_data` field. | -| `TIMEPERIOD` | A time period, corresponding to `CatalogTimePeriod`.
The time-period-specific data will be stored in the `time_period_data` field. | -| `MEASUREMENTUNIT` | A measurement unit, corresponding to `CatalogMeasurementUnit`. The unit of
measure and precision in which an item variation should be sold. | -| `ITEMOPTION` | Represents a list of item option values that can be assigned to item
variations. For example, a color option or size option for a t-shirt. | -| `ITEMOPTIONVAL` | Represents an option value associated with one or more item options.
For example, an item option of "Size" may have item option values such as
“Small" or "Medium". | -| `CUSTOMATTRIBUTEDEFINITION` | Represents the definition of a custom attribute | -| `QUICKAMOUNTSSETTINGS` | Represents a set of Quick Amounts and their settings at each location.
For example, a location may have a list of both AUTO and MANUAL quick amounts that are set to DISABLED. | +| `PRICING_RULE` | A pricing rule, corresponding to `CatalogPricingRule`. The pricing-rule-specific data
will be stored in the `pricing_rule_data` field. | +| `PRODUCT_SET` | A product set, corresponding to `CatalogProductSet`.
The product-set-specific data will be stored in the `product_set_data` field. | +| `TIME_PERIOD` | A time period, corresponding to `CatalogTimePeriod`.
The time-period-specific data will be stored in the `time_period_data` field. | +| `MEASUREMENT_UNIT` | A measurement unit, corresponding to `CatalogMeasurementUnit`. The unit of
measure and precision in which an item variation should be sold. | +| `SUBSCRIPTION_PLAN` | A subscription plan, corresponding to
[CatalogSubscriptionPlan](#type-CatalogSubscriptionPlan).

The subscription plan data is stored in the `subscription_plan_data` field of the
[CatalogObject](#type-CatalogObject). | +| `ITEM_OPTION` | Represents a list of item option values that can be assigned to item
variations. For example, a color option or size option for a t-shirt. | +| `ITEM_OPTION_VAL` | Represents an option value associated with one or more item options.
For example, an item option of "Size" may have item option values such as
“Small" or "Medium". | +| `CUSTOM_ATTRIBUTE_DEFINITION` | Represents the definition of a custom attribute | +| `QUICK_AMOUNTS_SETTINGS` | Represents a set of Quick Amounts and their settings at each location.
For example, a location may have a list of both AUTO and MANUAL quick amounts that are set to DISABLED. | diff --git a/doc/models/catalog-object.md b/doc/models/catalog-object.md index 5793525d..29cd2a19 100644 --- a/doc/models/catalog-object.md +++ b/doc/models/catalog-object.md @@ -18,6 +18,8 @@ their corresponding data atrribute that can be set: - For a `CatalogObject` of the `PRICING_RULE` type, set the `pricing_rule_data` attribute to yield the `CatalogPricingRule` object. - For a `CatalogObject` of the `TIME_PERIOD` type, set the `time_period_data` attribute to yield the `CatalogTimePeriod` object. - For a `CatalogObject` of the `PRODUCT_SET` type, set the `product_set_data` attribute to yield the `CatalogProductSet` object. +- For a `CatalogObject` of the `SUBSCRIPTION_PLAN` type, set the `subscription_plan_data` attribute to yield the `CatalogSubscriptionPlan` object. + For a more detailed discussion of the Catalog data model, please see the [Design a Catalog](https://developer.squareup.com/docs/catalog-api/design-a-catalog) guide. @@ -53,6 +55,7 @@ For a more detailed discussion of the Catalog data model, please see the | `PricingRuleData` | [`CatalogPricingRule`](/doc/models/catalog-pricing-rule.md) | Optional | Defines how discounts are automatically applied to a set of items that match the pricing rule
during the active time period. | | `ImageData` | [`CatalogImage`](/doc/models/catalog-image.md) | Optional | An image file to use in Square catalogs. It can be associated with catalog
items, item variations, and categories. | | `MeasurementUnitData` | [`CatalogMeasurementUnit`](/doc/models/catalog-measurement-unit.md) | Optional | Represents the unit used to measure a `CatalogItemVariation` and
specifies the precision for decimal quantities. | +| `SubscriptionPlanData` | [`CatalogSubscriptionPlan`](/doc/models/catalog-subscription-plan.md) | Optional | Describes a subscription plan. For more information, see
[Set Up and Manage a Subscription Plan](https://developer.squareup.com/docs/docs/subscriptions-api/setup-plan). | | `ItemOptionData` | [`CatalogItemOption`](/doc/models/catalog-item-option.md) | Optional | A group of variations for a `CatalogItem`. | | `ItemOptionValueData` | [`CatalogItemOptionValue`](/doc/models/catalog-item-option-value.md) | Optional | An enumerated value that can link a
`CatalogItemVariation` to an item option as one of
its item option values. | | `CustomAttributeDefinitionData` | [`CatalogCustomAttributeDefinition`](/doc/models/catalog-custom-attribute-definition.md) | Optional | Contains information defining a custom attribute. Custom attributes are
intended to store additional information about a catalog object or to associate a
catalog object with an entity in another system. Do not use custom attributes
to store any sensitive information (personally identifiable information, card details, etc.).
[Read more about custom attributes](https://developer.squareup.com/docs/catalog-api/add-custom-attributes) | @@ -62,7 +65,7 @@ For a more detailed discussion of the Catalog data model, please see the ```json { - "type": "CUSTOM_ATTRIBUTE_DEFINITION", + "type": "ITEM_VARIATION", "id": "id0", "updated_at": null, "version": null, @@ -85,6 +88,7 @@ For a more detailed discussion of the Catalog data model, please see the "pricing_rule_data": null, "image_data": null, "measurement_unit_data": null, + "subscription_plan_data": null, "item_option_data": null, "item_option_value_data": null, "custom_attribute_definition_data": null, diff --git a/doc/models/catalog-pricing-type.md b/doc/models/catalog-pricing-type.md index f184ece2..6b8b1e2b 100644 --- a/doc/models/catalog-pricing-type.md +++ b/doc/models/catalog-pricing-type.md @@ -10,6 +10,6 @@ Indicates whether the price of a CatalogItemVariation should be entered manually | Name | Description | | --- | --- | -| `FIXEDPRICING` | The catalog item variation's price is fixed. | -| `VARIABLEPRICING` | The catalog item variation's price is entered at the time of sale. | +| `FIXED_PRICING` | The catalog item variation's price is fixed. | +| `VARIABLE_PRICING` | The catalog item variation's price is entered at the time of sale. | diff --git a/doc/models/catalog-quick-amount-type.md b/doc/models/catalog-quick-amount-type.md index 39759d04..301512f1 100644 --- a/doc/models/catalog-quick-amount-type.md +++ b/doc/models/catalog-quick-amount-type.md @@ -10,6 +10,6 @@ Determines the type of a specific Quick Amount. | Name | Description | | --- | --- | -| `QUICKAMOUNTTYPEMANUAL` | Quick Amount is created manually by the seller. | -| `QUICKAMOUNTTYPEAUTO` | Quick Amount is generated automatically by machine learning algorithms. | +| `QUICK_AMOUNT_TYPE_MANUAL` | Quick Amount is created manually by the seller. | +| `QUICK_AMOUNT_TYPE_AUTO` | Quick Amount is generated automatically by machine learning algorithms. | diff --git a/doc/models/catalog-subscription-plan.md b/doc/models/catalog-subscription-plan.md new file mode 100644 index 00000000..3ca1c1b9 --- /dev/null +++ b/doc/models/catalog-subscription-plan.md @@ -0,0 +1,25 @@ +## Catalog Subscription Plan + +Describes a subscription plan. For more information, see +[Set Up and Manage a Subscription Plan](https://developer.squareup.com/docs/docs/subscriptions-api/setup-plan). + +### Structure + +`CatalogSubscriptionPlan` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Name` | `String` | Optional | The name of the plan. | +| `Phases` | [`List`](/doc/models/subscription-phase.md) | Optional | A list of SubscriptionPhase containing the [SubscriptionPhase](#type-SubscriptionPhase) for this plan. | + +### Example (as JSON) + +```json +{ + "name": null, + "phases": null +} +``` + diff --git a/doc/models/create-customer-request.md b/doc/models/create-customer-request.md index 8fbbcd8d..9e958c67 100644 --- a/doc/models/create-customer-request.md +++ b/doc/models/create-customer-request.md @@ -11,7 +11,7 @@ CreateCustomer endpoint. | Name | Type | Tags | Description | | --- | --- | --- | --- | -| `IdempotencyKey` | `String` | Optional | The idempotency key for the request. See the
[Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency) guide for more information. | +| `IdempotencyKey` | `String` | Optional | The idempotency key for the request. See the
[Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency) guide for more information. | | `GivenName` | `String` | Optional | The given (i.e., first) name associated with the customer profile. | | `FamilyName` | `String` | Optional | The family (i.e., last) name associated with the customer profile. | | `CompanyName` | `String` | Optional | A business name associated with the customer profile. | diff --git a/doc/models/create-subscription-request.md b/doc/models/create-subscription-request.md new file mode 100644 index 00000000..96c7d49d --- /dev/null +++ b/doc/models/create-subscription-request.md @@ -0,0 +1,43 @@ +## Create Subscription Request + +Defines parameters in a +[CreateSubscription](#endpoint-subscriptions-createsubscription) endpoint request. + +### Structure + +`CreateSubscriptionRequest` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `IdempotencyKey` | `String` | | A unique string that identifies this `CreateSubscription` request.
If you do not provide a unique string (or provide an empty string as the value),
the endpoint treats each request as independent.

For more information, see [Idempotency keys](https://developer.squareup.com/docs/docs/working-with-apis/idempotency). | +| `LocationId` | `String` | | The ID of the location the subscription is associated with. | +| `PlanId` | `String` | | The ID of the subscription plan. For more information, see
[Subscription Plan Overview](https://developer.squareup.com/docs/docs/subscriptions/overview). | +| `CustomerId` | `String` | | The ID of the [customer](#type-customer) profile. | +| `StartDate` | `String` | Optional | The start date of the subscription, in YYYY-MM-DD format. For example,
2013-01-15. If the start date is left empty, the subscription begins
immediately. | +| `CanceledDate` | `String` | Optional | The date when the subscription should be canceled, in
YYYY-MM-DD format (for example, 2025-02-29). This overrides the plan configuration
if it comes before the date the subscription would otherwise end. | +| `TaxPercentage` | `String` | Optional | The tax to add when billing the subscription.
The percentage is expressed in decimal form, using a `'.'` as the decimal
separator and without a `'%'` sign. For example, a value of 7.5
corresponds to 7.5%. | +| `PriceOverrideMoney` | [`Money`](/doc/models/money.md) | Optional | Represents an amount of money. `Money` fields can be signed or unsigned.
Fields that do not explicitly define whether they are signed or unsigned are
considered unsigned and can only hold positive amounts. For signed fields, the
sign of the value indicates the purpose of the money transfer. See
[Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts)
for more information. | +| `CardId` | `String` | Optional | The ID of the [customer](#type-customer) [card](#type-card) to charge.
If not specified, Square sends an invoice via email. For an example to
create a customer and add a card on file, see [Subscriptions Walkthrough](https://developer.squareup.com/docs/docs/subscriptions-api/walkthrough). | +| `Timezone` | `String` | Optional | The timezone that is used in date calculations for the subscription. If unset, defaults to
the location timezone. If a timezone is not configured for the location, defaults to "America/New_York".
Format: the IANA Timezone Database identifier for the location timezone. For
a list of time zones, see [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | + +### Example (as JSON) + +```json +{ + "idempotency_key": "8193148c-9586-11e6-99f9-28cfe92138cf", + "location_id": "S8GWD5R9QB376", + "plan_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "card_id": "ccof:qy5x8hHGYsgLrp4Q4GB", + "start_date": "2020-08-01", + "tax_percentage": "5", + "price_override_money": { + "amount": 100, + "currency": "USD" + }, + "timezone": "America/Los_Angeles" +} +``` + diff --git a/doc/models/create-subscription-response.md b/doc/models/create-subscription-response.md new file mode 100644 index 00000000..0e82fc22 --- /dev/null +++ b/doc/models/create-subscription-response.md @@ -0,0 +1,40 @@ +## Create Subscription Response + +Defines the fields that are included in the response from the +[CreateSubscription](#endpoint-subscriptions-createsubscription) endpoint. + +### Structure + +`CreateSubscriptionResponse` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Errors` | [`List`](/doc/models/error.md) | Optional | Information about errors encountered during the request. | +| `Subscription` | [`Subscription`](/doc/models/subscription.md) | Optional | Represents a customer subscription to a subscription plan.
For an overview of the `Subscription` type, see
[Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). | + +### Example (as JSON) + +```json +{ + "subscription": { + "id": "56214fb2-cc85-47a1-93bc-44f3766bb56f", + "location_id": "S8GWD5R9QB376", + "plan_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2020-08-01", + "status": "PENDING", + "tax_percentage": "5", + "price_override_money": { + "amount": 100, + "currency": "USD" + }, + "version": 1594155459464, + "created_at": "2020-08-03T21:53:10Z", + "card_id": "ccof:qy5x8hHGYsgLrp4Q4GB", + "timezone": "America/Los_Angeles" + } +} +``` + diff --git a/doc/models/currency.md b/doc/models/currency.md index 2297b599..f6719ab5 100644 --- a/doc/models/currency.md +++ b/doc/models/currency.md @@ -11,7 +11,7 @@ to [ISO 4217](https://wikipedia.org/wiki/ISO_4217). | Name | Description | | --- | --- | -| `UNKNOWNCURRENCY` | Unknown currency | +| `UNKNOWN_CURRENCY` | Unknown currency | | `AED` | United Arab Emirates dirham | | `AFN` | Afghan afghani | | `ALL` | Albanian lek | diff --git a/doc/models/customer-creation-source.md b/doc/models/customer-creation-source.md index 6b453b94..0cda0ef1 100644 --- a/doc/models/customer-creation-source.md +++ b/doc/models/customer-creation-source.md @@ -13,20 +13,20 @@ Indicates the method used to create the customer profile. | `OTHER` | Default creation source. Typically used for backward/future
compatibility when the original source of a customer profile is
unrecognized. For example, when older clients do not support newer
source types. | | `APPOINTMENTS` | Customer profile created automatically when an appointment
was scheduled. | | `COUPON` | Customer profile created automatically when a coupon was issued
using Square Point of Sale. | -| `DELETIONRECOVERY` | Customer profile restored through Square's deletion recovery
process. | +| `DELETION_RECOVERY` | Customer profile restored through Square's deletion recovery
process. | | `DIRECTORY` | Customer profile created manually through Square Dashboard or
Point of Sale application. | | `EGIFTING` | Customer profile created automatically when a gift card was
issued using Square Point of Sale. Customer profiles are created for
both the purchaser and the recipient of the gift card. | -| `EMAILCOLLECTION` | Customer profile created through Square Point of Sale when
signing up for marketing emails during checkout. | +| `EMAIL_COLLECTION` | Customer profile created through Square Point of Sale when
signing up for marketing emails during checkout. | | `FEEDBACK` | Customer profile created automatically when providing feedback
through a digital receipt. | | `IMPORT` | Customer profile created automatically when importing customer
data through Square Dashboard. | | `INVOICES` | Customer profile created automatically during an invoice payment. | | `LOYALTY` | Customer profile created automatically when customers provide a
phone number for loyalty reward programs during checkout. | | `MARKETING` | Customer profile created as the result of a campaign managed
through Square’s Facebook integration. | | `MERGE` | Customer profile created as the result of explicitly merging
multiple customer profiles through the Square Dashboard or Point of
Sale application. | -| `ONLINESTORE` | Customer profile created through Square's Online Store solution
(legacy service). | -| `INSTANTPROFILE` | Customer profile created automatically as the result of a successful
transaction that did not explicitly link to an existing customer profile. | +| `ONLINE_STORE` | Customer profile created through Square's Online Store solution
(legacy service). | +| `INSTANT_PROFILE` | Customer profile created automatically as the result of a successful
transaction that did not explicitly link to an existing customer profile. | | `TERMINAL` | Customer profile created through Square's Virtual Terminal. | -| `THIRDPARTY` | Customer profile created through a Square API call. | -| `THIRDPARTYIMPORT` | Customer profile created by a third-party product and imported
through an official integration. | -| `UNMERGERECOVERY` | Customer profile restored through Square's unmerge recovery
process. | +| `THIRD_PARTY` | Customer profile created through a Square API call. | +| `THIRD_PARTY_IMPORT` | Customer profile created by a third-party product and imported
through an official integration. | +| `UNMERGE_RECOVERY` | Customer profile restored through Square's unmerge recovery
process. | diff --git a/doc/models/customer-sort-field.md b/doc/models/customer-sort-field.md index ca870b00..8ed9dfbb 100644 --- a/doc/models/customer-sort-field.md +++ b/doc/models/customer-sort-field.md @@ -11,5 +11,5 @@ Specifies customer attributes as the sort key to customer profiles returned from | Name | Description | | --- | --- | | `DEFAULT` | Use the default sort key. By default, customers are sorted
alphanumerically by concatenating their `given_name` and `family_name`. If
neither name field is set, string comparison is performed using one of the
remaining fields in the following order: `company_name`, `email`,
`phone_number`. | -| `CREATEDAT` | Use the creation date attribute (`created_at`) of customer profiles as the sort key. | +| `CREATED_AT` | Use the creation date attribute (`created_at`) of customer profiles as the sort key. | diff --git a/doc/models/dispute-evidence-type.md b/doc/models/dispute-evidence-type.md index 6023a922..156eb17c 100644 --- a/doc/models/dispute-evidence-type.md +++ b/doc/models/dispute-evidence-type.md @@ -10,19 +10,19 @@ Type of the dispute evidence. | Name | Description | | --- | --- | -| `GENERICEVIDENCE` | Square assumes this evidence type if you don't provide a type when uploading evidence.

Use when uploading evidence as: file or string | -| `ONLINEORAPPACCESSLOG` | Server or activity logs that show proof of the cardholder’s identity and that the cardholder successfully ordered and received the goods (digitally or otherwise).
Example evidence: IP addresses, corresponding timestamps/dates, cardholder’s name/email address linked to a cardholder profile held by Merchant, proof the same device and card (used in dispute) were previously used in prior undisputed transaction, any related detailed activity.

Use when uploading evidence as: file or string | -| `AUTHORIZATIONDOCUMENTATION` | Evidence that the cardholder did provide authorization of the charge.
Example evidence: a signed credit card authorization.

Use when uploading evidence as: file | -| `CANCELLATIONORREFUNDDOCUMENTATION` | Evidence that the cardholder acknowledged your refund or cancellation policy.
Example evidence: a signature or checkbox showing the cardholder’s acknowledgement of your refund or cancellation policy.

Use when uploading evidence as: file or string | -| `CARDHOLDERCOMMUNICATION` | Evidence that shows relevant communication with the cardholder.
Example evidence: emails or texts that show the cardholder received goods/services or demonstrate cardholder satisfaction.

Use when uploading evidence as: file | -| `CARDHOLDERINFORMATION` | Evidence that validates customer identity.
Example evidence: personally identifiable details such as name, email address, purchaser IP address, copy of cardholder ID.

Use when uploading evidence as: file or string | -| `PURCHASEACKNOWLEDGEMENT` | Evidence that shows proof of the sale/transaction.
Example evidence: an invoice, contract, etc. showing the customer’s acknowledgement of the purchase and your terms.

Use when uploading evidence as: file or string | -| `DUPLICATECHARGEDOCUMENTATION` | Evidence that shows the charge(s) in question are valid and distinct from one another.
Example evidence: receipts, shipping labels, and invoices along with their distinct payment IDs.

Use when uploading evidence as: file | -| `PRODUCTORSERVICEDESCRIPTION` | A description of the product or service sold.

Use when uploading evidence as: file or string | +| `GENERIC_EVIDENCE` | Square assumes this evidence type if you don't provide a type when uploading evidence.

Use when uploading evidence as: file or string | +| `ONLINE_OR_APP_ACCESS_LOG` | Server or activity logs that show proof of the cardholder’s identity and that the cardholder successfully ordered and received the goods (digitally or otherwise).
Example evidence: IP addresses, corresponding timestamps/dates, cardholder’s name/email address linked to a cardholder profile held by Merchant, proof the same device and card (used in dispute) were previously used in prior undisputed transaction, any related detailed activity.

Use when uploading evidence as: file or string | +| `AUTHORIZATION_DOCUMENTATION` | Evidence that the cardholder did provide authorization of the charge.
Example evidence: a signed credit card authorization.

Use when uploading evidence as: file | +| `CANCELLATION_OR_REFUND_DOCUMENTATION` | Evidence that the cardholder acknowledged your refund or cancellation policy.
Example evidence: a signature or checkbox showing the cardholder’s acknowledgement of your refund or cancellation policy.

Use when uploading evidence as: file or string | +| `CARDHOLDER_COMMUNICATION` | Evidence that shows relevant communication with the cardholder.
Example evidence: emails or texts that show the cardholder received goods/services or demonstrate cardholder satisfaction.

Use when uploading evidence as: file | +| `CARDHOLDER_INFORMATION` | Evidence that validates customer identity.
Example evidence: personally identifiable details such as name, email address, purchaser IP address, copy of cardholder ID.

Use when uploading evidence as: file or string | +| `PURCHASE_ACKNOWLEDGEMENT` | Evidence that shows proof of the sale/transaction.
Example evidence: an invoice, contract, etc. showing the customer’s acknowledgement of the purchase and your terms.

Use when uploading evidence as: file or string | +| `DUPLICATE_CHARGE_DOCUMENTATION` | Evidence that shows the charge(s) in question are valid and distinct from one another.
Example evidence: receipts, shipping labels, and invoices along with their distinct payment IDs.

Use when uploading evidence as: file | +| `PRODUCT_OR_SERVICE_DESCRIPTION` | A description of the product or service sold.

Use when uploading evidence as: file or string | | `RECEIPT` | A receipt or message sent to the cardholder detailing the charge.
Note: You don’t need to upload the Square receipt; Square submits the receipt on your behalf.

Use when uploading evidence as: file or string | -| `SERVICERECEIVEDDOCUMENTATION` | Evidence that the service was provided to the cardholder or the expected date that services will be rendered.
Example evidence: signed delivery form, work order, expected delivery date, or other written agreement.

Use when uploading evidence as: file or string | -| `PROOFOFDELIVERYDOCUMENTATION` | Evidence that shows the product was provided to the cardholder or the expected date of delivery.
Example evidence: signed delivery form, or written agreement acknowledging receipt of goods or services.

Use when uploading evidence as: file or string | -| `RELATEDTRANSACTIONDOCUMENTATION` | Evidence that shows the cardholder previously processed transactions on the same card and did not dispute them.
Note: Square will automatically provide up to 5 distinct Square receipts for related transactions, when available.

Use when uploading evidence as: file or string | -| `REBUTTALEXPLANATION` | An explanation of why the cardholder’s claim is invalid.
Example evidence: explanation of why each distinct charge is a legitimate purchase why the cardholder’s claim for credit owed due to their attempt to cancel, return,
or refund is invalid per your stated policy and cardholder agreement,
or an explanation of how the cardholder did not attempt to remedy the issue with you first in order to receive credit.

Use when uploading evidence as: file or string | -| `TRACKINGNUMBER` | The tracking number for the order provided by the shipping carrier. If you have multiple numbers, they will need to be submitted individually as separate pieces of evidence.

Use when uploading evidence as: string | +| `SERVICE_RECEIVED_DOCUMENTATION` | Evidence that the service was provided to the cardholder or the expected date that services will be rendered.
Example evidence: signed delivery form, work order, expected delivery date, or other written agreement.

Use when uploading evidence as: file or string | +| `PROOF_OF_DELIVERY_DOCUMENTATION` | Evidence that shows the product was provided to the cardholder or the expected date of delivery.
Example evidence: signed delivery form, or written agreement acknowledging receipt of goods or services.

Use when uploading evidence as: file or string | +| `RELATED_TRANSACTION_DOCUMENTATION` | Evidence that shows the cardholder previously processed transactions on the same card and did not dispute them.
Note: Square will automatically provide up to 5 distinct Square receipts for related transactions, when available.

Use when uploading evidence as: file or string | +| `REBUTTAL_EXPLANATION` | An explanation of why the cardholder’s claim is invalid.
Example evidence: explanation of why each distinct charge is a legitimate purchase why the cardholder’s claim for credit owed due to their attempt to cancel, return,
or refund is invalid per your stated policy and cardholder agreement,
or an explanation of how the cardholder did not attempt to remedy the issue with you first in order to receive credit.

Use when uploading evidence as: file or string | +| `TRACKING_NUMBER` | The tracking number for the order provided by the shipping carrier. If you have multiple numbers, they will need to be submitted individually as separate pieces of evidence.

Use when uploading evidence as: string | diff --git a/doc/models/dispute-reason.md b/doc/models/dispute-reason.md index b15de29a..10457fc0 100644 --- a/doc/models/dispute-reason.md +++ b/doc/models/dispute-reason.md @@ -11,13 +11,13 @@ dispute with their bank. | Name | Description | | --- | --- | -| `AMOUNTDIFFERS` | The cardholder claims that they were charged the wrong amount for the purchase.
To challenge this dispute, provide specific and concrete evidence that the cardholder agreed to the amount charged. | +| `AMOUNT_DIFFERS` | The cardholder claims that they were charged the wrong amount for the purchase.
To challenge this dispute, provide specific and concrete evidence that the cardholder agreed to the amount charged. | | `CANCELLED` | The cardholder claims that they attempted to return the goods or cancel the service.
To challenge this dispute, provide specific and concrete evidence to prove that the cardholder is not due a refund, and that the cardholder acknowledged your cancellation policy. | | `DUPLICATE` | The cardholder claims that they were charged twice for the same purchase.
To challenge this dispute, provide specific and concrete evidence that shows both charges are legitimate and independent of one another. | -| `NOKNOWLEDGE` | The cardholder claims that they did not make this purchase nor authorized the charge.
To challenge this dispute, provide specific and concrete evidence that proves that the cardholder identity was verified at the time of purchase and that the purchase was authorized. | -| `NOTASDESCRIBED` | The cardholder claims the product or service was provided but the quality of the deliverable did not align with the expectations of the cardholder based on the description.
To challenge this dispute, provide specific and concrete evidence that shows the cardholder is in possession of the product as described, or received the service as described (agreed) upon. | -| `NOTRECEIVED` | The cardholder claims the product or service was not received by the cardholder within the stated time frame.
To challenge this dispute, provide specific and concrete evidence to prove that the cardholder is in possession of or received the product or service sold. | -| `PAIDBYOTHERMEANS` | The cardholder claims that they previously paid for this purchase.
To challenge this dispute, provide specific and concrete evidence that shows both charges are legitimate and independent of one another or proof that you already provided a credit for the charge. | -| `CUSTOMERREQUESTSCREDIT` | The cardholder claims that the purchase was either cancelled or returned but they have not yet received the credit.
To challenge this dispute, provide specific and concrete evidence to prove that the cardholder is not due a refund, and that they acknowledged your cancellation and/or refund policy. | -| `EMVLIABILITYSHIFT` | A chip-enabled card was not processed through a compliant chip-card reader (e.g. it was swiped instead of dipped into a chip-card reader).
You cannot challenge this dispute because the payment didn’t comply with EMV security requirements. For more information, see [What Is EMV.](https://squareup.com/emv) | +| `NO_KNOWLEDGE` | The cardholder claims that they did not make this purchase nor authorized the charge.
To challenge this dispute, provide specific and concrete evidence that proves that the cardholder identity was verified at the time of purchase and that the purchase was authorized. | +| `NOT_AS_DESCRIBED` | The cardholder claims the product or service was provided but the quality of the deliverable did not align with the expectations of the cardholder based on the description.
To challenge this dispute, provide specific and concrete evidence that shows the cardholder is in possession of the product as described, or received the service as described (agreed) upon. | +| `NOT_RECEIVED` | The cardholder claims the product or service was not received by the cardholder within the stated time frame.
To challenge this dispute, provide specific and concrete evidence to prove that the cardholder is in possession of or received the product or service sold. | +| `PAID_BY_OTHER_MEANS` | The cardholder claims that they previously paid for this purchase.
To challenge this dispute, provide specific and concrete evidence that shows both charges are legitimate and independent of one another or proof that you already provided a credit for the charge. | +| `CUSTOMER_REQUESTS_CREDIT` | The cardholder claims that the purchase was either cancelled or returned but they have not yet received the credit.
To challenge this dispute, provide specific and concrete evidence to prove that the cardholder is not due a refund, and that they acknowledged your cancellation and/or refund policy. | +| `EMV_LIABILITY_SHIFT` | A chip-enabled card was not processed through a compliant chip-card reader (e.g. it was swiped instead of dipped into a chip-card reader).
You cannot challenge this dispute because the payment didn’t comply with EMV security requirements. For more information, see [What Is EMV.](https://squareup.com/emv) | diff --git a/doc/models/dispute-state.md b/doc/models/dispute-state.md index 25b54885..2a9425a7 100644 --- a/doc/models/dispute-state.md +++ b/doc/models/dispute-state.md @@ -10,14 +10,14 @@ List of possible dispute states. | Name | | --- | -| `UNKNOWNSTATE` | -| `INQUIRYEVIDENCEREQUIRED` | -| `INQUIRYPROCESSING` | -| `INQUIRYCLOSED` | -| `EVIDENCEREQUIRED` | +| `UNKNOWN_STATE` | +| `INQUIRY_EVIDENCE_REQUIRED` | +| `INQUIRY_PROCESSING` | +| `INQUIRY_CLOSED` | +| `EVIDENCE_REQUIRED` | | `PROCESSING` | | `WON` | | `LOST` | | `ACCEPTED` | -| `WAITINGTHIRDPARTY` | +| `WAITING_THIRD_PARTY` | diff --git a/doc/models/error-category.md b/doc/models/error-category.md index 8f144962..808cf721 100644 --- a/doc/models/error-category.md +++ b/doc/models/error-category.md @@ -11,10 +11,10 @@ request to the Connect API. | Name | Description | | --- | --- | -| `APIERROR` | An error occurred with the Connect API itself. | -| `AUTHENTICATIONERROR` | An authentication error occurred. Most commonly, the request had
a missing, malformed, or otherwise invalid `Authorization` header. | -| `INVALIDREQUESTERROR` | The request was invalid. Most commonly, a required parameter was
missing, or a provided parameter had an invalid value. | -| `RATELIMITERROR` | Your application reached the Connect API rate limit. Retry your
request after a while. | -| `PAYMENTMETHODERROR` | An error occurred while processing a payment method. Most commonly,
the details of the payment method were invalid (such as a card's CVV
or expiration date). | -| `REFUNDERROR` | An error occurred while attempting to process a refund. | +| `API_ERROR` | An error occurred with the Connect API itself. | +| `AUTHENTICATION_ERROR` | An authentication error occurred. Most commonly, the request had
a missing, malformed, or otherwise invalid `Authorization` header. | +| `INVALID_REQUEST_ERROR` | The request was invalid. Most commonly, a required parameter was
missing, or a provided parameter had an invalid value. | +| `RATE_LIMIT_ERROR` | Your application reached the Connect API rate limit. Retry your
request after a while. | +| `PAYMENT_METHOD_ERROR` | An error occurred while processing a payment method. Most commonly,
the details of the payment method were invalid (such as a card's CVV
or expiration date). | +| `REFUND_ERROR` | An error occurred while attempting to process a refund. | diff --git a/doc/models/error-code.md b/doc/models/error-code.md index d68a4b7d..739606a7 100644 --- a/doc/models/error-code.md +++ b/doc/models/error-code.md @@ -11,128 +11,128 @@ Square API. | Name | Description | | --- | --- | -| `INTERNALSERVERERROR` | 500 Internal Server Error - a general server error occurred. | +| `INTERNAL_SERVER_ERROR` | 500 Internal Server Error - a general server error occurred. | | `UNAUTHORIZED` | 401 Unauthorized - a general authorization error occurred. | -| `ACCESSTOKENEXPIRED` | 401 Unauthorized - the provided access token has expired. | -| `ACCESSTOKENREVOKED` | 401 Unauthorized - the provided access token has been revoked. | -| `CLIENTDISABLED` | 401 Unauthorized - the provided client has been disabled. | +| `ACCESS_TOKEN_EXPIRED` | 401 Unauthorized - the provided access token has expired. | +| `ACCESS_TOKEN_REVOKED` | 401 Unauthorized - the provided access token has been revoked. | +| `CLIENT_DISABLED` | 401 Unauthorized - the provided client has been disabled. | | `FORBIDDEN` | 403 Forbidden - a general access error occurred. | -| `INSUFFICIENTSCOPES` | 403 Forbidden - the provided access token does not have permission
to execute the requested action. | -| `APPLICATIONDISABLED` | 403 Forbidden - the calling application was disabled. | -| `V1APPLICATION` | 403 Forbidden - the calling application was created prior to
2016-03-30 and is not compatible with v2 Square API calls. | -| `V1ACCESSTOKEN` | 403 Forbidden - the calling application is using an access token
created prior to 2016-03-30 and is not compatible with v2 Square API
calls. | -| `CARDPROCESSINGNOTENABLED` | 403 Forbidden - the location provided in the API call is not
enabled for credit card processing. | -| `BADREQUEST` | 400 Bad Request - a general error occurred. | -| `MISSINGREQUIREDPARAMETER` | 400 Bad Request - the request is missing a required path, query, or
body parameter. | -| `INCORRECTTYPE` | 400 Bad Request - the value provided in the request is the wrong
type. For example, a string instead of an integer. | -| `INVALIDTIME` | 400 Bad Request - formatting for the provided time value is
incorrect. | -| `INVALIDTIMERANGE` | 400 Bad Request - the time range provided in the request is invalid.
For example, the end time is before the start time. | -| `INVALIDVALUE` | 400 Bad Request - the provided value is invalid. For example,
including `%` in a phone number. | -| `INVALIDCURSOR` | 400 Bad Request - the pagination cursor included in the request is
invalid. | -| `UNKNOWNQUERYPARAMETER` | 400 Bad Request - the query parameters provided is invalid for the
requested endpoint. | -| `CONFLICTINGPARAMETERS` | 400 Bad Request - 1 or more of the request parameters conflict with
each other. | -| `EXPECTEDJSONBODY` | 400 Bad Request - the request body is not a JSON object. | -| `INVALIDSORTORDER` | 400 Bad Request - the provided sort order is not a valid key.
Currently, sort order must be `ASC` or `DESC`. | -| `VALUEREGEXMISMATCH` | 400 Bad Request - the provided value does not match an expected
regular expression. | -| `VALUETOOSHORT` | 400 Bad Request - the provided string value is shorter than the
minimum length allowed. | -| `VALUETOOLONG` | 400 Bad Request - the provided string value is longer than the
maximum length allowed. | -| `VALUETOOLOW` | 400 Bad Request - the provided value is less than the supported
minimum. | -| `VALUETOOHIGH` | 400 Bad Request - the provided value is greater than the supported
maximum. | -| `VALUEEMPTY` | 400 Bad Request - the provided value has a default (empty) value
such as a blank string. | -| `ARRAYLENGTHTOOLONG` | 400 Bad Request - the provided array has too many elements. | -| `ARRAYLENGTHTOOSHORT` | 400 Bad Request - the provided array has too few elements. | -| `ARRAYEMPTY` | 400 Bad Request - the provided array is empty. | -| `EXPECTEDBOOLEAN` | 400 Bad Request - the endpoint expected the provided value to be a
boolean. | -| `EXPECTEDINTEGER` | 400 Bad Request - the endpoint expected the provided value to be an
integer. | -| `EXPECTEDFLOAT` | 400 Bad Request - the endpoint expected the provided value to be a
float. | -| `EXPECTEDSTRING` | 400 Bad Request - the endpoint expected the provided value to be a
string. | -| `EXPECTEDOBJECT` | 400 Bad Request - the endpoint expected the provided value to be a
JSON object. | -| `EXPECTEDARRAY` | 400 Bad Request - the endpoint expected the provided value to be an
array or list. | -| `EXPECTEDMAP` | 400 Bad Request - the endpoint expected the provided value to be a
map or associative array. | -| `EXPECTEDBASE64ENCODEDBYTEARRAY` | 400 Bad Request - the endpoint expected the provided value to be an
array encoded in base64. | -| `INVALIDARRAYVALUE` | 400 Bad Request - 1 or more object in the array does not match the
array type. | -| `INVALIDENUMVALUE` | 400 Bad Request - the provided static string is not valid for the
field. | -| `INVALIDCONTENTTYPE` | 400 Bad Request - invalid content type header. | -| `INVALIDFORMVALUE` | 400 Bad Request - Only relevant for applications created prior to
2016-03-30. Indicates there was an error while parsing form values. | -| `CUSTOMERNOTFOUND` | 400 Bad Request - the provided customer id can't be found in the merchant's customers list. | -| `ONEINSTRUMENTEXPECTED` | 400 Bad Request - a general error occurred. | -| `NOFIELDSSET` | 400 Bad Request - a general error occurred. | -| `TOOMANYMAPENTRIES` | 400 Bad Request - too many entries in the map field. | -| `MAPKEYLENGTHTOOSHORT` | 400 Bad Request - the length of one of the provided keys in the map is too short. | -| `MAPKEYLENGTHTOOLONG` | 400 Bad Request - the length of one of the provided keys in the map is too long. | -| `CARDEXPIRED` | The card issuer declined the request because the card is expired. | -| `INVALIDEXPIRATION` | The expiration date for the payment card is invalid. For example,
it indicates a date in the past. | -| `INVALIDEXPIRATIONYEAR` | The expiration year for the payment card is invalid. For example,
it indicates a year in the past or contains invalid characters. | -| `INVALIDEXPIRATIONDATE` | The expiration date for the payment card is invalid. For example,
it contains invalid characters. | -| `UNSUPPORTEDCARDBRAND` | The credit card provided is not from a supported issuer. | -| `UNSUPPORTEDENTRYMETHOD` | The entry method for the credit card (swipe, dip, tap) is not supported. | -| `INVALIDENCRYPTEDCARD` | The encrypted card information is invalid. | -| `INVALIDCARD` | The credit card cannot be validated based on the provided details. | -| `GENERICDECLINE` | An unexpected error occurred. | -| `CVVFAILURE` | The card issuer declined the request because the CVV value is invalid. | -| `ADDRESSVERIFICATIONFAILURE` | The card issuer declined the request because the postal code is invalid. | -| `INVALIDACCOUNT` | The card issuer was not able to locate account on record. | -| `CURRENCYMISMATCH` | The currency associated with the payment is not valid for the provided
funding source. For example, a gift card funded in USD cannot be used to process
payments in GBP. | -| `INSUFFICIENTFUNDS` | The funding source has insufficient funds to cover the payment. | -| `INSUFFICIENTPERMISSIONS` | The Square account does not have the permissions to accept
this payment. For example, Square may limit which merchants are
allowed to receive gift card payments. | -| `CARDHOLDERINSUFFICIENTPERMISSIONS` | The card issuer has declined the transaction due to restrictions on where the card can be used.
For example, a gift card is limited to a single merchant. | -| `INVALIDLOCATION` | The Square account cannot take payments in the specified region.
A Square account can take payments only from the region where the account was created. | -| `TRANSACTIONLIMIT` | The card issuer has determined the payment amount is either too high or too low.
The API returns the error code mostly for credit cards (for example, the card reached
the credit limit). However, sometimes the issuer bank can indicate the error for debit
or prepaid cards (for example, card has insufficient funds). | -| `VOICEFAILURE` | The card issuer declined the request because the issuer requires voice authorization from the cardholder. | -| `PANFAILURE` | The specified card number is invalid. For example, it is of
incorrect length or is incorrectly formatted. | -| `EXPIRATIONFAILURE` | The card expiration date is either invalid or indicates that the
card is expired. | -| `CARDNOTSUPPORTED` | The card is not supported either in the geographic region or by
the MCC [merchant category code](https://developer.squareup.com/docs/docs/api/connect/v2#navsection-connectapibasics) | -| `INVALIDPIN` | The card issuer declined the request because the PIN is invalid. | -| `INVALIDPOSTALCODE` | The postal code is incorrectly formatted. | -| `INVALIDFEES` | The app_fee_money on a payment is too high. | -| `MANUALLYENTEREDPAYMENTNOTSUPPORTED` | The card must be swiped, tapped, or dipped. Payments attempted by manually entering the card number are declined. | -| `PAYMENTLIMITEXCEEDED` | Square declined the request because the payment amount exceeded the processing limit for this merchant. | -| `GIFTCARDAVAILABLEAMOUNT` | When using a gift card as a payment source in a `CreatePayment` request, you can allow
taking partial payment by adding the `accept_partial_authorization` parameter in the request.
If the gift card does not have sufficient balance to pay the entire `amount_money` specified
in the request, the request will succeed (an APPROVED payment for the remaining balance will be
returned). For more information, see [Partial amount with Square gift cards](https://developer.squareup.com/docs/docs/payments-api/take-payments#partial-payment-gift-card).\r\n\r\n
However, taking such a partial payment does not work if your request also includes `tip_money`,
`app_fee_money`, or both. Square declines such payment and returns this error.\r\n* The error
details provide the amount that was available on the gift card at the time of the request.
The amount is a string representation in the smallest denomination of the applicable currency.
For example, in USD the amount is specified in cents.\r\n* The error code appears in an array
along with the INSUFFICIENT_FUNDS error.\r\n\r\nThe following is an example set of
errors:\r\n```\r\n{\r\n \"errors\": [\r\n {\r\n \"code\": \"INSUFFICIENT_FUNDS\",\r\n \"detail\": \"Gift card does not have sufficient balance for requested amount and tip.\",\r\n \"category\": \"PAYMENT_METHOD_ERROR\"\r\n },\r\n {\r\n \"code\": \"GIFT_CARD_AVAILABLE_AMOUNT\",\r\n \"detail\": \"4494\",\r\n \"category\": \"PAYMENT_METHOD_ERROR\"\r\n }\r\n ]\r\n}\r\n```\r\n\r\n
In addition to the errors, it shows the gift card balance at 44.94 USD. You can review this amount and submit a new `CreatePayment` request with `tip_money` and `amount_money` that fit within the available balance. | -| `DELAYEDTRANSACTIONEXPIRED` | The application tried to update a delayed-capture payment that has expired. | -| `DELAYEDTRANSACTIONCANCELED` | The application tried to cancel a delayed-capture payment that was already cancelled. | -| `DELAYEDTRANSACTIONCAPTURED` | The application tried to capture a delayed-capture payment that was already captured. | -| `DELAYEDTRANSACTIONFAILED` | The application tried to update a delayed-capture payment that failed. | -| `CARDTOKENEXPIRED` | The provided card token (nonce) has expired. | -| `CARDTOKENUSED` | The provided card token (nonce) was already used to process payment. | -| `AMOUNTTOOHIGH` | The requested payment amount is too high for the provided payment source. | -| `UNSUPPORTEDINSTRUMENTTYPE` | The API request references an unsupported instrument type/ | -| `REFUNDAMOUNTINVALID` | The requested refund amount exceeds the amount available to refund. | -| `REFUNDALREADYPENDING` | The payment already has a pending refund. | -| `PAYMENTNOTREFUNDABLE` | The payment is not refundable. For example, a previous refund has
already been rejected and no new refunds can be accepted. | -| `INVALIDCARDDATA` | Generic error - the provided card data is invalid. | -| `LOCATIONMISMATCH` | Generic error - the given location does not matching what is expected. | -| `IDEMPOTENCYKEYREUSED` | The provided idempotency key has already been used. | -| `UNEXPECTEDVALUE` | General error - the value provided was unexpected. | -| `SANDBOXNOTSUPPORTED` | The API request is not supported in sandbox. | -| `INVALIDEMAILADDRESS` | The provided email address is invalid. | -| `INVALIDPHONENUMBER` | The provided phone number is invalid. | -| `CHECKOUTEXPIRED` | The provided checkout URL has expired. | -| `BADCERTIFICATE` | Bad certificate. | -| `INVALIDSQUAREVERSIONFORMAT` | The provided Square-Version is incorrectly formatted. | -| `APIVERSIONINCOMPATIBLE` | The provided Square-Version is incompatible with the requested action. | -| `CARDDECLINED` | 402 Request failed - the card was declined. | -| `VERIFYCVVFAILURE` | 402 Request failed - the CVV could not be verified. | -| `VERIFYAVSFAILURE` | 402 Request failed - the AVS could not be verified. | -| `CARDDECLINEDCALLISSUER` | 402 Request failed - the payment card was declined with a request
for the card holder to call the issuer. | -| `CARDDECLINEDVERIFICATIONREQUIRED` | 402 Request failed - the payment card was declined with a request
for additional verification. | -| `BADEXPIRATION` | 402 Request failed - the card expiration date is either missing or
incorrectly formatted. | -| `CHIPINSERTIONREQUIRED` | 402 Request failed - the card issuer requires that the card be read
using a chip reader. | -| `ALLOWABLEPINTRIESEXCEEDED` | 402 Request failed - the card has exhausted its available pin entry
retries set by the card issuer. Resolving the error typically requires the
card holder to contact the card issuer. | -| `RESERVATIONDECLINED` | 402 Request failed - The card issuer declined the refund. | -| `NOTFOUND` | 404 Not Found - a general error occurred. | -| `APPLEPAYMENTPROCESSINGCERTIFICATEHASHNOTFOUND` | 404 Not Found - Square could not find the associated Apple Pay certificate. | -| `METHODNOTALLOWED` | 405 Method Not Allowed - a general error occurred. | -| `NOTACCEPTABLE` | 406 Not Acceptable - a general error occurred. | -| `REQUESTTIMEOUT` | 408 Request Timeout - a general error occurred. | +| `INSUFFICIENT_SCOPES` | 403 Forbidden - the provided access token does not have permission
to execute the requested action. | +| `APPLICATION_DISABLED` | 403 Forbidden - the calling application was disabled. | +| `V1_APPLICATION` | 403 Forbidden - the calling application was created prior to
2016-03-30 and is not compatible with v2 Square API calls. | +| `V1_ACCESS_TOKEN` | 403 Forbidden - the calling application is using an access token
created prior to 2016-03-30 and is not compatible with v2 Square API
calls. | +| `CARD_PROCESSING_NOT_ENABLED` | 403 Forbidden - the location provided in the API call is not
enabled for credit card processing. | +| `BAD_REQUEST` | 400 Bad Request - a general error occurred. | +| `MISSING_REQUIRED_PARAMETER` | 400 Bad Request - the request is missing a required path, query, or
body parameter. | +| `INCORRECT_TYPE` | 400 Bad Request - the value provided in the request is the wrong
type. For example, a string instead of an integer. | +| `INVALID_TIME` | 400 Bad Request - formatting for the provided time value is
incorrect. | +| `INVALID_TIME_RANGE` | 400 Bad Request - the time range provided in the request is invalid.
For example, the end time is before the start time. | +| `INVALID_VALUE` | 400 Bad Request - the provided value is invalid. For example,
including `%` in a phone number. | +| `INVALID_CURSOR` | 400 Bad Request - the pagination cursor included in the request is
invalid. | +| `UNKNOWN_QUERY_PARAMETER` | 400 Bad Request - the query parameters provided is invalid for the
requested endpoint. | +| `CONFLICTING_PARAMETERS` | 400 Bad Request - 1 or more of the request parameters conflict with
each other. | +| `EXPECTED_JSON_BODY` | 400 Bad Request - the request body is not a JSON object. | +| `INVALID_SORT_ORDER` | 400 Bad Request - the provided sort order is not a valid key.
Currently, sort order must be `ASC` or `DESC`. | +| `VALUE_REGEX_MISMATCH` | 400 Bad Request - the provided value does not match an expected
regular expression. | +| `VALUE_TOO_SHORT` | 400 Bad Request - the provided string value is shorter than the
minimum length allowed. | +| `VALUE_TOO_LONG` | 400 Bad Request - the provided string value is longer than the
maximum length allowed. | +| `VALUE_TOO_LOW` | 400 Bad Request - the provided value is less than the supported
minimum. | +| `VALUE_TOO_HIGH` | 400 Bad Request - the provided value is greater than the supported
maximum. | +| `VALUE_EMPTY` | 400 Bad Request - the provided value has a default (empty) value
such as a blank string. | +| `ARRAY_LENGTH_TOO_LONG` | 400 Bad Request - the provided array has too many elements. | +| `ARRAY_LENGTH_TOO_SHORT` | 400 Bad Request - the provided array has too few elements. | +| `ARRAY_EMPTY` | 400 Bad Request - the provided array is empty. | +| `EXPECTED_BOOLEAN` | 400 Bad Request - the endpoint expected the provided value to be a
boolean. | +| `EXPECTED_INTEGER` | 400 Bad Request - the endpoint expected the provided value to be an
integer. | +| `EXPECTED_FLOAT` | 400 Bad Request - the endpoint expected the provided value to be a
float. | +| `EXPECTED_STRING` | 400 Bad Request - the endpoint expected the provided value to be a
string. | +| `EXPECTED_OBJECT` | 400 Bad Request - the endpoint expected the provided value to be a
JSON object. | +| `EXPECTED_ARRAY` | 400 Bad Request - the endpoint expected the provided value to be an
array or list. | +| `EXPECTED_MAP` | 400 Bad Request - the endpoint expected the provided value to be a
map or associative array. | +| `EXPECTED_BASE64_ENCODED_BYTE_ARRAY` | 400 Bad Request - the endpoint expected the provided value to be an
array encoded in base64. | +| `INVALID_ARRAY_VALUE` | 400 Bad Request - 1 or more object in the array does not match the
array type. | +| `INVALID_ENUM_VALUE` | 400 Bad Request - the provided static string is not valid for the
field. | +| `INVALID_CONTENT_TYPE` | 400 Bad Request - invalid content type header. | +| `INVALID_FORM_VALUE` | 400 Bad Request - Only relevant for applications created prior to
2016-03-30. Indicates there was an error while parsing form values. | +| `CUSTOMER_NOT_FOUND` | 400 Bad Request - the provided customer id can't be found in the merchant's customers list. | +| `ONE_INSTRUMENT_EXPECTED` | 400 Bad Request - a general error occurred. | +| `NO_FIELDS_SET` | 400 Bad Request - a general error occurred. | +| `TOO_MANY_MAP_ENTRIES` | 400 Bad Request - too many entries in the map field. | +| `MAP_KEY_LENGTH_TOO_SHORT` | 400 Bad Request - the length of one of the provided keys in the map is too short. | +| `MAP_KEY_LENGTH_TOO_LONG` | 400 Bad Request - the length of one of the provided keys in the map is too long. | +| `CARD_EXPIRED` | The card issuer declined the request because the card is expired. | +| `INVALID_EXPIRATION` | The expiration date for the payment card is invalid. For example,
it indicates a date in the past. | +| `INVALID_EXPIRATION_YEAR` | The expiration year for the payment card is invalid. For example,
it indicates a year in the past or contains invalid characters. | +| `INVALID_EXPIRATION_DATE` | The expiration date for the payment card is invalid. For example,
it contains invalid characters. | +| `UNSUPPORTED_CARD_BRAND` | The credit card provided is not from a supported issuer. | +| `UNSUPPORTED_ENTRY_METHOD` | The entry method for the credit card (swipe, dip, tap) is not supported. | +| `INVALID_ENCRYPTED_CARD` | The encrypted card information is invalid. | +| `INVALID_CARD` | The credit card cannot be validated based on the provided details. | +| `GENERIC_DECLINE` | An unexpected error occurred. | +| `CVV_FAILURE` | The card issuer declined the request because the CVV value is invalid. | +| `ADDRESS_VERIFICATION_FAILURE` | The card issuer declined the request because the postal code is invalid. | +| `INVALID_ACCOUNT` | The card issuer was not able to locate account on record. | +| `CURRENCY_MISMATCH` | The currency associated with the payment is not valid for the provided
funding source. For example, a gift card funded in USD cannot be used to process
payments in GBP. | +| `INSUFFICIENT_FUNDS` | The funding source has insufficient funds to cover the payment. | +| `INSUFFICIENT_PERMISSIONS` | The Square account does not have the permissions to accept
this payment. For example, Square may limit which merchants are
allowed to receive gift card payments. | +| `CARDHOLDER_INSUFFICIENT_PERMISSIONS` | The card issuer has declined the transaction due to restrictions on where the card can be used.
For example, a gift card is limited to a single merchant. | +| `INVALID_LOCATION` | The Square account cannot take payments in the specified region.
A Square account can take payments only from the region where the account was created. | +| `TRANSACTION_LIMIT` | The card issuer has determined the payment amount is either too high or too low.
The API returns the error code mostly for credit cards (for example, the card reached
the credit limit). However, sometimes the issuer bank can indicate the error for debit
or prepaid cards (for example, card has insufficient funds). | +| `VOICE_FAILURE` | The card issuer declined the request because the issuer requires voice authorization from the cardholder. | +| `PAN_FAILURE` | The specified card number is invalid. For example, it is of
incorrect length or is incorrectly formatted. | +| `EXPIRATION_FAILURE` | The card expiration date is either invalid or indicates that the
card is expired. | +| `CARD_NOT_SUPPORTED` | The card is not supported either in the geographic region or by
the MCC [merchant category code](https://developer.squareup.com/docs/docs/api/connect/v2#navsection-connectapibasics) | +| `INVALID_PIN` | The card issuer declined the request because the PIN is invalid. | +| `INVALID_POSTAL_CODE` | The postal code is incorrectly formatted. | +| `INVALID_FEES` | The app_fee_money on a payment is too high. | +| `MANUALLY_ENTERED_PAYMENT_NOT_SUPPORTED` | The card must be swiped, tapped, or dipped. Payments attempted by manually entering the card number are declined. | +| `PAYMENT_LIMIT_EXCEEDED` | Square declined the request because the payment amount exceeded the processing limit for this merchant. | +| `GIFT_CARD_AVAILABLE_AMOUNT` | When using a gift card as a payment source in a `CreatePayment` request, you can allow
taking partial payment by adding the `accept_partial_authorization` parameter in the request.
If the gift card does not have sufficient balance to pay the entire `amount_money` specified
in the request, the request will succeed (an APPROVED payment for the remaining balance will be
returned). For more information, see [Partial amount with Square gift cards](https://developer.squareup.com/docs/docs/payments-api/take-payments#partial-payment-gift-card).\r\n\r\n
However, taking such a partial payment does not work if your request also includes `tip_money`,
`app_fee_money`, or both. Square declines such payment and returns this error.\r\n* The error
details provide the amount that was available on the gift card at the time of the request.
The amount is a string representation in the smallest denomination of the applicable currency.
For example, in USD the amount is specified in cents.\r\n* The error code appears in an array
along with the INSUFFICIENT_FUNDS error.\r\n\r\nThe following is an example set of
errors:\r\n```\r\n{\r\n \"errors\": [\r\n {\r\n \"code\": \"INSUFFICIENT_FUNDS\",\r\n \"detail\": \"Gift card does not have sufficient balance for requested amount and tip.\",\r\n \"category\": \"PAYMENT_METHOD_ERROR\"\r\n },\r\n {\r\n \"code\": \"GIFT_CARD_AVAILABLE_AMOUNT\",\r\n \"detail\": \"4494\",\r\n \"category\": \"PAYMENT_METHOD_ERROR\"\r\n }\r\n ]\r\n}\r\n```\r\n\r\n
In addition to the errors, it shows the gift card balance at 44.94 USD. You can review this amount and submit a new `CreatePayment` request with `tip_money` and `amount_money` that fit within the available balance. | +| `DELAYED_TRANSACTION_EXPIRED` | The application tried to update a delayed-capture payment that has expired. | +| `DELAYED_TRANSACTION_CANCELED` | The application tried to cancel a delayed-capture payment that was already cancelled. | +| `DELAYED_TRANSACTION_CAPTURED` | The application tried to capture a delayed-capture payment that was already captured. | +| `DELAYED_TRANSACTION_FAILED` | The application tried to update a delayed-capture payment that failed. | +| `CARD_TOKEN_EXPIRED` | The provided card token (nonce) has expired. | +| `CARD_TOKEN_USED` | The provided card token (nonce) was already used to process payment. | +| `AMOUNT_TOO_HIGH` | The requested payment amount is too high for the provided payment source. | +| `UNSUPPORTED_INSTRUMENT_TYPE` | The API request references an unsupported instrument type/ | +| `REFUND_AMOUNT_INVALID` | The requested refund amount exceeds the amount available to refund. | +| `REFUND_ALREADY_PENDING` | The payment already has a pending refund. | +| `PAYMENT_NOT_REFUNDABLE` | The payment is not refundable. For example, a previous refund has
already been rejected and no new refunds can be accepted. | +| `INVALID_CARD_DATA` | Generic error - the provided card data is invalid. | +| `LOCATION_MISMATCH` | Generic error - the given location does not matching what is expected. | +| `IDEMPOTENCY_KEY_REUSED` | The provided idempotency key has already been used. | +| `UNEXPECTED_VALUE` | General error - the value provided was unexpected. | +| `SANDBOX_NOT_SUPPORTED` | The API request is not supported in sandbox. | +| `INVALID_EMAIL_ADDRESS` | The provided email address is invalid. | +| `INVALID_PHONE_NUMBER` | The provided phone number is invalid. | +| `CHECKOUT_EXPIRED` | The provided checkout URL has expired. | +| `BAD_CERTIFICATE` | Bad certificate. | +| `INVALID_SQUARE_VERSION_FORMAT` | The provided Square-Version is incorrectly formatted. | +| `API_VERSION_INCOMPATIBLE` | The provided Square-Version is incompatible with the requested action. | +| `CARD_DECLINED` | 402 Request failed - the card was declined. | +| `VERIFY_CVV_FAILURE` | 402 Request failed - the CVV could not be verified. | +| `VERIFY_AVS_FAILURE` | 402 Request failed - the AVS could not be verified. | +| `CARD_DECLINED_CALL_ISSUER` | 402 Request failed - the payment card was declined with a request
for the card holder to call the issuer. | +| `CARD_DECLINED_VERIFICATION_REQUIRED` | 402 Request failed - the payment card was declined with a request
for additional verification. | +| `BAD_EXPIRATION` | 402 Request failed - the card expiration date is either missing or
incorrectly formatted. | +| `CHIP_INSERTION_REQUIRED` | 402 Request failed - the card issuer requires that the card be read
using a chip reader. | +| `ALLOWABLE_PIN_TRIES_EXCEEDED` | 402 Request failed - the card has exhausted its available pin entry
retries set by the card issuer. Resolving the error typically requires the
card holder to contact the card issuer. | +| `RESERVATION_DECLINED` | 402 Request failed - The card issuer declined the refund. | +| `NOT_FOUND` | 404 Not Found - a general error occurred. | +| `APPLE_PAYMENT_PROCESSING_CERTIFICATE_HASH_NOT_FOUND` | 404 Not Found - Square could not find the associated Apple Pay certificate. | +| `METHOD_NOT_ALLOWED` | 405 Method Not Allowed - a general error occurred. | +| `NOT_ACCEPTABLE` | 406 Not Acceptable - a general error occurred. | +| `REQUEST_TIMEOUT` | 408 Request Timeout - a general error occurred. | | `CONFLICT` | 409 Conflict - a general error occurred. | | `GONE` | 410 Gone - the target resource is no longer available and this
condition is likely to be permanent.. | -| `REQUESTENTITYTOOLARGE` | 413 Request Entity Too Large - a general error occurred. | -| `UNSUPPORTEDMEDIATYPE` | 415 Unsupported Media Type - a general error occurred. | -| `UNPROCESSABLEENTITY` | 422 Unprocessable Entity - a general error occurred. | -| `RATELIMITED` | 429 Rate Limited - a general error occurred. | -| `NOTIMPLEMENTED` | 501 Not Implemented - a general error occurred. | -| `BADGATEWAY` | 502 Bad Gateway - a general error occurred. | -| `SERVICEUNAVAILABLE` | 503 Service Unavailable - a general error occurred. | -| `TEMPORARYERROR` | A temporary internal error occurred. You can safely retry your call
using the same idempotency key. | -| `GATEWAYTIMEOUT` | 504 Gateway Timeout - a general error occurred. | +| `REQUEST_ENTITY_TOO_LARGE` | 413 Request Entity Too Large - a general error occurred. | +| `UNSUPPORTED_MEDIA_TYPE` | 415 Unsupported Media Type - a general error occurred. | +| `UNPROCESSABLE_ENTITY` | 422 Unprocessable Entity - a general error occurred. | +| `RATE_LIMITED` | 429 Rate Limited - a general error occurred. | +| `NOT_IMPLEMENTED` | 501 Not Implemented - a general error occurred. | +| `BAD_GATEWAY` | 502 Bad Gateway - a general error occurred. | +| `SERVICE_UNAVAILABLE` | 503 Service Unavailable - a general error occurred. | +| `TEMPORARY_ERROR` | A temporary internal error occurred. You can safely retry your call
using the same idempotency key. | +| `GATEWAY_TIMEOUT` | 504 Gateway Timeout - a general error occurred. | diff --git a/doc/models/exclude-strategy.md b/doc/models/exclude-strategy.md index 95ca3450..705da344 100644 --- a/doc/models/exclude-strategy.md +++ b/doc/models/exclude-strategy.md @@ -11,6 +11,6 @@ will be excluded if the pricing rule uses an exclude set. | Name | Description | | --- | --- | -| `LEASTEXPENSIVE` | The least expensive matched products are excluded from the pricing. If
the pricing rule is set to exclude one product and multiple products in the
match set qualify as least expensive, then one will be excluded at random.

Excluding the least expensive product gives the best discount value to the buyer. | -| `MOSTEXPENSIVE` | The most expensive matched product is excluded from the pricing rule.
If multiple products have the same price and all qualify as least expensive,
one will be excluded at random.

This guarantees that the most expensive product is purchased at full price. | +| `LEAST_EXPENSIVE` | The least expensive matched products are excluded from the pricing. If
the pricing rule is set to exclude one product and multiple products in the
match set qualify as least expensive, then one will be excluded at random.

Excluding the least expensive product gives the best discount value to the buyer. | +| `MOST_EXPENSIVE` | The most expensive matched product is excluded from the pricing rule.
If multiple products have the same price and all qualify as least expensive,
one will be excluded at random.

This guarantees that the most expensive product is purchased at full price. | diff --git a/doc/models/inventory-alert-type.md b/doc/models/inventory-alert-type.md index c19b03c2..1f8ed6f8 100644 --- a/doc/models/inventory-alert-type.md +++ b/doc/models/inventory-alert-type.md @@ -11,5 +11,5 @@ Indicates whether Square should alert the merchant when the inventory quantity o | Name | Description | | --- | --- | | `NONE` | The variation does not display an alert. | -| `LOWQUANTITY` | The variation generates an alert when its quantity is low. | +| `LOW_QUANTITY` | The variation generates an alert when its quantity is low. | diff --git a/doc/models/inventory-change-type.md b/doc/models/inventory-change-type.md index 2093d29d..861fc72f 100644 --- a/doc/models/inventory-change-type.md +++ b/doc/models/inventory-change-type.md @@ -10,7 +10,7 @@ Indicates how the inventory change was applied to a tracked quantity of items. | Name | Description | | --- | --- | -| `PHYSICALCOUNT` | The change occurred as part of a physical count update. | +| `PHYSICAL_COUNT` | The change occurred as part of a physical count update. | | `ADJUSTMENT` | The change occurred as part of the normal lifecycle of goods
(e.g., as an inventory adjustment). | | `TRANSFER` | The change occurred as part of an inventory transfer. | diff --git a/doc/models/inventory-state.md b/doc/models/inventory-state.md index bed46142..f65b86eb 100644 --- a/doc/models/inventory-state.md +++ b/doc/models/inventory-state.md @@ -11,15 +11,15 @@ Indicates the state of a tracked item quantity in the lifecycle of goods. | Name | Description | | --- | --- | | `CUSTOM` | The related quantity of items are in a custom state. **READ-ONLY**:
the Inventory API cannot move quantities to or from this state. | -| `INSTOCK` | The related quantity of items are on hand and available for sale. | +| `IN_STOCK` | The related quantity of items are on hand and available for sale. | | `SOLD` | The related quantity of items were sold as part of an itemized
transaction. Quantities in the `SOLD` state are no longer tracked. | -| `RETURNEDBYCUSTOMER` | The related quantity of items were returned through the Square Point
of Sale application, but are not yet available for sale. **READ-ONLY**:
the Inventory API cannot move quantities to or from this state. | -| `RESERVEDFORSALE` | The related quantity of items are on hand, but not currently
available for sale. **READ-ONLY**: the Inventory API cannot move
quantities to or from this state. | -| `SOLDONLINE` | The related quantity of items were sold online. **READ-ONLY**: the
Inventory API cannot move quantities to or from this state. | -| `ORDEREDFROMVENDOR` | The related quantity of items were ordered from a vendor but not yet
received. **READ-ONLY**: the Inventory API cannot move quantities to or
from this state. | -| `RECEIVEDFROMVENDOR` | The related quantity of items were received from a vendor but are
not yet available for sale. **READ-ONLY**: the Inventory API cannot move
quantities to or from this state. | -| `INTRANSITTO` | The related quantity of items are in transit between locations.
*READ-ONLY**: the Inventory API cannot move quantities to or from this
state. | +| `RETURNED_BY_CUSTOMER` | The related quantity of items were returned through the Square Point
of Sale application, but are not yet available for sale. **READ-ONLY**:
the Inventory API cannot move quantities to or from this state. | +| `RESERVED_FOR_SALE` | The related quantity of items are on hand, but not currently
available for sale. **READ-ONLY**: the Inventory API cannot move
quantities to or from this state. | +| `SOLD_ONLINE` | The related quantity of items were sold online. **READ-ONLY**: the
Inventory API cannot move quantities to or from this state. | +| `ORDERED_FROM_VENDOR` | The related quantity of items were ordered from a vendor but not yet
received. **READ-ONLY**: the Inventory API cannot move quantities to or
from this state. | +| `RECEIVED_FROM_VENDOR` | The related quantity of items were received from a vendor but are
not yet available for sale. **READ-ONLY**: the Inventory API cannot move
quantities to or from this state. | +| `IN_TRANSIT_TO` | The related quantity of items are in transit between locations.
*READ-ONLY**: the Inventory API cannot move quantities to or from this
state. | | `NONE` | A placeholder indicating that the related quantity of items are not
currently tracked in Square. Transferring quantities from the `NONE` state
to a tracked state (e.g., `IN_STOCK`) introduces stock into the system. | | `WASTE` | The related quantity of items are lost or damaged and cannot be
sold. | -| `UNLINKEDRETURN` | The related quantity of items were returned but not linked to a
previous transaction. Unlinked returns are not tracked in Square.
Transferring a quantity from `UNLINKED_RETURN` to a tracked state (e.g.,
`IN_STOCK`) introduces new stock into the system. | +| `UNLINKED_RETURN` | The related quantity of items were returned but not linked to a
previous transaction. Unlinked returns are not tracked in Square.
Transferring a quantity from `UNLINKED_RETURN` to a tracked state (e.g.,
`IN_STOCK`) introduces new stock into the system. | diff --git a/doc/models/invoice-payment-reminder-status.md b/doc/models/invoice-payment-reminder-status.md index 760c0464..8a271a5b 100644 --- a/doc/models/invoice-payment-reminder-status.md +++ b/doc/models/invoice-payment-reminder-status.md @@ -11,6 +11,6 @@ The status of a payment request reminder. | Name | Description | | --- | --- | | `PENDING` | The reminder is to be sent on the `relative_scheduled_date` (if the invoice is published). | -| `NOTAPPLICABLE` | The reminder is not applicable and is not sent. The following are examples
of when reminders are not applicable and are not sent:
- You schedule a reminder to be sent before the invoice is published.
- The invoice is configured with multiple payment requests and a payment request reminder
is configured to be sent after the next payment request `due_date`.
- Two reminders (for different payment requests) are configured to be sent on the
same date. Therefore, only one reminder is sent.
- You configure a reminder to be sent on the date that the invoice is scheduled to be sent.
- The payment request is already paid.
- The invoice status is `CANCELED` or `FAILED`. | +| `NOT_APPLICABLE` | The reminder is not applicable and is not sent. The following are examples
of when reminders are not applicable and are not sent:
- You schedule a reminder to be sent before the invoice is published.
- The invoice is configured with multiple payment requests and a payment request reminder
is configured to be sent after the next payment request `due_date`.
- Two reminders (for different payment requests) are configured to be sent on the
same date. Therefore, only one reminder is sent.
- You configure a reminder to be sent on the date that the invoice is scheduled to be sent.
- The payment request is already paid.
- The invoice status is `CANCELED` or `FAILED`. | | `SENT` | The reminder is sent. | diff --git a/doc/models/invoice-request-method.md b/doc/models/invoice-request-method.md index c607b3ea..fe0685c2 100644 --- a/doc/models/invoice-request-method.md +++ b/doc/models/invoice-request-method.md @@ -12,6 +12,6 @@ email the invoice, charge a customer's card on file, or do nothing. | Name | Description | | --- | --- | | `EMAIL` | Directs Square to email the invoice to the customer after the invoice is published
(either immediately or at the `scheduled_at` time, if specified in the [invoice](#type-invoice)). | -| `CHARGECARDONFILE` | Directs Square to charge the card on file, on the `due_date`, specified in the payment request
after the invoice is published. | -| `SHAREMANUALLY` | Directs Square to take no specific action on the invoice. In this case, the seller
(or the application developer) follows up with the customer for payment. For example,
a seller might collect a payment in the Seller Dashboard or use the Point of Sale (POS) application.
The seller might also share the URL of the Square-hosted invoice page (`public_url`) with the customer requesting payment. | +| `CHARGE_CARD_ON_FILE` | Directs Square to charge the card on file, on the `due_date`, specified in the payment request
after the invoice is published. | +| `SHARE_MANUALLY` | Directs Square to take no specific action on the invoice. In this case, the seller
(or the application developer) follows up with the customer for payment. For example,
a seller might collect a payment in the Seller Dashboard or use the Point of Sale (POS) application.
The seller might also share the URL of the Square-hosted invoice page (`public_url`) with the customer requesting payment. | diff --git a/doc/models/invoice-sort-field.md b/doc/models/invoice-sort-field.md index f98c4b22..db282950 100644 --- a/doc/models/invoice-sort-field.md +++ b/doc/models/invoice-sort-field.md @@ -10,5 +10,5 @@ Field to use for sorting. | Name | Description | | --- | --- | -| `INVOICESORTDATE` | The field works as follows:

- If the invoice is a draft, it uses the invoice `created_at` date.
- If the invoice is scheduled for publication, it uses the `scheduled_at` date.
- If the invoice is published, it uses the invoice publication date. | +| `INVOICE_SORT_DATE` | The field works as follows:

- If the invoice is a draft, it uses the invoice `created_at` date.
- If the invoice is scheduled for publication, it uses the `scheduled_at` date.
- If the invoice is published, it uses the invoice publication date. | diff --git a/doc/models/invoice-status.md b/doc/models/invoice-status.md index 375d9d5f..2f37af49 100644 --- a/doc/models/invoice-status.md +++ b/doc/models/invoice-status.md @@ -13,9 +13,9 @@ Indicates the status of an invoice. | `DRAFT` | The invoice is a draft. You must publish a draft invoice before Square can process it.
A draft invoice has no public_url, so it is not available to customers. | | `UNPAID` | The invoice is published but not yet paid. | | `SCHEDULED` | The invoice is scheduled to be processed. On scheduled date,
Square emails the invoice (if the `request_method` is EMAIL),
charge the customer's card (if `request_method` is CHARGE_CARD_ON_FILE),
or take no action (if the `request_method` is SHARE_MANUALLY).
The invoice status then changes accordingly (`UNPAID`, `PAID`, or `PARTIALLY_PAID`). | -| `PARTIALLYPAID` | A partial payment is received for the invoice. | +| `PARTIALLY_PAID` | A partial payment is received for the invoice. | | `PAID` | The customer paid the invoice in full. | -| `PARTIALLYREFUNDED` | The invoice is paid (or partially paid) and some but not all the amount paid is
refunded. | +| `PARTIALLY_REFUNDED` | The invoice is paid (or partially paid) and some but not all the amount paid is
refunded. | | `REFUNDED` | The full amount that the customer paid for the invoice is refunded. | | `CANCELED` | The invoice is canceled. Square no longer requests payments from the customer.
The `public_url` page remains and is accessible, but it displays the invoice
as cancelled and does not accept payment. | | `FAILED` | Square canceled the invoice due to suspicious activity. | diff --git a/doc/models/list-subscription-events-request.md b/doc/models/list-subscription-events-request.md new file mode 100644 index 00000000..76e3f9af --- /dev/null +++ b/doc/models/list-subscription-events-request.md @@ -0,0 +1,26 @@ +## List Subscription Events Request + +Defines parameters in a +[ListSubscriptionEvents](#endpoint-subscriptions-listsubscriptionevents) +endpoint request. + +### Structure + +`ListSubscriptionEventsRequest` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Cursor` | `String` | Optional | A pagination cursor returned by a previous call to this endpoint.
Provide this to retrieve the next set of results for the original query.

For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). | +| `Limit` | `Integer` | Optional | The upper limit on the number of subscription events to return
in the response.

Default: `200` | + +### Example (as JSON) + +```json +{ + "cursor": null, + "limit": null +} +``` + diff --git a/doc/models/list-subscription-events-response.md b/doc/models/list-subscription-events-response.md new file mode 100644 index 00000000..be43356c --- /dev/null +++ b/doc/models/list-subscription-events-response.md @@ -0,0 +1,39 @@ +## List Subscription Events Response + +Defines the fields that are included in the response from the +[ListSubscriptionEvents](#endpoint-subscriptions-listsubscriptionevents) +endpoint. + +### Structure + +`ListSubscriptionEventsResponse` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Errors` | [`List`](/doc/models/error.md) | Optional | Information about errors encountered during the request. | +| `SubscriptionEvents` | [`List`](/doc/models/subscription-event.md) | Optional | The `SubscriptionEvents` retrieved. | +| `Cursor` | `String` | Optional | When a response is truncated, it includes a cursor that you can
use in a subsequent request to fetch the next set of events.
If empty, this is the final response.

For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). | + +### Example (as JSON) + +```json +{ + "subscription_events": [ + { + "id": "06809161-3867-4598-8269-8aea5be4f9de", + "subscription_event_type": "START_SUBSCRIPTION", + "effective_date": "2020-04-24", + "plan_id": "6JHXF3B2CW3YKHDV4XEM674H" + }, + { + "id": "a0c08083-5db0-4800-85c7-d398de4fbb6e", + "subscription_event_type": "STOP_SUBSCRIPTION", + "effective_date": "2020-05-06", + "plan_id": "6JHXF3B2CW3YKHDV4XEM674H" + } + ] +} +``` + diff --git a/doc/models/location-capability.md b/doc/models/location-capability.md index ff5648be..f0e3a45f 100644 --- a/doc/models/location-capability.md +++ b/doc/models/location-capability.md @@ -10,5 +10,5 @@ The capabilities a location may have. | Name | Description | | --- | --- | -| `CREDITCARDPROCESSING` | The permission to process credit card transactions with Square.

The location can process credit cards if this value is present
in the `capabilities` array of the `Location`. | +| `CREDIT_CARD_PROCESSING` | The permission to process credit card transactions with Square.

The location can process credit cards if this value is present
in the `capabilities` array of the `Location`. | diff --git a/doc/models/loyalty-event-source.md b/doc/models/loyalty-event-source.md index 27968a40..2c334718 100644 --- a/doc/models/loyalty-event-source.md +++ b/doc/models/loyalty-event-source.md @@ -11,5 +11,5 @@ Defines whether the event was generated by the Square Point of Sale. | Name | Description | | --- | --- | | `SQUARE` | The event is generated by the Square Point of Sale (POS). | -| `LOYALTYAPI` | The event is generated by something other than the Square Point of Sale that used the Loyalty API. | +| `LOYALTY_API` | The event is generated by something other than the Square Point of Sale that used the Loyalty API. | diff --git a/doc/models/loyalty-event-type.md b/doc/models/loyalty-event-type.md index 1a1a9f92..f66c27a5 100644 --- a/doc/models/loyalty-event-type.md +++ b/doc/models/loyalty-event-type.md @@ -10,11 +10,11 @@ The type of the loyalty event. | Name | Description | | --- | --- | -| `ACCUMULATEPOINTS` | Points are added to a loyalty account for a purchase. | -| `CREATEREWARD` | A loyalty reward is created. For more information, see
[Loyalty rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#loyalty-overview-loyalty-rewards). | -| `REDEEMREWARD` | A loyalty reward is redeemed. | -| `DELETEREWARD` | A loyalty reward is deleted. | -| `ADJUSTPOINTS` | Loyalty points are manually adjusted. | -| `EXPIREPOINTS` | Loyalty points are expired according to the
expiration policy of the loyalty program. | +| `ACCUMULATE_POINTS` | Points are added to a loyalty account for a purchase. | +| `CREATE_REWARD` | A loyalty reward is created. For more information, see
[Loyalty rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#loyalty-overview-loyalty-rewards). | +| `REDEEM_REWARD` | A loyalty reward is redeemed. | +| `DELETE_REWARD` | A loyalty reward is deleted. | +| `ADJUST_POINTS` | Loyalty points are manually adjusted. | +| `EXPIRE_POINTS` | Loyalty points are expired according to the
expiration policy of the loyalty program. | | `OTHER` | Some other loyalty event occurred. | diff --git a/doc/models/loyalty-program-accrual-rule-type.md b/doc/models/loyalty-program-accrual-rule-type.md index 5f3f9e81..5c08d7ad 100644 --- a/doc/models/loyalty-program-accrual-rule-type.md +++ b/doc/models/loyalty-program-accrual-rule-type.md @@ -12,6 +12,6 @@ The type of the accrual rule that defines how buyers can earn points. | --- | --- | | `VISIT` | A visit-based accrual rule. A buyer earns points for each visit.
You can specify the minimum purchase required. | | `SPEND` | A spend-based accrual rule. A buyer earns points based on the amount
spent. | -| `ITEMVARIATION` | An accrual rule based on an item variation. For example, accrue
points for purchasing a coffee. | +| `ITEM_VARIATION` | An accrual rule based on an item variation. For example, accrue
points for purchasing a coffee. | | `CATEGORY` | An accrual rule based on an item category. For example, accrue points
for purchasing any item in the "hot drink" category: coffee, tea, or hot cocoa. | diff --git a/doc/models/loyalty-program-reward-definition-scope.md b/doc/models/loyalty-program-reward-definition-scope.md index 9d6596cf..6c93f471 100644 --- a/doc/models/loyalty-program-reward-definition-scope.md +++ b/doc/models/loyalty-program-reward-definition-scope.md @@ -11,6 +11,6 @@ Indicates the scope of the reward tier. | Name | Description | | --- | --- | | `ORDER` | The discount applies to the entire order. | -| `ITEMVARIATION` | The discount applies only to specific item variations. | +| `ITEM_VARIATION` | The discount applies only to specific item variations. | | `CATEGORY` | The discount applies only to items in the given categories. | diff --git a/doc/models/loyalty-program-reward-definition-type.md b/doc/models/loyalty-program-reward-definition-type.md index 3fab15b6..e6b80219 100644 --- a/doc/models/loyalty-program-reward-definition-type.md +++ b/doc/models/loyalty-program-reward-definition-type.md @@ -10,6 +10,6 @@ The type of discount the reward tier offers. | Name | Description | | --- | --- | -| `FIXEDAMOUNT` | The fixed amount discounted. | -| `FIXEDPERCENTAGE` | The fixed percentage discounted. | +| `FIXED_AMOUNT` | The fixed amount discounted. | +| `FIXED_PERCENTAGE` | The fixed percentage discounted. | diff --git a/doc/models/measurement-unit-area.md b/doc/models/measurement-unit-area.md index d0e1d0fa..81b9ac47 100644 --- a/doc/models/measurement-unit-area.md +++ b/doc/models/measurement-unit-area.md @@ -10,12 +10,12 @@ Unit of area used to measure a quantity. | Name | Description | | --- | --- | -| `IMPERIALACRE` | The area is measured in acres. | -| `IMPERIALSQUAREINCH` | The area is measured in square inches. | -| `IMPERIALSQUAREFOOT` | The area is measured in square feet. | -| `IMPERIALSQUAREYARD` | The area is measured in square yards. | -| `IMPERIALSQUAREMILE` | The area is measured in square miles. | -| `METRICSQUARECENTIMETER` | The area is measured in square centimeters. | -| `METRICSQUAREMETER` | The area is measured in square meters. | -| `METRICSQUAREKILOMETER` | The area is measured in square kilometers. | +| `IMPERIAL_ACRE` | The area is measured in acres. | +| `IMPERIAL_SQUARE_INCH` | The area is measured in square inches. | +| `IMPERIAL_SQUARE_FOOT` | The area is measured in square feet. | +| `IMPERIAL_SQUARE_YARD` | The area is measured in square yards. | +| `IMPERIAL_SQUARE_MILE` | The area is measured in square miles. | +| `METRIC_SQUARE_CENTIMETER` | The area is measured in square centimeters. | +| `METRIC_SQUARE_METER` | The area is measured in square meters. | +| `METRIC_SQUARE_KILOMETER` | The area is measured in square kilometers. | diff --git a/doc/models/measurement-unit-length.md b/doc/models/measurement-unit-length.md index bb53bab8..8ef03e79 100644 --- a/doc/models/measurement-unit-length.md +++ b/doc/models/measurement-unit-length.md @@ -10,12 +10,12 @@ The unit of length used to measure a quantity. | Name | Description | | --- | --- | -| `IMPERIALINCH` | The length is measured in inches. | -| `IMPERIALFOOT` | The length is measured in feet. | -| `IMPERIALYARD` | The length is measured in yards. | -| `IMPERIALMILE` | The length is measured in miles. | -| `METRICMILLIMETER` | The length is measured in millimeters. | -| `METRICCENTIMETER` | The length is measured in centimeters. | -| `METRICMETER` | The length is measured in meters. | -| `METRICKILOMETER` | The length is measured in kilometers. | +| `IMPERIAL_INCH` | The length is measured in inches. | +| `IMPERIAL_FOOT` | The length is measured in feet. | +| `IMPERIAL_YARD` | The length is measured in yards. | +| `IMPERIAL_MILE` | The length is measured in miles. | +| `METRIC_MILLIMETER` | The length is measured in millimeters. | +| `METRIC_CENTIMETER` | The length is measured in centimeters. | +| `METRIC_METER` | The length is measured in meters. | +| `METRIC_KILOMETER` | The length is measured in kilometers. | diff --git a/doc/models/measurement-unit-time.md b/doc/models/measurement-unit-time.md index 2c08ac69..d2d7b901 100644 --- a/doc/models/measurement-unit-time.md +++ b/doc/models/measurement-unit-time.md @@ -10,9 +10,9 @@ Unit of time used to measure a quantity (a duration). | Name | Description | | --- | --- | -| `GENERICMILLISECOND` | The time is measured in milliseconds. | -| `GENERICSECOND` | The time is measured in seconds. | -| `GENERICMINUTE` | The time is measured in minutes. | -| `GENERICHOUR` | The time is measured in hours. | -| `GENERICDAY` | The time is measured in days. | +| `GENERIC_MILLISECOND` | The time is measured in milliseconds. | +| `GENERIC_SECOND` | The time is measured in seconds. | +| `GENERIC_MINUTE` | The time is measured in minutes. | +| `GENERIC_HOUR` | The time is measured in hours. | +| `GENERIC_DAY` | The time is measured in days. | diff --git a/doc/models/measurement-unit-unit-type.md b/doc/models/measurement-unit-unit-type.md index e1ecde22..f4019f49 100644 --- a/doc/models/measurement-unit-unit-type.md +++ b/doc/models/measurement-unit-unit-type.md @@ -10,10 +10,10 @@ Describes the type of this unit and indicates which field contains the unit info | Name | Description | | --- | --- | -| `TYPECUSTOM` | The unit details are contained in the custom_unit field. | -| `TYPEAREA` | The unit details are contained in the area_unit field. | -| `TYPELENGTH` | The unit details are contained in the length_unit field. | -| `TYPEVOLUME` | The unit details are contained in the volume_unit field. | -| `TYPEWEIGHT` | The unit details are contained in the weight_unit field. | -| `TYPEGENERIC` | The unit details are contained in the generic_unit field. | +| `TYPE_CUSTOM` | The unit details are contained in the custom_unit field. | +| `TYPE_AREA` | The unit details are contained in the area_unit field. | +| `TYPE_LENGTH` | The unit details are contained in the length_unit field. | +| `TYPE_VOLUME` | The unit details are contained in the volume_unit field. | +| `TYPE_WEIGHT` | The unit details are contained in the weight_unit field. | +| `TYPE_GENERIC` | The unit details are contained in the generic_unit field. | diff --git a/doc/models/measurement-unit-volume.md b/doc/models/measurement-unit-volume.md index 8b3a05b1..e1867d75 100644 --- a/doc/models/measurement-unit-volume.md +++ b/doc/models/measurement-unit-volume.md @@ -10,15 +10,15 @@ The unit of volume used to measure a quantity. | Name | Description | | --- | --- | -| `GENERICFLUIDOUNCE` | The volume is measured in ounces. | -| `GENERICSHOT` | The volume is measured in shots. | -| `GENERICCUP` | The volume is measured in cups. | -| `GENERICPINT` | The volume is measured in pints. | -| `GENERICQUART` | The volume is measured in quarts. | -| `GENERICGALLON` | The volume is measured in gallons. | -| `IMPERIALCUBICINCH` | The volume is measured in cubic inches. | -| `IMPERIALCUBICFOOT` | The volume is measured in cubic feet. | -| `IMPERIALCUBICYARD` | The volume is measured in cubic yards. | -| `METRICMILLILITER` | The volume is measured in metric milliliters. | -| `METRICLITER` | The volume is measured in metric liters. | +| `GENERIC_FLUID_OUNCE` | The volume is measured in ounces. | +| `GENERIC_SHOT` | The volume is measured in shots. | +| `GENERIC_CUP` | The volume is measured in cups. | +| `GENERIC_PINT` | The volume is measured in pints. | +| `GENERIC_QUART` | The volume is measured in quarts. | +| `GENERIC_GALLON` | The volume is measured in gallons. | +| `IMPERIAL_CUBIC_INCH` | The volume is measured in cubic inches. | +| `IMPERIAL_CUBIC_FOOT` | The volume is measured in cubic feet. | +| `IMPERIAL_CUBIC_YARD` | The volume is measured in cubic yards. | +| `METRIC_MILLILITER` | The volume is measured in metric milliliters. | +| `METRIC_LITER` | The volume is measured in metric liters. | diff --git a/doc/models/measurement-unit-weight.md b/doc/models/measurement-unit-weight.md index 2ab00a01..93a93ad1 100644 --- a/doc/models/measurement-unit-weight.md +++ b/doc/models/measurement-unit-weight.md @@ -10,10 +10,10 @@ Unit of weight used to measure a quantity. | Name | Description | | --- | --- | -| `IMPERIALWEIGHTOUNCE` | The weight is measured in ounces. | -| `IMPERIALPOUND` | The weight is measured in pounds. | -| `IMPERIALSTONE` | The weight is measured in stones. | -| `METRICMILLIGRAM` | The weight is measured in milligrams. | -| `METRICGRAM` | The weight is measured in grams. | -| `METRICKILOGRAM` | The weight is measured in kilograms. | +| `IMPERIAL_WEIGHT_OUNCE` | The weight is measured in ounces. | +| `IMPERIAL_POUND` | The weight is measured in pounds. | +| `IMPERIAL_STONE` | The weight is measured in stones. | +| `METRIC_MILLIGRAM` | The weight is measured in milligrams. | +| `METRIC_GRAM` | The weight is measured in grams. | +| `METRIC_KILOGRAM` | The weight is measured in kilograms. | diff --git a/doc/models/order-line-item-discount-scope.md b/doc/models/order-line-item-discount-scope.md index 3584bcb2..5739c0d6 100644 --- a/doc/models/order-line-item-discount-scope.md +++ b/doc/models/order-line-item-discount-scope.md @@ -10,7 +10,7 @@ Indicates whether this is a line item or order level discount. | Name | Description | | --- | --- | -| `OTHERDISCOUNTSCOPE` | Used for reporting only.
The original transaction discount scope is currently not supported by the API. | -| `LINEITEM` | The discount should be applied to only line items specified by
`OrderLineItemAppliedDiscount` reference records. | +| `OTHER_DISCOUNT_SCOPE` | Used for reporting only.
The original transaction discount scope is currently not supported by the API. | +| `LINE_ITEM` | The discount should be applied to only line items specified by
`OrderLineItemAppliedDiscount` reference records. | | `ORDER` | The discount should be applied to the entire order. | diff --git a/doc/models/order-line-item-discount-type.md b/doc/models/order-line-item-discount-type.md index 3f4eac5d..676791de 100644 --- a/doc/models/order-line-item-discount-type.md +++ b/doc/models/order-line-item-discount-type.md @@ -10,9 +10,9 @@ Indicates how the discount is applied to the associated line item or order. | Name | Description | | --- | --- | -| `UNKNOWNDISCOUNT` | Used for reporting only.
The original transaction discount type is currently not supported by the API. | -| `FIXEDPERCENTAGE` | Apply the discount as a fixed percentage (e.g., 5%) off the item price. | -| `FIXEDAMOUNT` | Apply the discount as a fixed monetary value (e.g., $1.00) off the item price. | -| `VARIABLEPERCENTAGE` | Apply the discount as a variable percentage based on the item
price.

The specific discount percentage of a `VARIABLE_PERCENTAGE` discount
is assigned at the time of the purchase. | -| `VARIABLEAMOUNT` | Apply the discount as a variable amount based on the item price.

The specific discount amount of a `VARIABLE_AMOUNT` discount
is assigned at the time of the purchase. | +| `UNKNOWN_DISCOUNT` | Used for reporting only.
The original transaction discount type is currently not supported by the API. | +| `FIXED_PERCENTAGE` | Apply the discount as a fixed percentage (e.g., 5%) off the item price. | +| `FIXED_AMOUNT` | Apply the discount as a fixed monetary value (e.g., $1.00) off the item price. | +| `VARIABLE_PERCENTAGE` | Apply the discount as a variable percentage based on the item
price.

The specific discount percentage of a `VARIABLE_PERCENTAGE` discount
is assigned at the time of the purchase. | +| `VARIABLE_AMOUNT` | Apply the discount as a variable amount based on the item price.

The specific discount amount of a `VARIABLE_AMOUNT` discount
is assigned at the time of the purchase. | diff --git a/doc/models/order-line-item-tax-scope.md b/doc/models/order-line-item-tax-scope.md index 89f93995..70724a61 100644 --- a/doc/models/order-line-item-tax-scope.md +++ b/doc/models/order-line-item-tax-scope.md @@ -10,7 +10,7 @@ Indicates whether this is a line item or order level tax. | Name | Description | | --- | --- | -| `OTHERTAXSCOPE` | Used for reporting only.
The original transaction tax scope is currently not supported by the API. | -| `LINEITEM` | The tax should be applied only to line items specified by
the `OrderLineItemAppliedTax` reference records. | +| `OTHER_TAX_SCOPE` | Used for reporting only.
The original transaction tax scope is currently not supported by the API. | +| `LINE_ITEM` | The tax should be applied only to line items specified by
the `OrderLineItemAppliedTax` reference records. | | `ORDER` | The tax should be applied to the entire order. | diff --git a/doc/models/order-line-item-tax-type.md b/doc/models/order-line-item-tax-type.md index 8f09332e..06a243be 100644 --- a/doc/models/order-line-item-tax-type.md +++ b/doc/models/order-line-item-tax-type.md @@ -10,7 +10,7 @@ Indicates how the tax is applied to the associated line item or order. | Name | Description | | --- | --- | -| `UNKNOWNTAX` | Used for reporting only.
The original transaction tax type is currently not supported by the API. | +| `UNKNOWN_TAX` | Used for reporting only.
The original transaction tax type is currently not supported by the API. | | `ADDITIVE` | The tax is an additive tax. The tax amount is added on top of the price.
For example, an item with a cost of 1.00 USD and a 10% additive tax would have a total
cost to the buyer of 1.10 USD. | | `INCLUSIVE` | The tax is an inclusive tax. Inclusive taxes are already included
in the line item price or order total. For example, an item with cost
1.00 USD with a 10% inclusive tax would have a pre-tax cost of 0.91 USD
(91 cents) and a 0.09 (9 cents) tax for a total cost of 1.00 USD to
the buyer. | diff --git a/doc/models/order-service-charge-calculation-phase.md b/doc/models/order-service-charge-calculation-phase.md index f424613a..43c610d0 100644 --- a/doc/models/order-service-charge-calculation-phase.md +++ b/doc/models/order-service-charge-calculation-phase.md @@ -13,6 +13,6 @@ Service charges are applied __after__ the indicated phase. | Name | Description | | --- | --- | -| `SUBTOTALPHASE` | The service charge will be applied after discounts, but before
taxes. | -| `TOTALPHASE` | The service charge will be applied after all discounts and taxes
are applied. | +| `SUBTOTAL_PHASE` | The service charge will be applied after discounts, but before
taxes. | +| `TOTAL_PHASE` | The service charge will be applied after all discounts and taxes
are applied. | diff --git a/doc/models/product-type.md b/doc/models/product-type.md index f13428a1..5074e5bd 100644 --- a/doc/models/product-type.md +++ b/doc/models/product-type.md @@ -8,5 +8,5 @@ | Name | | --- | -| `TERMINALAPI` | +| `TERMINAL_API` | diff --git a/doc/models/product.md b/doc/models/product.md index 1d1f296f..cb7c6010 100644 --- a/doc/models/product.md +++ b/doc/models/product.md @@ -10,14 +10,14 @@ Indicates the Square product used to generate an inventory change. | Name | Description | | --- | --- | -| `SQUAREPOS` | Square Point of Sale application. | -| `EXTERNALAPI` | Square Connect APIs (Transactions API, Checkout API). | +| `SQUARE_POS` | Square Point of Sale application. | +| `EXTERNAL_API` | Square Connect APIs (Transactions API, Checkout API). | | `BILLING` | A Square subscription (various products). | | `APPOINTMENTS` | Square Appointments. | | `INVOICES` | Square Invoices. | -| `ONLINESTORE` | Square Online Store. | +| `ONLINE_STORE` | Square Online Store. | | `PAYROLL` | Square Payroll. | | `DASHBOARD` | Square Dashboard | -| `ITEMLIBRARYIMPORT` | Item Library Import | +| `ITEM_LIBRARY_IMPORT` | Item Library Import | | `OTHER` | A Square product that does not match any other value. | diff --git a/doc/models/retrieve-subscription-response.md b/doc/models/retrieve-subscription-response.md new file mode 100644 index 00000000..23f9374a --- /dev/null +++ b/doc/models/retrieve-subscription-response.md @@ -0,0 +1,43 @@ +## Retrieve Subscription Response + +Defines the fields that are included in the response from the +[RetrieveSubscription](#endpoint-subscriptions-retrievesubscription) endpoint. + +### Structure + +`RetrieveSubscriptionResponse` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Errors` | [`List`](/doc/models/error.md) | Optional | Information about errors encountered during the request. | +| `Subscription` | [`Subscription`](/doc/models/subscription.md) | Optional | Represents a customer subscription to a subscription plan.
For an overview of the `Subscription` type, see
[Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). | + +### Example (as JSON) + +```json +{ + "subscription": { + "id": "8151fc89-da15-4eb9-a685-1a70883cebfc", + "location_id": "S8GWD5R9QB376", + "plan_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2020-05-11", + "charged_through_date": "2020-06-11", + "status": "ACTIVE", + "invoice_ids": [ + "grebK0Q_l8H4fqoMMVvt-Q", + "rcX_i3sNmHTGKhI4W2mceA" + ], + "price_override_money": { + "amount": 1000, + "currency": "USD" + }, + "created_at": "2020-08-03T21:53:10Z", + "paid_until_date": "2020-06-11", + "timezone": "America/Los_Angeles" + } +} +``` + diff --git a/doc/models/search-orders-sort-field.md b/doc/models/search-orders-sort-field.md index 2f9f5c5f..9939fa9f 100644 --- a/doc/models/search-orders-sort-field.md +++ b/doc/models/search-orders-sort-field.md @@ -10,7 +10,7 @@ Specifies which timestamp to use to sort SearchOrder results. | Name | Description | | --- | --- | -| `CREATEDAT` | Time when the order was created in RFC-3339 format. If you are also
filtering for a time range in this query, you must set the `CREATED_AT`
field in your DateTimeFilter. | -| `UPDATEDAT` | Time when the order last updated in RFC-3339 format. If you are also
filtering for a time range in this query, you must set the `UPDATED_AT`
field in your DateTimeFilter. | -| `CLOSEDAT` | Time when the order was closed in RFC-3339 format. If you use this
value, you must also set a StateFilter with closed states. If you are also
filtering for a time range in this query, you must set the `CLOSED_AT`
field in your DateTimeFilter. | +| `CREATED_AT` | Time when the order was created in RFC-3339 format. If you are also
filtering for a time range in this query, you must set the `CREATED_AT`
field in your DateTimeFilter. | +| `UPDATED_AT` | Time when the order last updated in RFC-3339 format. If you are also
filtering for a time range in this query, you must set the `UPDATED_AT`
field in your DateTimeFilter. | +| `CLOSED_AT` | Time when the order was closed in RFC-3339 format. If you use this
value, you must also set a StateFilter with closed states. If you are also
filtering for a time range in this query, you must set the `CLOSED_AT`
field in your DateTimeFilter. | diff --git a/doc/models/search-subscriptions-filter.md b/doc/models/search-subscriptions-filter.md new file mode 100644 index 00000000..b9a89861 --- /dev/null +++ b/doc/models/search-subscriptions-filter.md @@ -0,0 +1,24 @@ +## Search Subscriptions Filter + +Represents a set of SearchSubscriptionsQuery filters used to limit the set of Subscriptions returned by SearchSubscriptions. + +### Structure + +`SearchSubscriptionsFilter` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `CustomerIds` | `List` | Optional | A filter to select subscriptions based on the customer. | +| `LocationIds` | `List` | Optional | A filter to select subscriptions based the location. | + +### Example (as JSON) + +```json +{ + "customer_ids": null, + "location_ids": null +} +``` + diff --git a/doc/models/search-subscriptions-query.md b/doc/models/search-subscriptions-query.md new file mode 100644 index 00000000..fc0f1f91 --- /dev/null +++ b/doc/models/search-subscriptions-query.md @@ -0,0 +1,22 @@ +## Search Subscriptions Query + +Represents a query (including filtering criteria) used to search for subscriptions. + +### Structure + +`SearchSubscriptionsQuery` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Filter` | [`SearchSubscriptionsFilter`](/doc/models/search-subscriptions-filter.md) | Optional | Represents a set of SearchSubscriptionsQuery filters used to limit the set of Subscriptions returned by SearchSubscriptions. | + +### Example (as JSON) + +```json +{ + "filter": null +} +``` + diff --git a/doc/models/search-subscriptions-request.md b/doc/models/search-subscriptions-request.md new file mode 100644 index 00000000..fcbb874a --- /dev/null +++ b/doc/models/search-subscriptions-request.md @@ -0,0 +1,35 @@ +## Search Subscriptions Request + +Defines parameters in a +[SearchSubscriptions](#endpoint-subscriptions-searchsubscriptions) endpoint +request. + +### Structure + +`SearchSubscriptionsRequest` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Cursor` | `String` | Optional | A pagination cursor returned by a previous call to this endpoint.
Provide this to retrieve the next set of results for the original query.

For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). | +| `Limit` | `Integer` | Optional | The upper limit on the number of subscriptions to return
in the response.

Default: `200` | +| `Query` | [`SearchSubscriptionsQuery`](/doc/models/search-subscriptions-query.md) | Optional | Represents a query (including filtering criteria) used to search for subscriptions. | + +### Example (as JSON) + +```json +{ + "query": { + "filter": { + "location_ids": [ + "S8GWD5R9QB376" + ], + "customer_ids": [ + "CHFGVKYY8RSV93M5KCYTG4PN0G" + ] + } + } +} +``` + diff --git a/doc/models/search-subscriptions-response.md b/doc/models/search-subscriptions-response.md new file mode 100644 index 00000000..2ffe4bd9 --- /dev/null +++ b/doc/models/search-subscriptions-response.md @@ -0,0 +1,76 @@ +## Search Subscriptions Response + +Defines the fields that are included in the response from the +[SearchSubscriptions](#endpoint-subscriptions-searchsubscriptions) endpoint. + +### Structure + +`SearchSubscriptionsResponse` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Errors` | [`List`](/doc/models/error.md) | Optional | Information about errors encountered during the request. | +| `Subscriptions` | [`List`](/doc/models/subscription.md) | Optional | The search result. | +| `Cursor` | `String` | Optional | When a response is truncated, it includes a cursor that you can
use in a subsequent request to fetch the next set of subscriptions.
If empty, this is the final response.

For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). | + +### Example (as JSON) + +```json +{ + "subscriptions": [ + { + "id": "de86fc96-8664-474b-af1a-abbe59cacf0e", + "location_id": "S8GWD5R9QB376", + "plan_id": "L3TJVDHVBEQEGQDEZL2JJM7R", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2020-04-14", + "canceled_date": "2020-04-14", + "charged_through_date": "2020-05-14", + "status": "CANCELED", + "created_at": "2020-08-03T21:53:10Z", + "card_id": "ccof:mueUsvgajChmjEbp4GB", + "paid_until_date": "2020-05-14", + "timezone": "UTC" + }, + { + "id": "56214fb2-cc85-47a1-93bc-44f3766bb56f", + "location_id": "S8GWD5R9QB376", + "plan_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2020-08-01", + "status": "PENDING", + "tax_percentage": "5", + "price_override_money": { + "amount": 100, + "currency": "USD" + }, + "version": 1594155459464, + "created_at": "2020-08-03T21:53:10Z", + "timezone": "America/Los_Angeles" + }, + { + "id": "8151fc89-da15-4eb9-a685-1a70883cebfc", + "location_id": "S8GWD5R9QB376", + "plan_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2020-05-11", + "charged_through_date": "2020-06-11", + "status": "ACTIVE", + "invoice_ids": [ + "grebK0Q_l8H4fqoMMVvt-Q", + "rcX_i3sNmHTGKhI4W2mceA" + ], + "price_override_money": { + "amount": 1000, + "currency": "USD" + }, + "created_at": "2020-08-03T21:53:10Z", + "paid_until_date": "2020-06-11", + "timezone": "America/Los_Angeles" + } + ] +} +``` + diff --git a/doc/models/shift-sort-field.md b/doc/models/shift-sort-field.md index a0e1434c..47193b65 100644 --- a/doc/models/shift-sort-field.md +++ b/doc/models/shift-sort-field.md @@ -10,8 +10,8 @@ Enumerates the `Shift` fields to sort on. | Name | Description | | --- | --- | -| `STARTAT` | The start date/time of a `Shift` | -| `ENDAT` | The end date/time of a `Shift` | -| `CREATEDAT` | The date/time that a `Shift` is created | -| `UPDATEDAT` | The most recent date/time that a `Shift` is updated | +| `START_AT` | The start date/time of a `Shift` | +| `END_AT` | The end date/time of a `Shift` | +| `CREATED_AT` | The date/time that a `Shift` is created | +| `UPDATED_AT` | The most recent date/time that a `Shift` is updated | diff --git a/doc/models/shift-workday-matcher.md b/doc/models/shift-workday-matcher.md index fb13cbaa..caad6e27 100644 --- a/doc/models/shift-workday-matcher.md +++ b/doc/models/shift-workday-matcher.md @@ -10,7 +10,7 @@ Defines the logic used to apply a workday filter. | Name | Description | | --- | --- | -| `STARTAT` | All shifts that start on or after the specified workday | -| `ENDAT` | All shifts that end on or before the specified workday | +| `START_AT` | All shifts that start on or after the specified workday | +| `END_AT` | All shifts that end on or before the specified workday | | `INTERSECTION` | All shifts that start between the start and end workdays (inclusive) | diff --git a/doc/models/subscription-cadence.md b/doc/models/subscription-cadence.md new file mode 100644 index 00000000..df65f233 --- /dev/null +++ b/doc/models/subscription-cadence.md @@ -0,0 +1,26 @@ +## Subscription Cadence + +Determines the billing cadence of a [Subscription](#type-Subscription) + +### Enumeration + +`SubscriptionCadence` + +### Fields + +| Name | Description | +| --- | --- | +| `DAILY` | Once per day | +| `WEEKLY` | Once per week | +| `EVERY_TWO_WEEKS` | Every two weeks | +| `THIRTY_DAYS` | Once every 30 days | +| `SIXTY_DAYS` | Once every 60 days | +| `NINETY_DAYS` | Once every 90 days | +| `MONTHLY` | Once per month | +| `EVERY_TWO_MONTHS` | Once every two months | +| `QUARTERLY` | Once every three months | +| `EVERY_FOUR_MONTHS` | Once every four months | +| `EVERY_SIX_MONTHS` | Once every six months | +| `ANNUAL` | Once per year | +| `EVERY_TWO_YEARS` | Once every two years | + diff --git a/doc/models/subscription-event-subscription-event-type.md b/doc/models/subscription-event-subscription-event-type.md new file mode 100644 index 00000000..5eecc204 --- /dev/null +++ b/doc/models/subscription-event-subscription-event-type.md @@ -0,0 +1,16 @@ +## Subscription Event Subscription Event Type + +The possible subscription event types. + +### Enumeration + +`SubscriptionEventSubscriptionEventType` + +### Fields + +| Name | Description | +| --- | --- | +| `START_SUBSCRIPTION` | The subscription started. | +| `PLAN_CHANGE` | The subscription plan changed. | +| `STOP_SUBSCRIPTION` | The subscription stopped. | + diff --git a/doc/models/subscription-event.md b/doc/models/subscription-event.md new file mode 100644 index 00000000..78175543 --- /dev/null +++ b/doc/models/subscription-event.md @@ -0,0 +1,28 @@ +## Subscription Event + +Describes changes to subscription and billing states. + +### Structure + +`SubscriptionEvent` + +### Fields + +| Name | Type | Description | +| --- | --- | --- | +| `Id` | `String` | The ID of the subscription event. | +| `SubscriptionEventType` | [`String`](/doc/models/subscription-event-subscription-event-type.md) | The possible subscription event types. | +| `EffectiveDate` | `String` | The date, in YYYY-MM-DD format (for
example, 2013-01-15), when the subscription event went into effect. | +| `PlanId` | `String` | The ID of the subscription plan associated with the subscription. | + +### Example (as JSON) + +```json +{ + "id": "id0", + "subscription_event_type": "PLAN_CHANGE", + "effective_date": "effective_date0", + "plan_id": "plan_id8" +} +``` + diff --git a/doc/models/subscription-phase.md b/doc/models/subscription-phase.md new file mode 100644 index 00000000..5dfe47a7 --- /dev/null +++ b/doc/models/subscription-phase.md @@ -0,0 +1,34 @@ +## Subscription Phase + +Describes a phase in a subscription plan. For more information, see +[Set Up and Manage a Subscription Plan](https://developer.squareup.com/docs/docs/subscriptions-api/setup-plan). + +### Structure + +`SubscriptionPhase` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Uid` | `String` | Optional | The Square-assigned ID of the subscription phase. | +| `Cadence` | [`String`](/doc/models/subscription-cadence.md) | | Determines the billing cadence of a [Subscription](#type-Subscription) | +| `Periods` | `Integer` | Optional | The number of `cadence`s the phase lasts. If not set, the phase never ends. Only the last phase can be indefinite. | +| `RecurringPriceMoney` | [`Money`](/doc/models/money.md) | | Represents an amount of money. `Money` fields can be signed or unsigned.
Fields that do not explicitly define whether they are signed or unsigned are
considered unsigned and can only hold positive amounts. For signed fields, the
sign of the value indicates the purpose of the money transfer. See
[Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts)
for more information. | +| `Ordinal` | `Long` | Optional | The position this phase appears in the sequence of phases defined for the plan, indexed from 0. | + +### Example (as JSON) + +```json +{ + "uid": null, + "cadence": "DAILY", + "periods": null, + "recurring_price_money": { + "amount": null, + "currency": null + }, + "ordinal": null +} +``` + diff --git a/doc/models/subscription-status.md b/doc/models/subscription-status.md new file mode 100644 index 00000000..50eeeace --- /dev/null +++ b/doc/models/subscription-status.md @@ -0,0 +1,17 @@ +## Subscription Status + +Possible subscription status values. + +### Enumeration + +`SubscriptionStatus` + +### Fields + +| Name | Description | +| --- | --- | +| `DEFAULT_SUBSCRIPTION_STATUS_DO_NOT_USE` | | +| `PENDING` | The subscription starts in the future. | +| `ACTIVE` | The subscription is active. | +| `CANCELED` | The subscription is canceled. | + diff --git a/doc/models/subscription.md b/doc/models/subscription.md new file mode 100644 index 00000000..dd023b24 --- /dev/null +++ b/doc/models/subscription.md @@ -0,0 +1,52 @@ +## Subscription + +Represents a customer subscription to a subscription plan. +For an overview of the `Subscription` type, see +[Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). + +### Structure + +`Subscription` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `String` | Optional | The Square-assigned ID of the subscription. | +| `LocationId` | `String` | Optional | The ID of the location associated with the subscription. | +| `PlanId` | `String` | Optional | The ID of the associated [subscription plan](#type-catalogsubscriptionplan). | +| `CustomerId` | `String` | Optional | The ID of the associated [customer](#type-customer) profile. | +| `StartDate` | `String` | Optional | The start date of the subscription, in YYYY-MM-DD format (for example,
2013-01-15). | +| `CanceledDate` | `String` | Optional | The subscription cancellation date, in YYYY-MM-DD format (for
example, 2013-01-15). On this date, the subscription status changes
to `CANCELED` and the subscription billing stops.
If you don't set this field, the subscription plan dictates if and
when subscription ends.

You cannot update this field, you can only clear it. | +| `Status` | [`String`](/doc/models/subscription-status.md) | Optional | Possible subscription status values. | +| `TaxPercentage` | `String` | Optional | The tax amount applied when billing the subscription. The
percentage is expressed in decimal form, using a `'.'` as the decimal
separator and without a `'%'` sign. For example, a value of `7.5`
corresponds to 7.5%. | +| `InvoiceIds` | `List` | Optional | The IDs of the [invoices](#type-invoice) created for the
subscription, listed in order when the invoices were created
(oldest invoices appear first). | +| `PriceOverrideMoney` | [`Money`](/doc/models/money.md) | Optional | Represents an amount of money. `Money` fields can be signed or unsigned.
Fields that do not explicitly define whether they are signed or unsigned are
considered unsigned and can only hold positive amounts. For signed fields, the
sign of the value indicates the purpose of the money transfer. See
[Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts)
for more information. | +| `Version` | `Long` | Optional | The version of the object. When updating an object, the version
supplied must match the version in the database, otherwise the write will
be rejected as conflicting. | +| `CreatedAt` | `String` | Optional | The timestamp when the subscription was created, in RFC 3339 format. | +| `CardId` | `String` | Optional | The ID of the [customer](#type-customer) [card](#type-card)
that is charged for the subscription. | +| `PaidUntilDate` | `String` | Optional | The date up to which the customer is invoiced for the
subscription, in YYYY-MM-DD format (for example, 2013-01-15).

After the invoice is paid for a given billing period,
this date will be the last day of the billing period.
For example,
suppose for the month of May a customer gets an invoice
(or charged the card) on May 1. For the monthly billing scenario,
this date is then set to May 31. | +| `Timezone` | `String` | Optional | Timezone that will be used in date calculations for the subscription.
Defaults to the timezone of the location based on `location_id`.
Format: the IANA Timezone Database identifier for the location timezone (for example, `America/Los_Angeles`). | + +### Example (as JSON) + +```json +{ + "id": null, + "location_id": null, + "plan_id": null, + "customer_id": null, + "start_date": null, + "canceled_date": null, + "status": null, + "tax_percentage": null, + "invoice_ids": null, + "price_override_money": null, + "version": null, + "created_at": null, + "card_id": null, + "paid_until_date": null, + "timezone": null +} +``` + diff --git a/doc/models/tax-calculation-phase.md b/doc/models/tax-calculation-phase.md index eee6c87c..727deb36 100644 --- a/doc/models/tax-calculation-phase.md +++ b/doc/models/tax-calculation-phase.md @@ -10,6 +10,6 @@ When to calculate the taxes due on a cart. | Name | Description | | --- | --- | -| `TAXSUBTOTALPHASE` | The fee is calculated based on the payment's subtotal. | -| `TAXTOTALPHASE` | The fee is calculated based on the payment's total. | +| `TAX_SUBTOTAL_PHASE` | The fee is calculated based on the payment's subtotal. | +| `TAX_TOTAL_PHASE` | The fee is calculated based on the payment's total. | diff --git a/doc/models/team-member-assigned-locations-assignment-type.md b/doc/models/team-member-assigned-locations-assignment-type.md index 5d7f644d..47521e8f 100644 --- a/doc/models/team-member-assigned-locations-assignment-type.md +++ b/doc/models/team-member-assigned-locations-assignment-type.md @@ -10,6 +10,6 @@ Enumerates the possible assignment types the team member can have | Name | Description | | --- | --- | -| `ALLCURRENTANDFUTURELOCATIONS` | The team member is assigned to all curent and future locations - the location_ids field
is empty if the team member has this assignment type. | -| `EXPLICITLOCATIONS` | The team member is assigned to an explicit subset of locations - the location_ids field
is the list of locations that the team member is assigned to. | +| `ALL_CURRENT_AND_FUTURE_LOCATIONS` | The team member is assigned to all curent and future locations - the location_ids field
is empty if the team member has this assignment type. | +| `EXPLICIT_LOCATIONS` | The team member is assigned to an explicit subset of locations - the location_ids field
is the list of locations that the team member is assigned to. | diff --git a/doc/models/tender-card-details-entry-method.md b/doc/models/tender-card-details-entry-method.md index 52ffac5b..9a01a37a 100644 --- a/doc/models/tender-card-details-entry-method.md +++ b/doc/models/tender-card-details-entry-method.md @@ -13,6 +13,6 @@ Indicates the method used to enter the card's details. | `SWIPED` | The card was swiped through a Square reader or Square stand. | | `KEYED` | The card information was keyed manually into Square Point of Sale or a
Square-hosted web form. | | `EMV` | The card was processed via EMV with a Square reader. | -| `ONFILE` | The buyer's card details were already on file with Square. | +| `ON_FILE` | The buyer's card details were already on file with Square. | | `CONTACTLESS` | The card was processed via a contactless (i.e., NFC) transaction
with a Square reader. | diff --git a/doc/models/tender-type.md b/doc/models/tender-type.md index 9f69d817..a395b5d2 100644 --- a/doc/models/tender-type.md +++ b/doc/models/tender-type.md @@ -12,8 +12,8 @@ Indicates a tender's type. | --- | --- | | `CARD` | A credit card. | | `CASH` | Cash. | -| `THIRDPARTYCARD` | A credit card processed with a card processor other than Square.

This value applies only to merchants in countries where Square does not
yet provide card processing. | -| `SQUAREGIFTCARD` | A Square gift card. | -| `NOSALE` | This tender represents the register being opened for a "no sale" event. | +| `THIRD_PARTY_CARD` | A credit card processed with a card processor other than Square.

This value applies only to merchants in countries where Square does not
yet provide card processing. | +| `SQUARE_GIFT_CARD` | A Square gift card. | +| `NO_SALE` | This tender represents the register being opened for a "no sale" event. | | `OTHER` | A form of tender that does not match any other value. | diff --git a/doc/models/transaction-product.md b/doc/models/transaction-product.md index 23d72d45..58ed209f 100644 --- a/doc/models/transaction-product.md +++ b/doc/models/transaction-product.md @@ -11,11 +11,11 @@ Indicates the Square product used to process a transaction. | Name | Description | | --- | --- | | `REGISTER` | Square Point of Sale. | -| `EXTERNALAPI` | The Square Connect API. | +| `EXTERNAL_API` | The Square Connect API. | | `BILLING` | A Square subscription for one of multiple products. | | `APPOINTMENTS` | Square Appointments. | | `INVOICES` | Square Invoices. | -| `ONLINESTORE` | Square Online Store. | +| `ONLINE_STORE` | Square Online Store. | | `PAYROLL` | Square Payroll. | | `OTHER` | A Square product that does not match any other value. | diff --git a/doc/models/update-subscription-request.md b/doc/models/update-subscription-request.md new file mode 100644 index 00000000..7b5f18a9 --- /dev/null +++ b/doc/models/update-subscription-request.md @@ -0,0 +1,30 @@ +## Update Subscription Request + +Defines parameters in a +[UpdateSubscription](#endpoint-subscriptions-updatesubscription) endpoint +request. + +### Structure + +`UpdateSubscriptionRequest` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Subscription` | [`Subscription`](/doc/models/subscription.md) | Optional | Represents a customer subscription to a subscription plan.
For an overview of the `Subscription` type, see
[Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). | + +### Example (as JSON) + +```json +{ + "subscription": { + "version": 1594155459464, + "price_override_money": { + "amount": 2000, + "currency": "USD" + } + } +} +``` + diff --git a/doc/models/update-subscription-response.md b/doc/models/update-subscription-response.md new file mode 100644 index 00000000..e0fdeeda --- /dev/null +++ b/doc/models/update-subscription-response.md @@ -0,0 +1,37 @@ +## Update Subscription Response + +Defines the fields that are included in the response from the +[UpdateSubscription](#endpoint-subscriptions-updatesubscription) endpoint. + +### Structure + +`UpdateSubscriptionResponse` + +### Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Errors` | [`List`](/doc/models/error.md) | Optional | Information about errors encountered during the request. | +| `Subscription` | [`Subscription`](/doc/models/subscription.md) | Optional | Represents a customer subscription to a subscription plan.
For an overview of the `Subscription` type, see
[Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). | + +### Example (as JSON) + +```json +{ + "subscription": { + "id": "9ba40961-995a-4a3d-8c53-048c40cafc13", + "location_id": "S8GWD5R9QB376", + "plan_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "status": "ACTIVE", + "price_override_money": { + "amount": 2000, + "currency": "USD" + }, + "version": 1594311617331, + "created_at": "2020-08-03T21:53:10Z", + "timezone": "America/Los_Angeles" + } +} +``` + diff --git a/doc/models/v1-adjust-inventory-request-adjustment-type.md b/doc/models/v1-adjust-inventory-request-adjustment-type.md index 6e24ffca..c8391737 100644 --- a/doc/models/v1-adjust-inventory-request-adjustment-type.md +++ b/doc/models/v1-adjust-inventory-request-adjustment-type.md @@ -9,6 +9,6 @@ | Name | | --- | | `SALE` | -| `RECEIVESTOCK` | -| `MANUALADJUST` | +| `RECEIVE_STOCK` | +| `MANUAL_ADJUST` | diff --git a/doc/models/v1-bank-account-type.md b/doc/models/v1-bank-account-type.md index fc6d23d5..ddc51322 100644 --- a/doc/models/v1-bank-account-type.md +++ b/doc/models/v1-bank-account-type.md @@ -8,7 +8,7 @@ | Name | | --- | -| `BUSINESSCHECKING` | +| `BUSINESS_CHECKING` | | `CHECKING` | | `INVESTMENT` | | `LOAN` | diff --git a/doc/models/v1-cash-drawer-event-event-type.md b/doc/models/v1-cash-drawer-event-event-type.md index 8d4e9cb3..67757f1f 100644 --- a/doc/models/v1-cash-drawer-event-event-type.md +++ b/doc/models/v1-cash-drawer-event-event-type.md @@ -8,13 +8,13 @@ | Name | | --- | -| `NOSALE` | -| `CASHTENDERPAYMENT` | -| `OTHERTENDERPAYMENT` | -| `CASHTENDERCANCELEDPAYMENT` | -| `OTHERTENDERCANCELEDPAYMENT` | -| `CASHTENDERREFUND` | -| `OTHERTENDERREFUND` | -| `PAIDIN` | -| `PAIDOUT` | +| `NO_SALE` | +| `CASH_TENDER_PAYMENT` | +| `OTHER_TENDER_PAYMENT` | +| `CASH_TENDER_CANCELED_PAYMENT` | +| `OTHER_TENDER_CANCELED_PAYMENT` | +| `CASH_TENDER_REFUND` | +| `OTHER_TENDER_REFUND` | +| `PAID_IN` | +| `PAID_OUT` | diff --git a/doc/models/v1-discount-color.md b/doc/models/v1-discount-color.md index 25fc5e2d..c1f3c09d 100644 --- a/doc/models/v1-discount-color.md +++ b/doc/models/v1-discount-color.md @@ -8,13 +8,13 @@ | Name | | --- | -| `Enum9da2a6` | -| `Enum4ab200` | -| `Enum0b8000` | -| `Enum2952cc` | -| `A82ee5` | -| `E5457a` | -| `B21212` | -| `Enum593c00` | -| `E5BF00` | +| `9da2a6` | +| `4ab200` | +| `0b8000` | +| `2952cc` | +| `a82ee5` | +| `e5457a` | +| `b21212` | +| `593c00` | +| `e5BF00` | diff --git a/doc/models/v1-discount-discount-type.md b/doc/models/v1-discount-discount-type.md index d1da1da0..bd368a77 100644 --- a/doc/models/v1-discount-discount-type.md +++ b/doc/models/v1-discount-discount-type.md @@ -9,6 +9,6 @@ | Name | | --- | | `FIXED` | -| `VARIABLEPERCENTAGE` | -| `VARIABLEAMOUNT` | +| `VARIABLE_PERCENTAGE` | +| `VARIABLE_AMOUNT` | diff --git a/doc/models/v1-employee-role-permissions.md b/doc/models/v1-employee-role-permissions.md index 401645e3..23a16da0 100644 --- a/doc/models/v1-employee-role-permissions.md +++ b/doc/models/v1-employee-role-permissions.md @@ -8,11 +8,11 @@ | Name | | --- | -| `REGISTERACCESSSALESHISTORY` | -| `REGISTERAPPLYRESTRICTEDDISCOUNTS` | -| `REGISTERCHANGESETTINGS` | -| `REGISTEREDITITEM` | -| `REGISTERISSUEREFUNDS` | -| `REGISTEROPENCASHDRAWEROUTSIDESALE` | -| `REGISTERVIEWSUMMARYREPORTS` | +| `REGISTER_ACCESS_SALES_HISTORY` | +| `REGISTER_APPLY_RESTRICTED_DISCOUNTS` | +| `REGISTER_CHANGE_SETTINGS` | +| `REGISTER_EDIT_ITEM` | +| `REGISTER_ISSUE_REFUNDS` | +| `REGISTER_OPEN_CASH_DRAWER_OUTSIDE_SALE` | +| `REGISTER_VIEW_SUMMARY_REPORTS` | diff --git a/doc/models/v1-fee-calculation-phase.md b/doc/models/v1-fee-calculation-phase.md index 7ff11af6..9d72d7e3 100644 --- a/doc/models/v1-fee-calculation-phase.md +++ b/doc/models/v1-fee-calculation-phase.md @@ -8,7 +8,7 @@ | Name | | --- | -| `FEESUBTOTALPHASE` | +| `FEE_SUBTOTAL_PHASE` | | `OTHER` | -| `FEETOTALPHASE` | +| `FEE_TOTAL_PHASE` | diff --git a/doc/models/v1-fee-type.md b/doc/models/v1-fee-type.md index c7ff11fd..e4945f2a 100644 --- a/doc/models/v1-fee-type.md +++ b/doc/models/v1-fee-type.md @@ -8,12 +8,12 @@ | Name | | --- | -| `CAGST` | -| `CAHST` | -| `CAPST` | -| `CAQST` | -| `JPCONSUMPTIONTAX` | -| `CAPEIPST` | -| `USSALESTAX` | +| `CA_GST` | +| `CA_HST` | +| `CA_PST` | +| `CA_QST` | +| `JP_CONSUMPTION_TAX` | +| `CA_PEI_PST` | +| `US_SALES_TAX` | | `OTHER` | diff --git a/doc/models/v1-item-color.md b/doc/models/v1-item-color.md index 33238af9..5c063509 100644 --- a/doc/models/v1-item-color.md +++ b/doc/models/v1-item-color.md @@ -8,13 +8,13 @@ | Name | | --- | -| `Enum9da2a6` | -| `Enum4ab200` | -| `Enum0b8000` | -| `Enum2952cc` | -| `A82ee5` | -| `E5457a` | -| `B21212` | -| `Enum593c00` | -| `E5BF00` | +| `9da2a6` | +| `4ab200` | +| `0b8000` | +| `2952cc` | +| `a82ee5` | +| `e5457a` | +| `b21212` | +| `593c00` | +| `e5BF00` | diff --git a/doc/models/v1-item-type.md b/doc/models/v1-item-type.md index 65b0253f..8387be30 100644 --- a/doc/models/v1-item-type.md +++ b/doc/models/v1-item-type.md @@ -9,6 +9,6 @@ | Name | | --- | | `NORMAL` | -| `GIFTCARD` | +| `GIFT_CARD` | | `OTHER` | diff --git a/doc/models/v1-merchant-business-type.md b/doc/models/v1-merchant-business-type.md index 2b69f86d..744cdee0 100644 --- a/doc/models/v1-merchant-business-type.md +++ b/doc/models/v1-merchant-business-type.md @@ -9,53 +9,53 @@ | Name | | --- | | `ACCOUNTING` | -| `APPARELANDACCESSORYSHOPS` | -| `ARTDEALERSGALLERIES` | -| `ARTDESIGNANDPHOTOGRAPHY` | -| `BARCLUBLOUNGE` | -| `BEAUTYANDBARBERSHOPS` | -| `BOOKSTORES` | -| `BUSINESSSERVICES` | +| `APPAREL_AND_ACCESSORY_SHOPS` | +| `ART_DEALERS_GALLERIES` | +| `ART_DESIGN_AND_PHOTOGRAPHY` | +| `BAR_CLUB_LOUNGE` | +| `BEAUTY_AND_BARBER_SHOPS` | +| `BOOK_STORES` | +| `BUSINESS_SERVICES` | | `CATERING` | -| `CHARITABLESOCIALSERVICEORGANIZATIONS` | -| `CHARITIBLEORGS` | -| `CLEANINGSERVICES` | -| `COMPUTEREQUIPMENTSOFTWAREMAINTENANCEREPAIRSERVICES` | +| `CHARITABLE_SOCIAL_SERVICE_ORGANIZATIONS` | +| `CHARITIBLE_ORGS` | +| `CLEANING_SERVICES` | +| `COMPUTER_EQUIPMENT_SOFTWARE_MAINTENANCE_REPAIR_SERVICES` | | `CONSULTANT` | | `CONTRACTORS` | -| `DELIVERYSERVICES` | +| `DELIVERY_SERVICES` | | `DENTISTRY` | | `EDUCATION` | -| `FOODSTORESCONVENIENCESTORESANDSPECIALTYMARKETS` | -| `FOODTRUCKCART` | -| `FURNITUREHOMEANDOFFICEEQUIPMENT` | -| `FURNITUREHOMEGOODS` | -| `HOTELSANDLODGING` | -| `INDIVIDUALUSE` | -| `JEWELRYANDWATCHES` | -| `LANDSCAPINGANDHORTICULTURALSERVICES` | -| `LANGUAGESCHOOLS` | -| `LEGALSERVICES` | -| `MEDICALPRACTITIONERS` | -| `MEDICALSERVICESANDHEALTHPRACTITIONERS` | -| `MEMBERSHIPORGANIZATIONS` | -| `MUSICANDENTERTAINMENT` | +| `FOOD_STORES_CONVENIENCE_STORES_AND_SPECIALTY_MARKETS` | +| `FOOD_TRUCK_CART` | +| `FURNITURE_HOME_AND_OFFICE_EQUIPMENT` | +| `FURNITURE_HOME_GOODS` | +| `HOTELS_AND_LODGING` | +| `INDIVIDUAL_USE` | +| `JEWELRY_AND_WATCHES` | +| `LANDSCAPING_AND_HORTICULTURAL_SERVICES` | +| `LANGUAGE_SCHOOLS` | +| `LEGAL_SERVICES` | +| `MEDICAL_PRACTITIONERS` | +| `MEDICAL_SERVICES_AND_HEALTH_PRACTITIONERS` | +| `MEMBERSHIP_ORGANIZATIONS` | +| `MUSIC_AND_ENTERTAINMENT` | | `OTHER` | -| `OUTDOORMARKETS` | -| `PERSONALSERVICES` | -| `POLITICALORGANIZATIONS` | -| `PROFESSIONALSERVICES` | -| `REALESTATE` | -| `RECREATIONSERVICES` | -| `REPAIRSHOPSANDRELATEDSERVICES` | +| `OUTDOOR_MARKETS` | +| `PERSONAL_SERVICES` | +| `POLITICAL_ORGANIZATIONS` | +| `PROFESSIONAL_SERVICES` | +| `REAL_ESTATE` | +| `RECREATION_SERVICES` | +| `REPAIR_SHOPS_AND_RELATED_SERVICES` | | `RESTAURANTS` | -| `RETAILSHOPS` | -| `SCHOOLSANDEDUCATIONALSERVICES` | -| `SPORTINGGOODS` | -| `TAXICABSANDLIMOUSINES` | -| `TICKETSALES` | +| `RETAIL_SHOPS` | +| `SCHOOLS_AND_EDUCATIONAL_SERVICES` | +| `SPORTING_GOODS` | +| `TAXICABS_AND_LIMOUSINES` | +| `TICKET_SALES` | | `TOURISM` | -| `TRAVELTOURISM` | -| `VETERINARYSERVICES` | -| `WEBDEVDESIGN` | +| `TRAVEL_TOURISM` | +| `VETERINARY_SERVICES` | +| `WEB_DEV_DESIGN` | diff --git a/doc/models/v1-order-history-entry-action.md b/doc/models/v1-order-history-entry-action.md index 72f19859..56a2cba2 100644 --- a/doc/models/v1-order-history-entry-action.md +++ b/doc/models/v1-order-history-entry-action.md @@ -8,9 +8,9 @@ | Name | | --- | -| `ORDERPLACED` | +| `ORDER_PLACED` | | `DECLINED` | -| `PAYMENTRECEIVED` | +| `PAYMENT_RECEIVED` | | `CANCELED` | | `COMPLETED` | | `REFUNDED` | diff --git a/doc/models/v1-page-cell-placeholder-type.md b/doc/models/v1-page-cell-placeholder-type.md index 4eb1e011..0813c415 100644 --- a/doc/models/v1-page-cell-placeholder-type.md +++ b/doc/models/v1-page-cell-placeholder-type.md @@ -8,7 +8,7 @@ | Name | | --- | -| `ALLITEMS` | -| `DISCOUNTSCATEGORY` | -| `REWARDSFINDER` | +| `ALL_ITEMS` | +| `DISCOUNTS_CATEGORY` | +| `REWARDS_FINDER` | diff --git a/doc/models/v1-payment-itemization-itemization-type.md b/doc/models/v1-payment-itemization-itemization-type.md index 129d951d..e3cf42a4 100644 --- a/doc/models/v1-payment-itemization-itemization-type.md +++ b/doc/models/v1-payment-itemization-itemization-type.md @@ -9,9 +9,9 @@ | Name | | --- | | `ITEM` | -| `CUSTOMAMOUNT` | -| `GIFTCARDACTIVATION` | -| `GIFTCARDRELOAD` | -| `GIFTCARDUNKNOWN` | +| `CUSTOM_AMOUNT` | +| `GIFT_CARD_ACTIVATION` | +| `GIFT_CARD_RELOAD` | +| `GIFT_CARD_UNKNOWN` | | `OTHER` | diff --git a/doc/models/v1-payment-surcharge-type.md b/doc/models/v1-payment-surcharge-type.md index 2765a0ca..7ad04e86 100644 --- a/doc/models/v1-payment-surcharge-type.md +++ b/doc/models/v1-payment-surcharge-type.md @@ -9,6 +9,6 @@ | Name | | --- | | `UNKNOWN` | -| `AUTOGRATUITY` | +| `AUTO_GRATUITY` | | `CUSTOM` | diff --git a/doc/models/v1-settlement-entry-type.md b/doc/models/v1-settlement-entry-type.md index cf1b2a80..424e27af 100644 --- a/doc/models/v1-settlement-entry-type.md +++ b/doc/models/v1-settlement-entry-type.md @@ -9,24 +9,24 @@ | Name | Description | | --- | --- | | `ADJUSTMENT` | A manual adjustment applied to the merchant's account by Square | -| `BALANCECHARGE` | A payment from an existing Square balance, such as a gift card | +| `BALANCE_CHARGE` | A payment from an existing Square balance, such as a gift card | | `CHARGE` | A credit card payment CAPTURE | -| `FREEPROCESSING` | Square offers Free Payments Processing for a variety of business scenarios including seller referral or when we want to apologize for a bug, customer service, repricing complication, etc. This entry represents a credit to the merchant for the purposes of Free Processing. | -| `HOLDADJUSTMENT` | An adjustment made by Square related to holding/releasing a payment | -| `PAIDSERVICEFEE` | a fee paid to a 3rd party merchant | -| `PAIDSERVICEFEEREFUND` | a refund for a 3rd party merchant fee | -| `REDEMPTIONCODE` | Repayment for a redemption code | +| `FREE_PROCESSING` | Square offers Free Payments Processing for a variety of business scenarios including seller referral or when we want to apologize for a bug, customer service, repricing complication, etc. This entry represents a credit to the merchant for the purposes of Free Processing. | +| `HOLD_ADJUSTMENT` | An adjustment made by Square related to holding/releasing a payment | +| `PAID_SERVICE_FEE` | a fee paid to a 3rd party merchant | +| `PAID_SERVICE_FEE_REFUND` | a refund for a 3rd party merchant fee | +| `REDEMPTION_CODE` | Repayment for a redemption code | | `REFUND` | A refund for an existing card payment | -| `RETURNEDPAYOUT` | An entry created when we receive a response for the ACH file we sent indicating that the settlement of the original entry failed. | -| `SQUARECAPITALADVANCE` | Initial deposit to a merchant for a Capital merchant cash advance (MCA). | -| `SQUARECAPITALPAYMENT` | Capital merchant cash advance (MCA) assessment. These are, generally, proportional to the merchant's sales but may be issued for other reasons related to the MCA. | -| `SQUARECAPITALREVERSEDPAYMENT` | Capital merchant cash advance (MCA) assessment refund. These are, generally, proportional to the merchant's refunds but may be issued for other reasons related to the MCA. | -| `SUBSCRIPTIONFEE` | Fee charged for subscription to a Square product | -| `SUBSCRIPTIONFEEREFUND` | Refund of a previously charged Square product subscription fee. | +| `RETURNED_PAYOUT` | An entry created when we receive a response for the ACH file we sent indicating that the settlement of the original entry failed. | +| `SQUARE_CAPITAL_ADVANCE` | Initial deposit to a merchant for a Capital merchant cash advance (MCA). | +| `SQUARE_CAPITAL_PAYMENT` | Capital merchant cash advance (MCA) assessment. These are, generally, proportional to the merchant's sales but may be issued for other reasons related to the MCA. | +| `SQUARE_CAPITAL_REVERSED_PAYMENT` | Capital merchant cash advance (MCA) assessment refund. These are, generally, proportional to the merchant's refunds but may be issued for other reasons related to the MCA. | +| `SUBSCRIPTION_FEE` | Fee charged for subscription to a Square product | +| `SUBSCRIPTION_FEE_REFUND` | Refund of a previously charged Square product subscription fee. | | `OTHER` | | -| `INCENTEDPAYMENT` | A payment in which Square covers part of the funds for a purchase | -| `RETURNEDACHENTRY` | A settlement failed to be processed and the settlement amount has been returned to the account | -| `RETURNEDSQUARE275` | Refund for cancelling a Square Plus subscription | -| `SQUARE275` | Fee charged for a Square Plus subscription ($275) | -| `SQUARECARD` | Settlements to or withdrawals from the Square Card (an asset) | +| `INCENTED_PAYMENT` | A payment in which Square covers part of the funds for a purchase | +| `RETURNED_ACH_ENTRY` | A settlement failed to be processed and the settlement amount has been returned to the account | +| `RETURNED_SQUARE_275` | Refund for cancelling a Square Plus subscription | +| `SQUARE_275` | Fee charged for a Square Plus subscription ($275) | +| `SQUARE_CARD` | Settlements to or withdrawals from the Square Card (an asset) | diff --git a/doc/models/v1-tender-card-brand.md b/doc/models/v1-tender-card-brand.md index 47cca537..945e8977 100644 --- a/doc/models/v1-tender-card-brand.md +++ b/doc/models/v1-tender-card-brand.md @@ -10,13 +10,13 @@ The brand of a credit card. | Name | | --- | -| `OTHERBRAND` | +| `OTHER_BRAND` | | `VISA` | -| `MASTERCARD` | -| `AMERICANEXPRESS` | +| `MASTER_CARD` | +| `AMERICAN_EXPRESS` | | `DISCOVER` | -| `DISCOVERDINERS` | +| `DISCOVER_DINERS` | | `JCB` | -| `CHINAUNIONPAY` | -| `SQUAREGIFTCARD` | +| `CHINA_UNIONPAY` | +| `SQUARE_GIFT_CARD` | diff --git a/doc/models/v1-tender-entry-method.md b/doc/models/v1-tender-entry-method.md index 268cae18..2edc2638 100644 --- a/doc/models/v1-tender-entry-method.md +++ b/doc/models/v1-tender-entry-method.md @@ -10,9 +10,9 @@ | --- | | `MANUAL` | | `SCANNED` | -| `SQUARECASH` | -| `SQUAREWALLET` | +| `SQUARE_CASH` | +| `SQUARE_WALLET` | | `SWIPED` | -| `WEBFORM` | +| `WEB_FORM` | | `OTHER` | diff --git a/doc/models/v1-tender-type.md b/doc/models/v1-tender-type.md index 4b8f3ad6..89132a7d 100644 --- a/doc/models/v1-tender-type.md +++ b/doc/models/v1-tender-type.md @@ -8,12 +8,12 @@ | Name | | --- | -| `CREDITCARD` | +| `CREDIT_CARD` | | `CASH` | -| `THIRDPARTYCARD` | -| `NOSALE` | -| `SQUAREWALLET` | -| `SQUAREGIFTCARD` | +| `THIRD_PARTY_CARD` | +| `NO_SALE` | +| `SQUARE_WALLET` | +| `SQUARE_GIFT_CARD` | | `UNKNOWN` | | `OTHER` | diff --git a/doc/models/v1-timecard-event-event-type.md b/doc/models/v1-timecard-event-event-type.md index 176b7818..420a4d8f 100644 --- a/doc/models/v1-timecard-event-event-type.md +++ b/doc/models/v1-timecard-event-event-type.md @@ -12,12 +12,12 @@ events created with the Connect API have an event type that begins with | Name | Description | | --- | --- | -| `APICREATE` | The timecard was created by a request to the
[CreateTimecard](#endpoint-v1employees-createtimecard) endpoint. | -| `APIEDIT` | The timecard was edited by a request to the
[UpdateTimecard](#endpoint-v1employees-updatetimecard) endpoint. | -| `APIDELETE` | The timecard was deleted by a request to the
[DeleteTimecard](#endpoint-v1employees-deletetimecard) endpoint. | -| `REGISTERCLOCKIN` | The employee clocked in via Square Point of Sale. | -| `REGISTERCLOCKOUT` | The employee clocked out via Square Point of Sale. | -| `DASHBOARDSUPERVISORCLOSE` | A supervisor clocked out the employee from the merchant
dashboard. | -| `DASHBOARDEDIT` | A supervisor manually edited the timecard from the merchant
dashboard | -| `DASHBOARDDELETE` | A supervisor deleted the timecard from the merchant dashboard. | +| `API_CREATE` | The timecard was created by a request to the
[CreateTimecard](#endpoint-v1employees-createtimecard) endpoint. | +| `API_EDIT` | The timecard was edited by a request to the
[UpdateTimecard](#endpoint-v1employees-updatetimecard) endpoint. | +| `API_DELETE` | The timecard was deleted by a request to the
[DeleteTimecard](#endpoint-v1employees-deletetimecard) endpoint. | +| `REGISTER_CLOCKIN` | The employee clocked in via Square Point of Sale. | +| `REGISTER_CLOCKOUT` | The employee clocked out via Square Point of Sale. | +| `DASHBOARD_SUPERVISOR_CLOSE` | A supervisor clocked out the employee from the merchant
dashboard. | +| `DASHBOARD_EDIT` | A supervisor manually edited the timecard from the merchant
dashboard | +| `DASHBOARD_DELETE` | A supervisor deleted the timecard from the merchant dashboard. | diff --git a/doc/models/v1-variation-inventory-alert-type.md b/doc/models/v1-variation-inventory-alert-type.md index 9b1b7fa3..aed7fc6d 100644 --- a/doc/models/v1-variation-inventory-alert-type.md +++ b/doc/models/v1-variation-inventory-alert-type.md @@ -8,7 +8,7 @@ | Name | | --- | -| `LOWQUANTITY` | +| `LOW_QUANTITY` | | `NONE` | | `INVESTMENT` | | `LOAN` | diff --git a/doc/models/v1-variation-pricing-type.md b/doc/models/v1-variation-pricing-type.md index 04ef48c5..066f59f1 100644 --- a/doc/models/v1-variation-pricing-type.md +++ b/doc/models/v1-variation-pricing-type.md @@ -8,6 +8,6 @@ | Name | | --- | -| `FIXEDPRICING` | -| `VARIABLEPRICING` | +| `FIXED_PRICING` | +| `VARIABLE_PRICING` | diff --git a/doc/subscriptions.md b/doc/subscriptions.md new file mode 100644 index 00000000..b6be9de6 --- /dev/null +++ b/doc/subscriptions.md @@ -0,0 +1,285 @@ +# Subscriptions + +```java +SubscriptionsApi subscriptionsApi = client.getSubscriptionsApi(); +``` + +## Class Name + +`SubscriptionsApi` + +## Methods + +* [Create Subscription](/doc/subscriptions.md#create-subscription) +* [Search Subscriptions](/doc/subscriptions.md#search-subscriptions) +* [Retrieve Subscription](/doc/subscriptions.md#retrieve-subscription) +* [Update Subscription](/doc/subscriptions.md#update-subscription) +* [Cancel Subscription](/doc/subscriptions.md#cancel-subscription) +* [List Subscription Events](/doc/subscriptions.md#list-subscription-events) + +## Create Subscription + +Creates a subscription for a customer to a subscription plan. + +If you provide a card on file in the request, Square charges the card for +the subscription. Otherwise, Square bills an invoice to the customer's email +address. The subscription starts immediately, unless the request includes +the optional `start_date`. Each individual subscription is associated with a particular location. + +For more information, +see [Subscription API Overview](https://developer.squareup.com/docs/docs/subscriptions-api/overview). + +```java +CompletableFuture createSubscriptionAsync( + final CreateSubscriptionRequest body) +``` + +### Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `body` | [`CreateSubscriptionRequest`](/doc/models/create-subscription-request.md) | Body, Required | An object containing the fields to POST for the request.

See the corresponding object definition for field details. | + +### Response Type + +[`CreateSubscriptionResponse`](/doc/models/create-subscription-response.md) + +### Example Usage + +```java +Money bodyPriceOverrideMoney = new Money.Builder() + .amount(100L) + .currency("USD") + .build(); +CreateSubscriptionRequest body = new CreateSubscriptionRequest.Builder( + "8193148c-9586-11e6-99f9-28cfe92138cf", + "S8GWD5R9QB376", + "6JHXF3B2CW3YKHDV4XEM674H", + "CHFGVKYY8RSV93M5KCYTG4PN0G") + .startDate("2020-08-01") + .taxPercentage("5") + .priceOverrideMoney(bodyPriceOverrideMoney) + .cardId("ccof:qy5x8hHGYsgLrp4Q4GB") + .timezone("America/Los_Angeles") + .build(); + +subscriptionsApi.createSubscriptionAsync(body).thenAccept(result -> { + // TODO success callback handler +}).exceptionally(exception -> { + // TODO failure callback handler + return null; +}); +``` + +## Search Subscriptions + +Searches for subscriptions. +Results are ordered chronologically by subscription creation date. If +the request specifies more than one location ID, +the endpoint orders the result +by location ID, and then by creation date within each location. If no locations are given +in the query, all locations are searched. + +You can also optionally specify `customer_ids` to search by customer. +If left unset, all customers +associated with the specified locations are returned. +If the request specifies customer IDs, the endpoint orders results +first by location, within location by customer ID, and within +customer by subscription creation date. + +For more information, see +[Retrieve subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#retrieve-subscriptions). + +```java +CompletableFuture searchSubscriptionsAsync( + final SearchSubscriptionsRequest body) +``` + +### Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `body` | [`SearchSubscriptionsRequest`](/doc/models/search-subscriptions-request.md) | Body, Required | An object containing the fields to POST for the request.

See the corresponding object definition for field details. | + +### Response Type + +[`SearchSubscriptionsResponse`](/doc/models/search-subscriptions-response.md) + +### Example Usage + +```java +List bodyQueryFilterCustomerIds = new LinkedList<>(); +bodyQueryFilterCustomerIds.add("CHFGVKYY8RSV93M5KCYTG4PN0G"); +List bodyQueryFilterLocationIds = new LinkedList<>(); +bodyQueryFilterLocationIds.add("S8GWD5R9QB376"); +SearchSubscriptionsFilter bodyQueryFilter = new SearchSubscriptionsFilter.Builder() + .customerIds(bodyQueryFilterCustomerIds) + .locationIds(bodyQueryFilterLocationIds) + .build(); +SearchSubscriptionsQuery bodyQuery = new SearchSubscriptionsQuery.Builder() + .filter(bodyQueryFilter) + .build(); +SearchSubscriptionsRequest body = new SearchSubscriptionsRequest.Builder() + .query(bodyQuery) + .build(); + +subscriptionsApi.searchSubscriptionsAsync(body).thenAccept(result -> { + // TODO success callback handler +}).exceptionally(exception -> { + // TODO failure callback handler + return null; +}); +``` + +## Retrieve Subscription + +Retrieves a subscription. + +```java +CompletableFuture retrieveSubscriptionAsync( + final String subscriptionId) +``` + +### Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `String` | Template, Required | The ID of the subscription to retrieve. | + +### Response Type + +[`RetrieveSubscriptionResponse`](/doc/models/retrieve-subscription-response.md) + +### Example Usage + +```java +String subscriptionId = "subscription_id0"; + +subscriptionsApi.retrieveSubscriptionAsync(subscriptionId).thenAccept(result -> { + // TODO success callback handler +}).exceptionally(exception -> { + // TODO failure callback handler + return null; +}); +``` + +## Update Subscription + +Updates a subscription. You can set, modify, and clear the +`subscription` field values. For more information and examples, see +[Update subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#update-subscriptions). + +```java +CompletableFuture updateSubscriptionAsync( + final String subscriptionId, + final UpdateSubscriptionRequest body) +``` + +### Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `String` | Template, Required | The ID for the subscription to update. | +| `body` | [`UpdateSubscriptionRequest`](/doc/models/update-subscription-request.md) | Body, Required | An object containing the fields to POST for the request.

See the corresponding object definition for field details. | + +### Response Type + +[`UpdateSubscriptionResponse`](/doc/models/update-subscription-response.md) + +### Example Usage + +```java +String subscriptionId = "subscription_id0"; +Money bodySubscriptionPriceOverrideMoney = new Money.Builder() + .amount(2000L) + .currency("USD") + .build(); +Subscription bodySubscription = new Subscription.Builder() + .priceOverrideMoney(bodySubscriptionPriceOverrideMoney) + .version(1594155459464L) + .build(); +UpdateSubscriptionRequest body = new UpdateSubscriptionRequest.Builder() + .subscription(bodySubscription) + .build(); + +subscriptionsApi.updateSubscriptionAsync(subscriptionId, body).thenAccept(result -> { + // TODO success callback handler +}).exceptionally(exception -> { + // TODO failure callback handler + return null; +}); +``` + +## Cancel Subscription + +Cancels a subscription immediately and sets the subscription +`status` to `CANCELED`. You can also use the `UpdateSubscription` +endpoint to cancel a subscription at a future date. For more +information, see +[CancelSubscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#cancel-subscriptions). + +```java +CompletableFuture cancelSubscriptionAsync( + final String subscriptionId) +``` + +### Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `String` | Template, Required | The ID of the subscription to cancel. | + +### Response Type + +[`CancelSubscriptionResponse`](/doc/models/cancel-subscription-response.md) + +### Example Usage + +```java +String subscriptionId = "subscription_id0"; + +subscriptionsApi.cancelSubscriptionAsync(subscriptionId).thenAccept(result -> { + // TODO success callback handler +}).exceptionally(exception -> { + // TODO failure callback handler + return null; +}); +``` + +## List Subscription Events + +Lists all events for a specific subscription. +In the current implementation, only `START_SUBSCRIPTION` and `STOP_SUBSCRIPTION` (when the subscription was canceled) events are returned. + +```java +CompletableFuture listSubscriptionEventsAsync( + final String subscriptionId, + final String cursor, + final Integer limit) +``` + +### Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `String` | Template, Required | The ID of the subscription to retrieve the events for. | +| `cursor` | `String` | Query, Optional | A pagination cursor returned by a previous call to this endpoint.
Provide this to retrieve the next set of results for the original query.

For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). | +| `limit` | `Integer` | Query, Optional | The upper limit on the number of subscription events to return
in the response.

Default: `200` | + +### Response Type + +[`ListSubscriptionEventsResponse`](/doc/models/list-subscription-events-response.md) + +### Example Usage + +```java +String subscriptionId = "subscription_id0"; + +subscriptionsApi.listSubscriptionEventsAsync(subscriptionId, null, null).thenAccept(result -> { + // TODO success callback handler +}).exceptionally(exception -> { + // TODO failure callback handler + return null; +}); +``` + diff --git a/pom.xml b/pom.xml index af356dc8..c6c9a72e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.squareup square - 6.1.0.20200722 + 6.2.0.20200812 jar Square @@ -214,4 +214,4 @@ test - \ No newline at end of file + diff --git a/src/main/java/com/squareup/square/AccessTokenCredentials.java b/src/main/java/com/squareup/square/AccessTokenCredentials.java index 0f935fba..248439b8 100644 --- a/src/main/java/com/squareup/square/AccessTokenCredentials.java +++ b/src/main/java/com/squareup/square/AccessTokenCredentials.java @@ -9,4 +9,4 @@ public interface AccessTokenCredentials { * @return accessToken */ String getAccessToken(); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/AccessTokenManager.java b/src/main/java/com/squareup/square/AccessTokenManager.java index 1246c700..eec657f5 100644 --- a/src/main/java/com/squareup/square/AccessTokenManager.java +++ b/src/main/java/com/squareup/square/AccessTokenManager.java @@ -45,4 +45,4 @@ public CompletableFuture applyAsync(HttpRequest httpRequest) { httpRequest.getHeaders().add("Authorization", "Bearer " + accessToken); return CompletableFuture.completedFuture(httpRequest); } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/ApiHelper.java b/src/main/java/com/squareup/square/ApiHelper.java index 2a5eeff3..abf725de 100644 --- a/src/main/java/com/squareup/square/ApiHelper.java +++ b/src/main/java/com/squareup/square/ApiHelper.java @@ -506,4 +506,4 @@ private static void loadKeyValuePairForEncoding( private static boolean isWrapperType(Object object) { return WRAPPER_TYPES.contains(object.getClass()) || object.getClass().isPrimitive() || object.getClass().isEnum(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/Environment.java b/src/main/java/com/squareup/square/Environment.java index b20c5790..8eb08722 100644 --- a/src/main/java/com/squareup/square/Environment.java +++ b/src/main/java/com/squareup/square/Environment.java @@ -61,4 +61,4 @@ public static List toValue(List toConvert) { } return convertedValues; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/Server.java b/src/main/java/com/squareup/square/Server.java index f0260a48..3f6d7090 100644 --- a/src/main/java/com/squareup/square/Server.java +++ b/src/main/java/com/squareup/square/Server.java @@ -57,4 +57,4 @@ public static List toValue(List toConvert) { } return convertedValues; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/SquareClient.java b/src/main/java/com/squareup/square/SquareClient.java index ebc6b048..abaf8a7c 100644 --- a/src/main/java/com/squareup/square/SquareClient.java +++ b/src/main/java/com/squareup/square/SquareClient.java @@ -34,6 +34,7 @@ import com.squareup.square.api.DefaultPaymentsApi; import com.squareup.square.api.DefaultRefundsApi; import com.squareup.square.api.DefaultReportingApi; +import com.squareup.square.api.DefaultSubscriptionsApi; import com.squareup.square.api.DefaultTeamApi; import com.squareup.square.api.DefaultTerminalApi; import com.squareup.square.api.DefaultTransactionsApi; @@ -56,6 +57,7 @@ import com.squareup.square.api.PaymentsApi; import com.squareup.square.api.RefundsApi; import com.squareup.square.api.ReportingApi; +import com.squareup.square.api.SubscriptionsApi; import com.squareup.square.api.TeamApi; import com.squareup.square.api.TerminalApi; import com.squareup.square.api.TransactionsApi; @@ -104,6 +106,7 @@ public final class SquareClient implements SquareClientInterface { private MerchantsApi merchants; private PaymentsApi payments; private RefundsApi refunds; + private SubscriptionsApi subscriptions; private TeamApi team; private TerminalApi terminal; @@ -331,6 +334,14 @@ public RefundsApi getRefundsApi() { return refunds; } + /** + * Get the instance of SubscriptionsApi + * @return subscriptions + */ + public SubscriptionsApi getSubscriptionsApi() { + return subscriptions; + } + /** * Get the instance of TeamApi * @return team @@ -402,6 +413,7 @@ private SquareClient(Environment environment, String squareVersion, String acces merchants = new DefaultMerchantsApi(this, this.httpClient, this.authManagers, this.httpCallback); payments = new DefaultPaymentsApi(this, this.httpClient, this.authManagers, this.httpCallback); refunds = new DefaultRefundsApi(this, this.httpClient, this.authManagers, this.httpCallback); + subscriptions = new DefaultSubscriptionsApi(this, this.httpClient, this.authManagers, this.httpCallback); team = new DefaultTeamApi(this, this.httpClient, this.authManagers, this.httpCallback); terminal = new DefaultTerminalApi(this, this.httpClient, this.authManagers, this.httpCallback); } @@ -512,7 +524,7 @@ public Headers getAdditionalHeaders() { * @return sdkVersion */ public String getSdkVersion() { - return "6.1.0.20200722"; + return "6.2.0.20200812"; } /** @@ -580,7 +592,7 @@ public Builder newBuilder() { */ public static class Builder { private Environment environment = Environment.PRODUCTION; - private String squareVersion = "2020-07-22"; + private String squareVersion = "2020-08-12"; private String accessToken = "TODO: Replace"; private HttpClient httpClient; private long timeout = 60; @@ -668,4 +680,4 @@ public SquareClient build() { additionalHeaders, authManagers, httpCallback); } } -} +} diff --git a/src/main/java/com/squareup/square/SquareClientInterface.java b/src/main/java/com/squareup/square/SquareClientInterface.java index 9709d962..29216bc9 100644 --- a/src/main/java/com/squareup/square/SquareClientInterface.java +++ b/src/main/java/com/squareup/square/SquareClientInterface.java @@ -23,6 +23,7 @@ import com.squareup.square.api.PaymentsApi; import com.squareup.square.api.RefundsApi; import com.squareup.square.api.ReportingApi; +import com.squareup.square.api.SubscriptionsApi; import com.squareup.square.api.TeamApi; import com.squareup.square.api.TerminalApi; import com.squareup.square.api.TransactionsApi; @@ -208,6 +209,12 @@ public interface SquareClientInterface extends Configuration { */ RefundsApi getRefundsApi(); + /** + * Provides access to Subscriptions controller + * @return Returns the SubscriptionsApi instance + */ + SubscriptionsApi getSubscriptionsApi(); + /** * Provides access to Team controller * @return Returns the TeamApi instance @@ -274,4 +281,4 @@ public interface SquareClientInterface extends Configuration { * @return Processed base URI */ String getBaseUri(); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/ApplePayApi.java b/src/main/java/com/squareup/square/api/ApplePayApi.java index 84a32e29..c766f194 100644 --- a/src/main/java/com/squareup/square/api/ApplePayApi.java +++ b/src/main/java/com/squareup/square/api/ApplePayApi.java @@ -39,4 +39,4 @@ RegisterDomainResponse registerDomain( CompletableFuture registerDomainAsync( final RegisterDomainRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/BankAccountsApi.java b/src/main/java/com/squareup/square/api/BankAccountsApi.java index 144b6b39..df079186 100644 --- a/src/main/java/com/squareup/square/api/BankAccountsApi.java +++ b/src/main/java/com/squareup/square/api/BankAccountsApi.java @@ -80,4 +80,4 @@ GetBankAccountResponse getBankAccount( CompletableFuture getBankAccountAsync( final String bankAccountId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/BaseApi.java b/src/main/java/com/squareup/square/api/BaseApi.java index 4df1440f..4d9d7f1f 100644 --- a/src/main/java/com/squareup/square/api/BaseApi.java +++ b/src/main/java/com/squareup/square/api/BaseApi.java @@ -24,7 +24,7 @@ public abstract class BaseApi { * Protected variables to hold an instance of Configuration */ protected final Configuration config; - protected static final String userAgent = "Square-Java-SDK/6.1.0.20200722"; + protected static final String userAgent = "Square-Java-SDK/6.2.0.20200812"; /** * Protected variable to hold an instance of HttpCallback if the user provides it diff --git a/src/main/java/com/squareup/square/api/CashDrawersApi.java b/src/main/java/com/squareup/square/api/CashDrawersApi.java index c0322b75..650fa34c 100644 --- a/src/main/java/com/squareup/square/api/CashDrawersApi.java +++ b/src/main/java/com/squareup/square/api/CashDrawersApi.java @@ -100,4 +100,4 @@ CompletableFuture listCashDrawerShiftEventsAs final Integer limit, final String cursor); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/CatalogApi.java b/src/main/java/com/squareup/square/api/CatalogApi.java index e8fa816d..ffc4ca3d 100644 --- a/src/main/java/com/squareup/square/api/CatalogApi.java +++ b/src/main/java/com/squareup/square/api/CatalogApi.java @@ -374,4 +374,4 @@ UpdateItemTaxesResponse updateItemTaxes( CompletableFuture updateItemTaxesAsync( final UpdateItemTaxesRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/CheckoutApi.java b/src/main/java/com/squareup/square/api/CheckoutApi.java index 6d3def13..e05ab5e9 100644 --- a/src/main/java/com/squareup/square/api/CheckoutApi.java +++ b/src/main/java/com/squareup/square/api/CheckoutApi.java @@ -35,4 +35,4 @@ CompletableFuture createCheckoutAsync( final String locationId, final CreateCheckoutRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/CustomerGroupsApi.java b/src/main/java/com/squareup/square/api/CustomerGroupsApi.java index 73e2c06c..0d2e2d03 100644 --- a/src/main/java/com/squareup/square/api/CustomerGroupsApi.java +++ b/src/main/java/com/squareup/square/api/CustomerGroupsApi.java @@ -102,4 +102,4 @@ CompletableFuture updateCustomerGroupAsync( final String groupId, final UpdateCustomerGroupRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/CustomerSegmentsApi.java b/src/main/java/com/squareup/square/api/CustomerSegmentsApi.java index 6ae79a75..f4a0cf30 100644 --- a/src/main/java/com/squareup/square/api/CustomerSegmentsApi.java +++ b/src/main/java/com/squareup/square/api/CustomerSegmentsApi.java @@ -43,4 +43,4 @@ RetrieveCustomerSegmentResponse retrieveCustomerSegment( CompletableFuture retrieveCustomerSegmentAsync( final String segmentId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/CustomersApi.java b/src/main/java/com/squareup/square/api/CustomersApi.java index 1cc11314..584ee448 100644 --- a/src/main/java/com/squareup/square/api/CustomersApi.java +++ b/src/main/java/com/squareup/square/api/CustomersApi.java @@ -275,4 +275,4 @@ CompletableFuture addGroupToCustomerAsync( final String customerId, final String groupId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultApplePayApi.java b/src/main/java/com/squareup/square/api/DefaultApplePayApi.java index dcd1af44..1b1e40c5 100644 --- a/src/main/java/com/squareup/square/api/DefaultApplePayApi.java +++ b/src/main/java/com/squareup/square/api/DefaultApplePayApi.java @@ -143,4 +143,4 @@ private RegisterDomainResponse handleRegisterDomainResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultBankAccountsApi.java b/src/main/java/com/squareup/square/api/DefaultBankAccountsApi.java index bec0a11b..997bb512 100644 --- a/src/main/java/com/squareup/square/api/DefaultBankAccountsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultBankAccountsApi.java @@ -340,4 +340,4 @@ private GetBankAccountResponse handleGetBankAccountResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultCashDrawersApi.java b/src/main/java/com/squareup/square/api/DefaultCashDrawersApi.java index a5211e71..908754ee 100644 --- a/src/main/java/com/squareup/square/api/DefaultCashDrawersApi.java +++ b/src/main/java/com/squareup/square/api/DefaultCashDrawersApi.java @@ -382,4 +382,4 @@ private ListCashDrawerShiftEventsResponse handleListCashDrawerShiftEventsRespons return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultCatalogApi.java b/src/main/java/com/squareup/square/api/DefaultCatalogApi.java index 596131f2..6d00ac16 100644 --- a/src/main/java/com/squareup/square/api/DefaultCatalogApi.java +++ b/src/main/java/com/squareup/square/api/DefaultCatalogApi.java @@ -1361,4 +1361,4 @@ private UpdateItemTaxesResponse handleUpdateItemTaxesResponse(HttpContext contex return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultCheckoutApi.java b/src/main/java/com/squareup/square/api/DefaultCheckoutApi.java index 06712eee..5ef4ae02 100644 --- a/src/main/java/com/squareup/square/api/DefaultCheckoutApi.java +++ b/src/main/java/com/squareup/square/api/DefaultCheckoutApi.java @@ -146,4 +146,4 @@ private CreateCheckoutResponse handleCreateCheckoutResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultCustomerGroupsApi.java b/src/main/java/com/squareup/square/api/DefaultCustomerGroupsApi.java index 4c701460..c4cf3a3b 100644 --- a/src/main/java/com/squareup/square/api/DefaultCustomerGroupsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultCustomerGroupsApi.java @@ -506,4 +506,4 @@ private UpdateCustomerGroupResponse handleUpdateCustomerGroupResponse(HttpContex return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultCustomerSegmentsApi.java b/src/main/java/com/squareup/square/api/DefaultCustomerSegmentsApi.java index 76ae41bc..3ea0f182 100644 --- a/src/main/java/com/squareup/square/api/DefaultCustomerSegmentsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultCustomerSegmentsApi.java @@ -225,4 +225,4 @@ private RetrieveCustomerSegmentResponse handleRetrieveCustomerSegmentResponse(Ht return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultCustomersApi.java b/src/main/java/com/squareup/square/api/DefaultCustomersApi.java index 9916e270..cce3785e 100644 --- a/src/main/java/com/squareup/square/api/DefaultCustomersApi.java +++ b/src/main/java/com/squareup/square/api/DefaultCustomersApi.java @@ -1059,4 +1059,4 @@ private AddGroupToCustomerResponse handleAddGroupToCustomerResponse(HttpContext return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultDevicesApi.java b/src/main/java/com/squareup/square/api/DefaultDevicesApi.java index a023cc20..45edfa7a 100644 --- a/src/main/java/com/squareup/square/api/DefaultDevicesApi.java +++ b/src/main/java/com/squareup/square/api/DefaultDevicesApi.java @@ -328,4 +328,4 @@ private GetDeviceCodeResponse handleGetDeviceCodeResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultDisputesApi.java b/src/main/java/com/squareup/square/api/DefaultDisputesApi.java index bbe59ac1..1b958e64 100644 --- a/src/main/java/com/squareup/square/api/DefaultDisputesApi.java +++ b/src/main/java/com/squareup/square/api/DefaultDisputesApi.java @@ -971,4 +971,4 @@ private SubmitEvidenceResponse handleSubmitEvidenceResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultEmployeesApi.java b/src/main/java/com/squareup/square/api/DefaultEmployeesApi.java index f8dcae27..30e6391e 100644 --- a/src/main/java/com/squareup/square/api/DefaultEmployeesApi.java +++ b/src/main/java/com/squareup/square/api/DefaultEmployeesApi.java @@ -243,4 +243,4 @@ private RetrieveEmployeeResponse handleRetrieveEmployeeResponse(HttpContext cont return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultInventoryApi.java b/src/main/java/com/squareup/square/api/DefaultInventoryApi.java index 4aafbae1..6fac7557 100644 --- a/src/main/java/com/squareup/square/api/DefaultInventoryApi.java +++ b/src/main/java/com/squareup/square/api/DefaultInventoryApi.java @@ -762,4 +762,4 @@ private RetrieveInventoryChangesResponse handleRetrieveInventoryChangesResponse( return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultInvoicesApi.java b/src/main/java/com/squareup/square/api/DefaultInvoicesApi.java index 3486e7b5..61e3868a 100644 --- a/src/main/java/com/squareup/square/api/DefaultInvoicesApi.java +++ b/src/main/java/com/squareup/square/api/DefaultInvoicesApi.java @@ -877,4 +877,4 @@ private PublishInvoiceResponse handlePublishInvoiceResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultLaborApi.java b/src/main/java/com/squareup/square/api/DefaultLaborApi.java index bf564a49..bf297493 100644 --- a/src/main/java/com/squareup/square/api/DefaultLaborApi.java +++ b/src/main/java/com/squareup/square/api/DefaultLaborApi.java @@ -1447,4 +1447,4 @@ private UpdateWorkweekConfigResponse handleUpdateWorkweekConfigResponse(HttpCont return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultLocationsApi.java b/src/main/java/com/squareup/square/api/DefaultLocationsApi.java index cc9cd289..0c301ed6 100644 --- a/src/main/java/com/squareup/square/api/DefaultLocationsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultLocationsApi.java @@ -417,4 +417,4 @@ private UpdateLocationResponse handleUpdateLocationResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultLoyaltyApi.java b/src/main/java/com/squareup/square/api/DefaultLoyaltyApi.java index 9612847d..dc78f338 100644 --- a/src/main/java/com/squareup/square/api/DefaultLoyaltyApi.java +++ b/src/main/java/com/squareup/square/api/DefaultLoyaltyApi.java @@ -1356,4 +1356,4 @@ private RedeemLoyaltyRewardResponse handleRedeemLoyaltyRewardResponse(HttpContex return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultMerchantsApi.java b/src/main/java/com/squareup/square/api/DefaultMerchantsApi.java index 6e0ff147..8a1e5215 100644 --- a/src/main/java/com/squareup/square/api/DefaultMerchantsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultMerchantsApi.java @@ -235,4 +235,4 @@ private RetrieveMerchantResponse handleRetrieveMerchantResponse(HttpContext cont return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultMobileAuthorizationApi.java b/src/main/java/com/squareup/square/api/DefaultMobileAuthorizationApi.java index 262fa416..b9befd19 100644 --- a/src/main/java/com/squareup/square/api/DefaultMobileAuthorizationApi.java +++ b/src/main/java/com/squareup/square/api/DefaultMobileAuthorizationApi.java @@ -145,4 +145,4 @@ private CreateMobileAuthorizationCodeResponse handleCreateMobileAuthorizationCod return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultOAuthApi.java b/src/main/java/com/squareup/square/api/DefaultOAuthApi.java index ac03caa4..bd5ff779 100644 --- a/src/main/java/com/squareup/square/api/DefaultOAuthApi.java +++ b/src/main/java/com/squareup/square/api/DefaultOAuthApi.java @@ -398,4 +398,4 @@ private ObtainTokenResponse handleObtainTokenResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultOrdersApi.java b/src/main/java/com/squareup/square/api/DefaultOrdersApi.java index 78cdd07c..b11e2f2e 100644 --- a/src/main/java/com/squareup/square/api/DefaultOrdersApi.java +++ b/src/main/java/com/squareup/square/api/DefaultOrdersApi.java @@ -709,4 +709,4 @@ private PayOrderResponse handlePayOrderResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultPaymentsApi.java b/src/main/java/com/squareup/square/api/DefaultPaymentsApi.java index 1054efa4..3865ec8f 100644 --- a/src/main/java/com/squareup/square/api/DefaultPaymentsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultPaymentsApi.java @@ -677,4 +677,4 @@ private CompletePaymentResponse handleCompletePaymentResponse(HttpContext contex return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultRefundsApi.java b/src/main/java/com/squareup/square/api/DefaultRefundsApi.java index c97f4a7e..753caf12 100644 --- a/src/main/java/com/squareup/square/api/DefaultRefundsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultRefundsApi.java @@ -356,4 +356,4 @@ private GetPaymentRefundResponse handleGetPaymentRefundResponse(HttpContext cont return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultReportingApi.java b/src/main/java/com/squareup/square/api/DefaultReportingApi.java index 1b33f90f..6f749cdf 100644 --- a/src/main/java/com/squareup/square/api/DefaultReportingApi.java +++ b/src/main/java/com/squareup/square/api/DefaultReportingApi.java @@ -301,4 +301,4 @@ private ListAdditionalRecipientReceivablesResponse handleListAdditionalRecipient return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultSubscriptionsApi.java b/src/main/java/com/squareup/square/api/DefaultSubscriptionsApi.java new file mode 100644 index 00000000..fa3b7605 --- /dev/null +++ b/src/main/java/com/squareup/square/api/DefaultSubscriptionsApi.java @@ -0,0 +1,664 @@ +package com.squareup.square.api; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.squareup.square.ApiHelper; +import com.squareup.square.AuthManager; +import com.squareup.square.Configuration; +import com.squareup.square.exceptions.ApiException; +import com.squareup.square.http.client.HttpCallback; +import com.squareup.square.http.client.HttpClient; +import com.squareup.square.http.client.HttpContext; +import com.squareup.square.http.Headers; +import com.squareup.square.http.request.HttpRequest; +import com.squareup.square.http.response.HttpResponse; +import com.squareup.square.http.response.HttpStringResponse; +import com.squareup.square.models.CancelSubscriptionResponse; +import com.squareup.square.models.CreateSubscriptionRequest; +import com.squareup.square.models.CreateSubscriptionResponse; +import com.squareup.square.models.ListSubscriptionEventsResponse; +import com.squareup.square.models.RetrieveSubscriptionResponse; +import com.squareup.square.models.SearchSubscriptionsRequest; +import com.squareup.square.models.SearchSubscriptionsResponse; +import com.squareup.square.models.UpdateSubscriptionRequest; +import com.squareup.square.models.UpdateSubscriptionResponse; + +/** + * This class lists all the endpoints of the groups. + */ +public final class DefaultSubscriptionsApi extends BaseApi implements SubscriptionsApi { + + /** + * Initializes the controller. + * @param config + * @param httpClient + * @param authManagers + */ + public DefaultSubscriptionsApi(Configuration config, HttpClient httpClient, Map authManagers) { + super(config, httpClient, authManagers); + } + + /** + * Initializes the controller with HTTPCallback. + * @param config + * @param httpClient + * @param authManagers + * @param httpCallback + */ + public DefaultSubscriptionsApi(Configuration config, HttpClient httpClient, Map authManagers, HttpCallback httpCallback) { + super(config, httpClient, authManagers, httpCallback); + } + + /** + * Creates a subscription for a customer to a subscription plan. + * If you provide a card on file in the request, Square charges the card for + * the subscription. Otherwise, Square bills an invoice to the customer's email + * address. The subscription starts immediately, unless the request includes + * the optional `start_date`. Each individual subscription is associated with a particular location. + * For more information, + * see [Subscription API Overview](https://developer.squareup.com/docs/docs/subscriptions-api/overview). + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the CreateSubscriptionResponse response from the API call + */ + public CreateSubscriptionResponse createSubscription( + final CreateSubscriptionRequest body) throws ApiException, IOException { + HttpRequest request = buildCreateSubscriptionRequest(body); + authManagers.get("default").apply(request); + + HttpResponse response = getClientInstance().executeAsString(request); + HttpContext context = new HttpContext(request, response); + + return handleCreateSubscriptionResponse(context); + } + + /** + * Creates a subscription for a customer to a subscription plan. + * If you provide a card on file in the request, Square charges the card for + * the subscription. Otherwise, Square bills an invoice to the customer's email + * address. The subscription starts immediately, unless the request includes + * the optional `start_date`. Each individual subscription is associated with a particular location. + * For more information, + * see [Subscription API Overview](https://developer.squareup.com/docs/docs/subscriptions-api/overview). + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the CreateSubscriptionResponse response from the API call + */ + public CompletableFuture createSubscriptionAsync( + final CreateSubscriptionRequest body) { + return makeHttpCallAsync(() -> buildCreateSubscriptionRequest(body), + req -> authManagers.get("default").applyAsync(req) + .thenCompose(request -> getClientInstance().executeAsStringAsync(request)), + context -> handleCreateSubscriptionResponse(context)); + } + + /** + * Builds the HttpRequest object for createSubscription + */ + private HttpRequest buildCreateSubscriptionRequest( + final CreateSubscriptionRequest body) throws JsonProcessingException { + //the base uri for api requests + String baseUri = config.getBaseUri(); + + //prepare query string for API call + StringBuilder queryBuilder = new StringBuilder(baseUri + "/v2/subscriptions"); + //validate and preprocess url + String queryUrl = ApiHelper.cleanUrl(queryBuilder); + + //load all headers for the outgoing API request + Headers headers = new Headers(); + headers.add("Square-Version", config.getSquareVersion()); + headers.add("user-agent", BaseApi.userAgent); + headers.add("accept", "application/json"); + headers.add("content-type", "application/json"); + headers.addAll(config.getAdditionalHeaders()); + + //prepare and invoke the API call request to fetch the response + String bodyJson = ApiHelper.serialize(body); + HttpRequest request = getClientInstance().postBody(queryUrl, headers, bodyJson); + + // Invoke the callback before request if its not null + if (getHttpCallback() != null) { + getHttpCallback().onBeforeRequest(request); + } + + return request; + } + + /** + * Processes the response for createSubscription + * @return An object of type CreateSubscriptionResponse + */ + private CreateSubscriptionResponse handleCreateSubscriptionResponse(HttpContext context) + throws ApiException, IOException { + HttpResponse response = context.getResponse(); + + //invoke the callback after response if its not null + if (getHttpCallback() != null) { + getHttpCallback().onAfterResponse(context); + } + + //handle errors defined at the API level + validateResponse(response, context); + + //extract result from the http response + String responseBody = ((HttpStringResponse)response).getBody(); + CreateSubscriptionResponse result = ApiHelper.deserialize(responseBody, + CreateSubscriptionResponse.class); + + result = result.toBuilder().httpContext(context).build(); + return result; + } + + /** + * Searches for subscriptions. + * Results are ordered chronologically by subscription creation date. If + * the request specifies more than one location ID, + * the endpoint orders the result + * by location ID, and then by creation date within each location. If no locations are given + * in the query, all locations are searched. + * You can also optionally specify `customer_ids` to search by customer. + * If left unset, all customers + * associated with the specified locations are returned. + * If the request specifies customer IDs, the endpoint orders results + * first by location, within location by customer ID, and within + * customer by subscription creation date. + * For more information, see + * [Retrieve subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#retrieve-subscriptions). + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the SearchSubscriptionsResponse response from the API call + */ + public SearchSubscriptionsResponse searchSubscriptions( + final SearchSubscriptionsRequest body) throws ApiException, IOException { + HttpRequest request = buildSearchSubscriptionsRequest(body); + authManagers.get("default").apply(request); + + HttpResponse response = getClientInstance().executeAsString(request); + HttpContext context = new HttpContext(request, response); + + return handleSearchSubscriptionsResponse(context); + } + + /** + * Searches for subscriptions. + * Results are ordered chronologically by subscription creation date. If + * the request specifies more than one location ID, + * the endpoint orders the result + * by location ID, and then by creation date within each location. If no locations are given + * in the query, all locations are searched. + * You can also optionally specify `customer_ids` to search by customer. + * If left unset, all customers + * associated with the specified locations are returned. + * If the request specifies customer IDs, the endpoint orders results + * first by location, within location by customer ID, and within + * customer by subscription creation date. + * For more information, see + * [Retrieve subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#retrieve-subscriptions). + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the SearchSubscriptionsResponse response from the API call + */ + public CompletableFuture searchSubscriptionsAsync( + final SearchSubscriptionsRequest body) { + return makeHttpCallAsync(() -> buildSearchSubscriptionsRequest(body), + req -> authManagers.get("default").applyAsync(req) + .thenCompose(request -> getClientInstance().executeAsStringAsync(request)), + context -> handleSearchSubscriptionsResponse(context)); + } + + /** + * Builds the HttpRequest object for searchSubscriptions + */ + private HttpRequest buildSearchSubscriptionsRequest( + final SearchSubscriptionsRequest body) throws JsonProcessingException { + //the base uri for api requests + String baseUri = config.getBaseUri(); + + //prepare query string for API call + StringBuilder queryBuilder = new StringBuilder(baseUri + "/v2/subscriptions/search"); + //validate and preprocess url + String queryUrl = ApiHelper.cleanUrl(queryBuilder); + + //load all headers for the outgoing API request + Headers headers = new Headers(); + headers.add("Square-Version", config.getSquareVersion()); + headers.add("user-agent", BaseApi.userAgent); + headers.add("accept", "application/json"); + headers.add("content-type", "application/json"); + headers.addAll(config.getAdditionalHeaders()); + + //prepare and invoke the API call request to fetch the response + String bodyJson = ApiHelper.serialize(body); + HttpRequest request = getClientInstance().postBody(queryUrl, headers, bodyJson); + + // Invoke the callback before request if its not null + if (getHttpCallback() != null) { + getHttpCallback().onBeforeRequest(request); + } + + return request; + } + + /** + * Processes the response for searchSubscriptions + * @return An object of type SearchSubscriptionsResponse + */ + private SearchSubscriptionsResponse handleSearchSubscriptionsResponse(HttpContext context) + throws ApiException, IOException { + HttpResponse response = context.getResponse(); + + //invoke the callback after response if its not null + if (getHttpCallback() != null) { + getHttpCallback().onAfterResponse(context); + } + + //handle errors defined at the API level + validateResponse(response, context); + + //extract result from the http response + String responseBody = ((HttpStringResponse)response).getBody(); + SearchSubscriptionsResponse result = ApiHelper.deserialize(responseBody, + SearchSubscriptionsResponse.class); + + result = result.toBuilder().httpContext(context).build(); + return result; + } + + /** + * Retrieves a subscription. + * @param subscriptionId Required parameter: The ID of the subscription to retrieve. + * @return Returns the RetrieveSubscriptionResponse response from the API call + */ + public RetrieveSubscriptionResponse retrieveSubscription( + final String subscriptionId) throws ApiException, IOException { + HttpRequest request = buildRetrieveSubscriptionRequest(subscriptionId); + authManagers.get("default").apply(request); + + HttpResponse response = getClientInstance().executeAsString(request); + HttpContext context = new HttpContext(request, response); + + return handleRetrieveSubscriptionResponse(context); + } + + /** + * Retrieves a subscription. + * @param subscriptionId Required parameter: The ID of the subscription to retrieve. + * @return Returns the RetrieveSubscriptionResponse response from the API call + */ + public CompletableFuture retrieveSubscriptionAsync( + final String subscriptionId) { + return makeHttpCallAsync(() -> buildRetrieveSubscriptionRequest(subscriptionId), + req -> authManagers.get("default").applyAsync(req) + .thenCompose(request -> getClientInstance().executeAsStringAsync(request)), + context -> handleRetrieveSubscriptionResponse(context)); + } + + /** + * Builds the HttpRequest object for retrieveSubscription + */ + private HttpRequest buildRetrieveSubscriptionRequest( + final String subscriptionId) { + //the base uri for api requests + String baseUri = config.getBaseUri(); + + //prepare query string for API call + StringBuilder queryBuilder = new StringBuilder(baseUri + "/v2/subscriptions/{subscription_id}"); + + //process template parameters + Map templateParameters = new HashMap<>(); + templateParameters.put("subscription_id", subscriptionId); + ApiHelper.appendUrlWithTemplateParameters(queryBuilder, templateParameters, true); + //validate and preprocess url + String queryUrl = ApiHelper.cleanUrl(queryBuilder); + + //load all headers for the outgoing API request + Headers headers = new Headers(); + headers.add("Square-Version", config.getSquareVersion()); + headers.add("user-agent", BaseApi.userAgent); + headers.add("accept", "application/json"); + headers.addAll(config.getAdditionalHeaders()); + + //prepare and invoke the API call request to fetch the response + HttpRequest request = getClientInstance().get(queryUrl, headers, null); + + // Invoke the callback before request if its not null + if (getHttpCallback() != null) { + getHttpCallback().onBeforeRequest(request); + } + + return request; + } + + /** + * Processes the response for retrieveSubscription + * @return An object of type RetrieveSubscriptionResponse + */ + private RetrieveSubscriptionResponse handleRetrieveSubscriptionResponse(HttpContext context) + throws ApiException, IOException { + HttpResponse response = context.getResponse(); + + //invoke the callback after response if its not null + if (getHttpCallback() != null) { + getHttpCallback().onAfterResponse(context); + } + + //handle errors defined at the API level + validateResponse(response, context); + + //extract result from the http response + String responseBody = ((HttpStringResponse)response).getBody(); + RetrieveSubscriptionResponse result = ApiHelper.deserialize(responseBody, + RetrieveSubscriptionResponse.class); + + result = result.toBuilder().httpContext(context).build(); + return result; + } + + /** + * Updates a subscription. You can set, modify, and clear the + * `subscription` field values. For more information and examples, see + * [Update subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#update-subscriptions). + * @param subscriptionId Required parameter: The ID for the subscription to update. + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the UpdateSubscriptionResponse response from the API call + */ + public UpdateSubscriptionResponse updateSubscription( + final String subscriptionId, + final UpdateSubscriptionRequest body) throws ApiException, IOException { + HttpRequest request = buildUpdateSubscriptionRequest(subscriptionId, body); + authManagers.get("default").apply(request); + + HttpResponse response = getClientInstance().executeAsString(request); + HttpContext context = new HttpContext(request, response); + + return handleUpdateSubscriptionResponse(context); + } + + /** + * Updates a subscription. You can set, modify, and clear the + * `subscription` field values. For more information and examples, see + * [Update subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#update-subscriptions). + * @param subscriptionId Required parameter: The ID for the subscription to update. + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the UpdateSubscriptionResponse response from the API call + */ + public CompletableFuture updateSubscriptionAsync( + final String subscriptionId, + final UpdateSubscriptionRequest body) { + return makeHttpCallAsync(() -> buildUpdateSubscriptionRequest(subscriptionId, body), + req -> authManagers.get("default").applyAsync(req) + .thenCompose(request -> getClientInstance().executeAsStringAsync(request)), + context -> handleUpdateSubscriptionResponse(context)); + } + + /** + * Builds the HttpRequest object for updateSubscription + */ + private HttpRequest buildUpdateSubscriptionRequest( + final String subscriptionId, + final UpdateSubscriptionRequest body) throws JsonProcessingException { + //the base uri for api requests + String baseUri = config.getBaseUri(); + + //prepare query string for API call + StringBuilder queryBuilder = new StringBuilder(baseUri + "/v2/subscriptions/{subscription_id}"); + + //process template parameters + Map templateParameters = new HashMap<>(); + templateParameters.put("subscription_id", subscriptionId); + ApiHelper.appendUrlWithTemplateParameters(queryBuilder, templateParameters, true); + //validate and preprocess url + String queryUrl = ApiHelper.cleanUrl(queryBuilder); + + //load all headers for the outgoing API request + Headers headers = new Headers(); + headers.add("Square-Version", config.getSquareVersion()); + headers.add("user-agent", BaseApi.userAgent); + headers.add("accept", "application/json"); + headers.add("content-type", "application/json"); + headers.addAll(config.getAdditionalHeaders()); + + //prepare and invoke the API call request to fetch the response + String bodyJson = ApiHelper.serialize(body); + HttpRequest request = getClientInstance().putBody(queryUrl, headers, bodyJson); + + // Invoke the callback before request if its not null + if (getHttpCallback() != null) { + getHttpCallback().onBeforeRequest(request); + } + + return request; + } + + /** + * Processes the response for updateSubscription + * @return An object of type UpdateSubscriptionResponse + */ + private UpdateSubscriptionResponse handleUpdateSubscriptionResponse(HttpContext context) + throws ApiException, IOException { + HttpResponse response = context.getResponse(); + + //invoke the callback after response if its not null + if (getHttpCallback() != null) { + getHttpCallback().onAfterResponse(context); + } + + //handle errors defined at the API level + validateResponse(response, context); + + //extract result from the http response + String responseBody = ((HttpStringResponse)response).getBody(); + UpdateSubscriptionResponse result = ApiHelper.deserialize(responseBody, + UpdateSubscriptionResponse.class); + + result = result.toBuilder().httpContext(context).build(); + return result; + } + + /** + * Cancels a subscription immediately and sets the subscription + * `status` to `CANCELED`. You can also use the `UpdateSubscription` + * endpoint to cancel a subscription at a future date. For more + * information, see + * [CancelSubscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#cancel-subscriptions). + * @param subscriptionId Required parameter: The ID of the subscription to cancel. + * @return Returns the CancelSubscriptionResponse response from the API call + */ + public CancelSubscriptionResponse cancelSubscription( + final String subscriptionId) throws ApiException, IOException { + HttpRequest request = buildCancelSubscriptionRequest(subscriptionId); + authManagers.get("default").apply(request); + + HttpResponse response = getClientInstance().executeAsString(request); + HttpContext context = new HttpContext(request, response); + + return handleCancelSubscriptionResponse(context); + } + + /** + * Cancels a subscription immediately and sets the subscription + * `status` to `CANCELED`. You can also use the `UpdateSubscription` + * endpoint to cancel a subscription at a future date. For more + * information, see + * [CancelSubscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#cancel-subscriptions). + * @param subscriptionId Required parameter: The ID of the subscription to cancel. + * @return Returns the CancelSubscriptionResponse response from the API call + */ + public CompletableFuture cancelSubscriptionAsync( + final String subscriptionId) { + return makeHttpCallAsync(() -> buildCancelSubscriptionRequest(subscriptionId), + req -> authManagers.get("default").applyAsync(req) + .thenCompose(request -> getClientInstance().executeAsStringAsync(request)), + context -> handleCancelSubscriptionResponse(context)); + } + + /** + * Builds the HttpRequest object for cancelSubscription + */ + private HttpRequest buildCancelSubscriptionRequest( + final String subscriptionId) { + //the base uri for api requests + String baseUri = config.getBaseUri(); + + //prepare query string for API call + StringBuilder queryBuilder = new StringBuilder(baseUri + "/v2/subscriptions/{subscription_id}/cancel"); + + //process template parameters + Map templateParameters = new HashMap<>(); + templateParameters.put("subscription_id", subscriptionId); + ApiHelper.appendUrlWithTemplateParameters(queryBuilder, templateParameters, true); + //validate and preprocess url + String queryUrl = ApiHelper.cleanUrl(queryBuilder); + + //load all headers for the outgoing API request + Headers headers = new Headers(); + headers.add("Square-Version", config.getSquareVersion()); + headers.add("user-agent", BaseApi.userAgent); + headers.add("accept", "application/json"); + headers.addAll(config.getAdditionalHeaders()); + + //prepare and invoke the API call request to fetch the response + HttpRequest request = getClientInstance().post(queryUrl, headers, null); + + // Invoke the callback before request if its not null + if (getHttpCallback() != null) { + getHttpCallback().onBeforeRequest(request); + } + + return request; + } + + /** + * Processes the response for cancelSubscription + * @return An object of type CancelSubscriptionResponse + */ + private CancelSubscriptionResponse handleCancelSubscriptionResponse(HttpContext context) + throws ApiException, IOException { + HttpResponse response = context.getResponse(); + + //invoke the callback after response if its not null + if (getHttpCallback() != null) { + getHttpCallback().onAfterResponse(context); + } + + //handle errors defined at the API level + validateResponse(response, context); + + //extract result from the http response + String responseBody = ((HttpStringResponse)response).getBody(); + CancelSubscriptionResponse result = ApiHelper.deserialize(responseBody, + CancelSubscriptionResponse.class); + + result = result.toBuilder().httpContext(context).build(); + return result; + } + + /** + * Lists all events for a specific subscription. + * In the current implementation, only `START_SUBSCRIPTION` and `STOP_SUBSCRIPTION` (when the subscription was canceled) events are returned. + * @param subscriptionId Required parameter: The ID of the subscription to retrieve the events for. + * @param cursor Optional parameter: A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). + * @param limit Optional parameter: The upper limit on the number of subscription events to return in the response. Default: `200` + * @return Returns the ListSubscriptionEventsResponse response from the API call + */ + public ListSubscriptionEventsResponse listSubscriptionEvents( + final String subscriptionId, + final String cursor, + final Integer limit) throws ApiException, IOException { + HttpRequest request = buildListSubscriptionEventsRequest(subscriptionId, cursor, limit); + authManagers.get("default").apply(request); + + HttpResponse response = getClientInstance().executeAsString(request); + HttpContext context = new HttpContext(request, response); + + return handleListSubscriptionEventsResponse(context); + } + + /** + * Lists all events for a specific subscription. + * In the current implementation, only `START_SUBSCRIPTION` and `STOP_SUBSCRIPTION` (when the subscription was canceled) events are returned. + * @param subscriptionId Required parameter: The ID of the subscription to retrieve the events for. + * @param cursor Optional parameter: A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). + * @param limit Optional parameter: The upper limit on the number of subscription events to return in the response. Default: `200` + * @return Returns the ListSubscriptionEventsResponse response from the API call + */ + public CompletableFuture listSubscriptionEventsAsync( + final String subscriptionId, + final String cursor, + final Integer limit) { + return makeHttpCallAsync(() -> buildListSubscriptionEventsRequest(subscriptionId, cursor, limit), + req -> authManagers.get("default").applyAsync(req) + .thenCompose(request -> getClientInstance().executeAsStringAsync(request)), + context -> handleListSubscriptionEventsResponse(context)); + } + + /** + * Builds the HttpRequest object for listSubscriptionEvents + */ + private HttpRequest buildListSubscriptionEventsRequest( + final String subscriptionId, + final String cursor, + final Integer limit) { + //the base uri for api requests + String baseUri = config.getBaseUri(); + + //prepare query string for API call + StringBuilder queryBuilder = new StringBuilder(baseUri + "/v2/subscriptions/{subscription_id}/events"); + + //process template parameters + Map templateParameters = new HashMap<>(); + templateParameters.put("subscription_id", subscriptionId); + ApiHelper.appendUrlWithTemplateParameters(queryBuilder, templateParameters, true); + + //process query parameters + Map queryParameters = new HashMap<>(); + queryParameters.put("cursor", cursor); + queryParameters.put("limit", limit); + ApiHelper.appendUrlWithQueryParameters(queryBuilder, queryParameters); + //validate and preprocess url + String queryUrl = ApiHelper.cleanUrl(queryBuilder); + + //load all headers for the outgoing API request + Headers headers = new Headers(); + headers.add("Square-Version", config.getSquareVersion()); + headers.add("user-agent", BaseApi.userAgent); + headers.add("accept", "application/json"); + headers.addAll(config.getAdditionalHeaders()); + + //prepare and invoke the API call request to fetch the response + HttpRequest request = getClientInstance().get(queryUrl, headers, null); + + // Invoke the callback before request if its not null + if (getHttpCallback() != null) { + getHttpCallback().onBeforeRequest(request); + } + + return request; + } + + /** + * Processes the response for listSubscriptionEvents + * @return An object of type ListSubscriptionEventsResponse + */ + private ListSubscriptionEventsResponse handleListSubscriptionEventsResponse(HttpContext context) + throws ApiException, IOException { + HttpResponse response = context.getResponse(); + + //invoke the callback after response if its not null + if (getHttpCallback() != null) { + getHttpCallback().onAfterResponse(context); + } + + //handle errors defined at the API level + validateResponse(response, context); + + //extract result from the http response + String responseBody = ((HttpStringResponse)response).getBody(); + ListSubscriptionEventsResponse result = ApiHelper.deserialize(responseBody, + ListSubscriptionEventsResponse.class); + + result = result.toBuilder().httpContext(context).build(); + return result; + } + +} diff --git a/src/main/java/com/squareup/square/api/DefaultTeamApi.java b/src/main/java/com/squareup/square/api/DefaultTeamApi.java index c8157ce5..73e97bdc 100644 --- a/src/main/java/com/squareup/square/api/DefaultTeamApi.java +++ b/src/main/java/com/squareup/square/api/DefaultTeamApi.java @@ -825,4 +825,4 @@ private UpdateWageSettingResponse handleUpdateWageSettingResponse(HttpContext co return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultTerminalApi.java b/src/main/java/com/squareup/square/api/DefaultTerminalApi.java index 5c26edcf..18dca1e6 100644 --- a/src/main/java/com/squareup/square/api/DefaultTerminalApi.java +++ b/src/main/java/com/squareup/square/api/DefaultTerminalApi.java @@ -403,4 +403,4 @@ private CancelTerminalCheckoutResponse handleCancelTerminalCheckoutResponse(Http return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultTransactionsApi.java b/src/main/java/com/squareup/square/api/DefaultTransactionsApi.java index 06e11aff..1daa7506 100644 --- a/src/main/java/com/squareup/square/api/DefaultTransactionsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultTransactionsApi.java @@ -888,4 +888,4 @@ private VoidTransactionResponse handleVoidTransactionResponse(HttpContext contex return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultV1EmployeesApi.java b/src/main/java/com/squareup/square/api/DefaultV1EmployeesApi.java index 0cbeefa4..94d64198 100644 --- a/src/main/java/com/squareup/square/api/DefaultV1EmployeesApi.java +++ b/src/main/java/com/squareup/square/api/DefaultV1EmployeesApi.java @@ -1784,4 +1784,4 @@ private V1CashDrawerShift handleRetrieveCashDrawerShiftResponse(HttpContext cont return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultV1ItemsApi.java b/src/main/java/com/squareup/square/api/DefaultV1ItemsApi.java index ff073f64..8de2c1ff 100644 --- a/src/main/java/com/squareup/square/api/DefaultV1ItemsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultV1ItemsApi.java @@ -4344,4 +4344,4 @@ private V1Page handleUpdatePageCellResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultV1LocationsApi.java b/src/main/java/com/squareup/square/api/DefaultV1LocationsApi.java index 9837e4a6..3a9eb52b 100644 --- a/src/main/java/com/squareup/square/api/DefaultV1LocationsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultV1LocationsApi.java @@ -216,4 +216,4 @@ private List handleListLocationsResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DefaultV1TransactionsApi.java b/src/main/java/com/squareup/square/api/DefaultV1TransactionsApi.java index 32c77f58..9df333ae 100644 --- a/src/main/java/com/squareup/square/api/DefaultV1TransactionsApi.java +++ b/src/main/java/com/squareup/square/api/DefaultV1TransactionsApi.java @@ -1293,4 +1293,4 @@ private V1Settlement handleRetrieveSettlementResponse(HttpContext context) return result; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DevicesApi.java b/src/main/java/com/squareup/square/api/DevicesApi.java index 9c97e2f6..a71b7a62 100644 --- a/src/main/java/com/squareup/square/api/DevicesApi.java +++ b/src/main/java/com/squareup/square/api/DevicesApi.java @@ -71,4 +71,4 @@ GetDeviceCodeResponse getDeviceCode( CompletableFuture getDeviceCodeAsync( final String id); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/DisputesApi.java b/src/main/java/com/squareup/square/api/DisputesApi.java index d08a84de..79884af0 100644 --- a/src/main/java/com/squareup/square/api/DisputesApi.java +++ b/src/main/java/com/squareup/square/api/DisputesApi.java @@ -241,4 +241,4 @@ SubmitEvidenceResponse submitEvidence( CompletableFuture submitEvidenceAsync( final String disputeId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/EmployeesApi.java b/src/main/java/com/squareup/square/api/EmployeesApi.java index d32b6218..2d98268e 100644 --- a/src/main/java/com/squareup/square/api/EmployeesApi.java +++ b/src/main/java/com/squareup/square/api/EmployeesApi.java @@ -55,4 +55,4 @@ RetrieveEmployeeResponse retrieveEmployee( CompletableFuture retrieveEmployeeAsync( final String id); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/InventoryApi.java b/src/main/java/com/squareup/square/api/InventoryApi.java index 892c0e43..eaa13142 100644 --- a/src/main/java/com/squareup/square/api/InventoryApi.java +++ b/src/main/java/com/squareup/square/api/InventoryApi.java @@ -203,4 +203,4 @@ CompletableFuture retrieveInventoryChangesAsyn final String locationIds, final String cursor); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/InvoicesApi.java b/src/main/java/com/squareup/square/api/InvoicesApi.java index 70591611..0a6a6a57 100644 --- a/src/main/java/com/squareup/square/api/InvoicesApi.java +++ b/src/main/java/com/squareup/square/api/InvoicesApi.java @@ -238,4 +238,4 @@ CompletableFuture publishInvoiceAsync( final String invoiceId, final PublishInvoiceRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/LaborApi.java b/src/main/java/com/squareup/square/api/LaborApi.java index 9a7e753b..cbfc7c14 100644 --- a/src/main/java/com/squareup/square/api/LaborApi.java +++ b/src/main/java/com/squareup/square/api/LaborApi.java @@ -367,4 +367,4 @@ CompletableFuture updateWorkweekConfigAsync( final String id, final UpdateWorkweekConfigRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/LocationsApi.java b/src/main/java/com/squareup/square/api/LocationsApi.java index f4439cab..ab1f9b86 100644 --- a/src/main/java/com/squareup/square/api/LocationsApi.java +++ b/src/main/java/com/squareup/square/api/LocationsApi.java @@ -93,4 +93,4 @@ CompletableFuture updateLocationAsync( final String locationId, final UpdateLocationRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/LoyaltyApi.java b/src/main/java/com/squareup/square/api/LoyaltyApi.java index 48d52ed0..e47438d6 100644 --- a/src/main/java/com/squareup/square/api/LoyaltyApi.java +++ b/src/main/java/com/squareup/square/api/LoyaltyApi.java @@ -369,4 +369,4 @@ CompletableFuture redeemLoyaltyRewardAsync( final String rewardId, final RedeemLoyaltyRewardRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/MerchantsApi.java b/src/main/java/com/squareup/square/api/MerchantsApi.java index dcdec164..d738e0cc 100644 --- a/src/main/java/com/squareup/square/api/MerchantsApi.java +++ b/src/main/java/com/squareup/square/api/MerchantsApi.java @@ -53,4 +53,4 @@ RetrieveMerchantResponse retrieveMerchant( CompletableFuture retrieveMerchantAsync( final String merchantId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/MobileAuthorizationApi.java b/src/main/java/com/squareup/square/api/MobileAuthorizationApi.java index d97a2827..a301b7fd 100644 --- a/src/main/java/com/squareup/square/api/MobileAuthorizationApi.java +++ b/src/main/java/com/squareup/square/api/MobileAuthorizationApi.java @@ -41,4 +41,4 @@ CreateMobileAuthorizationCodeResponse createMobileAuthorizationCode( CompletableFuture createMobileAuthorizationCodeAsync( final CreateMobileAuthorizationCodeRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/OAuthApi.java b/src/main/java/com/squareup/square/api/OAuthApi.java index 181ee43b..b799f5dd 100644 --- a/src/main/java/com/squareup/square/api/OAuthApi.java +++ b/src/main/java/com/squareup/square/api/OAuthApi.java @@ -146,4 +146,4 @@ ObtainTokenResponse obtainToken( CompletableFuture obtainTokenAsync( final ObtainTokenRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/OrdersApi.java b/src/main/java/com/squareup/square/api/OrdersApi.java index 293c36f4..d73beeb9 100644 --- a/src/main/java/com/squareup/square/api/OrdersApi.java +++ b/src/main/java/com/squareup/square/api/OrdersApi.java @@ -223,4 +223,4 @@ CompletableFuture payOrderAsync( final String orderId, final PayOrderRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/PaymentsApi.java b/src/main/java/com/squareup/square/api/PaymentsApi.java index 6da6f39e..3775f6e7 100644 --- a/src/main/java/com/squareup/square/api/PaymentsApi.java +++ b/src/main/java/com/squareup/square/api/PaymentsApi.java @@ -191,4 +191,4 @@ CompletePaymentResponse completePayment( CompletableFuture completePaymentAsync( final String paymentId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/RefundsApi.java b/src/main/java/com/squareup/square/api/RefundsApi.java index 1ad4c2b8..2cb3a72d 100644 --- a/src/main/java/com/squareup/square/api/RefundsApi.java +++ b/src/main/java/com/squareup/square/api/RefundsApi.java @@ -91,4 +91,4 @@ GetPaymentRefundResponse getPaymentRefund( CompletableFuture getPaymentRefundAsync( final String refundId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/ReportingApi.java b/src/main/java/com/squareup/square/api/ReportingApi.java index 129392b3..60182bb4 100644 --- a/src/main/java/com/squareup/square/api/ReportingApi.java +++ b/src/main/java/com/squareup/square/api/ReportingApi.java @@ -93,4 +93,4 @@ CompletableFuture listAdditionalReci final String sortOrder, final String cursor); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/SubscriptionsApi.java b/src/main/java/com/squareup/square/api/SubscriptionsApi.java new file mode 100644 index 00000000..cd01f73b --- /dev/null +++ b/src/main/java/com/squareup/square/api/SubscriptionsApi.java @@ -0,0 +1,181 @@ +package com.squareup.square.api; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import com.squareup.square.exceptions.ApiException; +import com.squareup.square.models.CancelSubscriptionResponse; +import com.squareup.square.models.CreateSubscriptionRequest; +import com.squareup.square.models.CreateSubscriptionResponse; +import com.squareup.square.models.ListSubscriptionEventsResponse; +import com.squareup.square.models.RetrieveSubscriptionResponse; +import com.squareup.square.models.SearchSubscriptionsRequest; +import com.squareup.square.models.SearchSubscriptionsResponse; +import com.squareup.square.models.UpdateSubscriptionRequest; +import com.squareup.square.models.UpdateSubscriptionResponse; + +/** + * This interface lists all the endpoints of the group. + * This can be overridden for the mock calls. + */ +public interface SubscriptionsApi { + /** + * Creates a subscription for a customer to a subscription plan. + * If you provide a card on file in the request, Square charges the card for + * the subscription. Otherwise, Square bills an invoice to the customer's email + * address. The subscription starts immediately, unless the request includes + * the optional `start_date`. Each individual subscription is associated with a particular location. + * For more information, + * see [Subscription API Overview](https://developer.squareup.com/docs/docs/subscriptions-api/overview). + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the CreateSubscriptionResponse response from the API call + */ + CreateSubscriptionResponse createSubscription( + final CreateSubscriptionRequest body) throws ApiException, IOException; + + /** + * Creates a subscription for a customer to a subscription plan. + * If you provide a card on file in the request, Square charges the card for + * the subscription. Otherwise, Square bills an invoice to the customer's email + * address. The subscription starts immediately, unless the request includes + * the optional `start_date`. Each individual subscription is associated with a particular location. + * For more information, + * see [Subscription API Overview](https://developer.squareup.com/docs/docs/subscriptions-api/overview). + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the CreateSubscriptionResponse response from the API call + */ + CompletableFuture createSubscriptionAsync( + final CreateSubscriptionRequest body); + + /** + * Searches for subscriptions. + * Results are ordered chronologically by subscription creation date. If + * the request specifies more than one location ID, + * the endpoint orders the result + * by location ID, and then by creation date within each location. If no locations are given + * in the query, all locations are searched. + * You can also optionally specify `customer_ids` to search by customer. + * If left unset, all customers + * associated with the specified locations are returned. + * If the request specifies customer IDs, the endpoint orders results + * first by location, within location by customer ID, and within + * customer by subscription creation date. + * For more information, see + * [Retrieve subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#retrieve-subscriptions). + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the SearchSubscriptionsResponse response from the API call + */ + SearchSubscriptionsResponse searchSubscriptions( + final SearchSubscriptionsRequest body) throws ApiException, IOException; + + /** + * Searches for subscriptions. + * Results are ordered chronologically by subscription creation date. If + * the request specifies more than one location ID, + * the endpoint orders the result + * by location ID, and then by creation date within each location. If no locations are given + * in the query, all locations are searched. + * You can also optionally specify `customer_ids` to search by customer. + * If left unset, all customers + * associated with the specified locations are returned. + * If the request specifies customer IDs, the endpoint orders results + * first by location, within location by customer ID, and within + * customer by subscription creation date. + * For more information, see + * [Retrieve subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#retrieve-subscriptions). + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the SearchSubscriptionsResponse response from the API call + */ + CompletableFuture searchSubscriptionsAsync( + final SearchSubscriptionsRequest body); + + /** + * Retrieves a subscription. + * @param subscriptionId Required parameter: The ID of the subscription to retrieve. + * @return Returns the RetrieveSubscriptionResponse response from the API call + */ + RetrieveSubscriptionResponse retrieveSubscription( + final String subscriptionId) throws ApiException, IOException; + + /** + * Retrieves a subscription. + * @param subscriptionId Required parameter: The ID of the subscription to retrieve. + * @return Returns the RetrieveSubscriptionResponse response from the API call + */ + CompletableFuture retrieveSubscriptionAsync( + final String subscriptionId); + + /** + * Updates a subscription. You can set, modify, and clear the + * `subscription` field values. For more information and examples, see + * [Update subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#update-subscriptions). + * @param subscriptionId Required parameter: The ID for the subscription to update. + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the UpdateSubscriptionResponse response from the API call + */ + UpdateSubscriptionResponse updateSubscription( + final String subscriptionId, + final UpdateSubscriptionRequest body) throws ApiException, IOException; + + /** + * Updates a subscription. You can set, modify, and clear the + * `subscription` field values. For more information and examples, see + * [Update subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#update-subscriptions). + * @param subscriptionId Required parameter: The ID for the subscription to update. + * @param body Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details. + * @return Returns the UpdateSubscriptionResponse response from the API call + */ + CompletableFuture updateSubscriptionAsync( + final String subscriptionId, + final UpdateSubscriptionRequest body); + + /** + * Cancels a subscription immediately and sets the subscription + * `status` to `CANCELED`. You can also use the `UpdateSubscription` + * endpoint to cancel a subscription at a future date. For more + * information, see + * [CancelSubscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#cancel-subscriptions). + * @param subscriptionId Required parameter: The ID of the subscription to cancel. + * @return Returns the CancelSubscriptionResponse response from the API call + */ + CancelSubscriptionResponse cancelSubscription( + final String subscriptionId) throws ApiException, IOException; + + /** + * Cancels a subscription immediately and sets the subscription + * `status` to `CANCELED`. You can also use the `UpdateSubscription` + * endpoint to cancel a subscription at a future date. For more + * information, see + * [CancelSubscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/overview#cancel-subscriptions). + * @param subscriptionId Required parameter: The ID of the subscription to cancel. + * @return Returns the CancelSubscriptionResponse response from the API call + */ + CompletableFuture cancelSubscriptionAsync( + final String subscriptionId); + + /** + * Lists all events for a specific subscription. + * In the current implementation, only `START_SUBSCRIPTION` and `STOP_SUBSCRIPTION` (when the subscription was canceled) events are returned. + * @param subscriptionId Required parameter: The ID of the subscription to retrieve the events for. + * @param cursor Optional parameter: A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). + * @param limit Optional parameter: The upper limit on the number of subscription events to return in the response. Default: `200` + * @return Returns the ListSubscriptionEventsResponse response from the API call + */ + ListSubscriptionEventsResponse listSubscriptionEvents( + final String subscriptionId, + final String cursor, + final Integer limit) throws ApiException, IOException; + + /** + * Lists all events for a specific subscription. + * In the current implementation, only `START_SUBSCRIPTION` and `STOP_SUBSCRIPTION` (when the subscription was canceled) events are returned. + * @param subscriptionId Required parameter: The ID of the subscription to retrieve the events for. + * @param cursor Optional parameter: A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). + * @param limit Optional parameter: The upper limit on the number of subscription events to return in the response. Default: `200` + * @return Returns the ListSubscriptionEventsResponse response from the API call + */ + CompletableFuture listSubscriptionEventsAsync( + final String subscriptionId, + final String cursor, + final Integer limit); + +} diff --git a/src/main/java/com/squareup/square/api/TeamApi.java b/src/main/java/com/squareup/square/api/TeamApi.java index 8a36318d..b67af0a1 100644 --- a/src/main/java/com/squareup/square/api/TeamApi.java +++ b/src/main/java/com/squareup/square/api/TeamApi.java @@ -205,4 +205,4 @@ CompletableFuture updateWageSettingAsync( final String teamMemberId, final UpdateWageSettingRequest body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/TerminalApi.java b/src/main/java/com/squareup/square/api/TerminalApi.java index e41eb588..49c667c3 100644 --- a/src/main/java/com/squareup/square/api/TerminalApi.java +++ b/src/main/java/com/squareup/square/api/TerminalApi.java @@ -79,4 +79,4 @@ CancelTerminalCheckoutResponse cancelTerminalCheckout( CompletableFuture cancelTerminalCheckoutAsync( final String checkoutId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/TransactionsApi.java b/src/main/java/com/squareup/square/api/TransactionsApi.java index 1a4ebe68..065c931d 100644 --- a/src/main/java/com/squareup/square/api/TransactionsApi.java +++ b/src/main/java/com/squareup/square/api/TransactionsApi.java @@ -291,4 +291,4 @@ CompletableFuture voidTransactionAsync( final String locationId, final String transactionId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/V1EmployeesApi.java b/src/main/java/com/squareup/square/api/V1EmployeesApi.java index 301ac230..893881e3 100644 --- a/src/main/java/com/squareup/square/api/V1EmployeesApi.java +++ b/src/main/java/com/squareup/square/api/V1EmployeesApi.java @@ -519,4 +519,4 @@ CompletableFuture retrieveCashDrawerShiftAsync( final String locationId, final String shiftId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/V1ItemsApi.java b/src/main/java/com/squareup/square/api/V1ItemsApi.java index b7faa299..566b5e48 100644 --- a/src/main/java/com/squareup/square/api/V1ItemsApi.java +++ b/src/main/java/com/squareup/square/api/V1ItemsApi.java @@ -1178,4 +1178,4 @@ CompletableFuture updatePageCellAsync( final String pageId, final V1PageCell body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/V1LocationsApi.java b/src/main/java/com/squareup/square/api/V1LocationsApi.java index ab381491..287811e2 100644 --- a/src/main/java/com/squareup/square/api/V1LocationsApi.java +++ b/src/main/java/com/squareup/square/api/V1LocationsApi.java @@ -47,4 +47,4 @@ public interface V1LocationsApi { @Deprecated CompletableFuture> listLocationsAsync(); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/api/V1TransactionsApi.java b/src/main/java/com/squareup/square/api/V1TransactionsApi.java index 595a2def..e91e9b98 100644 --- a/src/main/java/com/squareup/square/api/V1TransactionsApi.java +++ b/src/main/java/com/squareup/square/api/V1TransactionsApi.java @@ -381,4 +381,4 @@ CompletableFuture retrieveSettlementAsync( final String locationId, final String settlementId); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/exceptions/ApiException.java b/src/main/java/com/squareup/square/exceptions/ApiException.java index 8aec5dca..be9728cd 100644 --- a/src/main/java/com/squareup/square/exceptions/ApiException.java +++ b/src/main/java/com/squareup/square/exceptions/ApiException.java @@ -85,4 +85,4 @@ public ApiException(String reason, HttpContext context) { // Can throw exception while object mapper tries to convert results from JSON tree into given value type. } } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/http/client/HttpCallback.java b/src/main/java/com/squareup/square/http/client/HttpCallback.java index 20f11dac..19234e1f 100644 --- a/src/main/java/com/squareup/square/http/client/HttpCallback.java +++ b/src/main/java/com/squareup/square/http/client/HttpCallback.java @@ -17,4 +17,4 @@ public interface HttpCallback { * @param context Context for the HTTP call */ public void onAfterResponse(HttpContext context); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/http/client/HttpClient.java b/src/main/java/com/squareup/square/http/client/HttpClient.java index bd90bbfb..943477f7 100644 --- a/src/main/java/com/squareup/square/http/client/HttpClient.java +++ b/src/main/java/com/squareup/square/http/client/HttpClient.java @@ -102,4 +102,4 @@ HttpRequest delete(String queryUrl, */ public HttpBodyRequest deleteBody(String queryUrl, Headers headers, Object body); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/http/client/HttpClientConfiguration.java b/src/main/java/com/squareup/square/http/client/HttpClientConfiguration.java index 6cf0dcc2..e05081d9 100644 --- a/src/main/java/com/squareup/square/http/client/HttpClientConfiguration.java +++ b/src/main/java/com/squareup/square/http/client/HttpClientConfiguration.java @@ -27,4 +27,4 @@ public void setTimeout(long timeout) { } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/http/client/HttpContext.java b/src/main/java/com/squareup/square/http/client/HttpContext.java index 00cf3591..472a7947 100644 --- a/src/main/java/com/squareup/square/http/client/HttpContext.java +++ b/src/main/java/com/squareup/square/http/client/HttpContext.java @@ -35,4 +35,4 @@ public HttpRequest getRequest() { public HttpResponse getResponse() { return response; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/http/client/ReadonlyHttpClientConfiguration.java b/src/main/java/com/squareup/square/http/client/ReadonlyHttpClientConfiguration.java index ecd0cf83..e6ba739f 100644 --- a/src/main/java/com/squareup/square/http/client/ReadonlyHttpClientConfiguration.java +++ b/src/main/java/com/squareup/square/http/client/ReadonlyHttpClientConfiguration.java @@ -11,4 +11,4 @@ public interface ReadonlyHttpClientConfiguration { public long getTimeout(); -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/http/response/HttpResponse.java b/src/main/java/com/squareup/square/http/response/HttpResponse.java index ab9d3f21..d926bbfb 100644 --- a/src/main/java/com/squareup/square/http/response/HttpResponse.java +++ b/src/main/java/com/squareup/square/http/response/HttpResponse.java @@ -47,4 +47,4 @@ public HttpResponse(int code, Headers headers, InputStream rawBody) { this.headers = headers; this.rawBody = rawBody; } -} \ No newline at end of file +} diff --git a/src/main/java/com/squareup/square/models/CancelSubscriptionResponse.java b/src/main/java/com/squareup/square/models/CancelSubscriptionResponse.java new file mode 100644 index 00000000..a74b51e6 --- /dev/null +++ b/src/main/java/com/squareup/square/models/CancelSubscriptionResponse.java @@ -0,0 +1,142 @@ +package com.squareup.square.models; + +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.squareup.square.http.client.HttpContext; + + +/** + * This is a model class for CancelSubscriptionResponse type. + */ +public class CancelSubscriptionResponse { + + /** + * Initialization constructor. + * @param errors + * @param subscription + */ + @JsonCreator + public CancelSubscriptionResponse( + @JsonProperty("errors") List errors, + @JsonProperty("subscription") Subscription subscription) { + this.errors = errors; + this.subscription = subscription; + } + + private HttpContext httpContext; + private final List errors; + private final Subscription subscription; + + public HttpContext getContext() { + return httpContext; + } + + /** + * Getter for Errors. + * Information about errors encountered during the request. + */ + @JsonGetter("errors") + public List getErrors() { + return this.errors; + } + + /** + * Getter for Subscription. + * Represents a customer subscription to a subscription plan. + * For an overview of the `Subscription` type, see + * [Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). + */ + @JsonGetter("subscription") + public Subscription getSubscription() { + return this.subscription; + } + + + @Override + public int hashCode() { + return Objects.hash(errors, subscription); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof CancelSubscriptionResponse)) { + return false; + } + CancelSubscriptionResponse cancelSubscriptionResponse = (CancelSubscriptionResponse) obj; + return Objects.equals(errors, cancelSubscriptionResponse.errors) && + Objects.equals(subscription, cancelSubscriptionResponse.subscription); + } + + /** + * Builds a new {@link CancelSubscriptionResponse.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link CancelSubscriptionResponse.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .errors(getErrors()) + .subscription(getSubscription()); + return builder; + } + + /** + * Class to build instances of {@link CancelSubscriptionResponse} + */ + public static class Builder { + private HttpContext httpContext; + private List errors; + private Subscription subscription; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for httpContext + * @param httpContext + * @return Builder + */ + public Builder httpContext(HttpContext httpContext) { + this.httpContext = httpContext; + return this; + } + /** + * Setter for errors + * @param errors + * @return Builder + */ + public Builder errors(List errors) { + this.errors = errors; + return this; + } + /** + * Setter for subscription + * @param subscription + * @return Builder + */ + public Builder subscription(Subscription subscription) { + this.subscription = subscription; + return this; + } + + /** + * Builds a new {@link CancelSubscriptionResponse} object using the set fields. + * @return {@link CancelSubscriptionResponse} + */ + public CancelSubscriptionResponse build() { + CancelSubscriptionResponse model = new CancelSubscriptionResponse(errors, + subscription); + model.httpContext = httpContext; + return model; + } + } +} diff --git a/src/main/java/com/squareup/square/models/CatalogObject.java b/src/main/java/com/squareup/square/models/CatalogObject.java index 876edf93..f4564f56 100644 --- a/src/main/java/com/squareup/square/models/CatalogObject.java +++ b/src/main/java/com/squareup/square/models/CatalogObject.java @@ -38,6 +38,7 @@ public class CatalogObject { * @param pricingRuleData * @param imageData * @param measurementUnitData + * @param subscriptionPlanData * @param itemOptionData * @param itemOptionValueData * @param customAttributeDefinitionData @@ -68,6 +69,7 @@ public CatalogObject( @JsonProperty("pricing_rule_data") CatalogPricingRule pricingRuleData, @JsonProperty("image_data") CatalogImage imageData, @JsonProperty("measurement_unit_data") CatalogMeasurementUnit measurementUnitData, + @JsonProperty("subscription_plan_data") CatalogSubscriptionPlan subscriptionPlanData, @JsonProperty("item_option_data") CatalogItemOption itemOptionData, @JsonProperty("item_option_value_data") CatalogItemOptionValue itemOptionValueData, @JsonProperty("custom_attribute_definition_data") CatalogCustomAttributeDefinition customAttributeDefinitionData, @@ -95,6 +97,7 @@ public CatalogObject( this.pricingRuleData = pricingRuleData; this.imageData = imageData; this.measurementUnitData = measurementUnitData; + this.subscriptionPlanData = subscriptionPlanData; this.itemOptionData = itemOptionData; this.itemOptionValueData = itemOptionValueData; this.customAttributeDefinitionData = customAttributeDefinitionData; @@ -124,6 +127,7 @@ public CatalogObject( private final CatalogPricingRule pricingRuleData; private final CatalogImage imageData; private final CatalogMeasurementUnit measurementUnitData; + private final CatalogSubscriptionPlan subscriptionPlanData; private final CatalogItemOption itemOptionData; private final CatalogItemOptionValue itemOptionValueData; private final CatalogCustomAttributeDefinition customAttributeDefinitionData; @@ -373,6 +377,16 @@ public CatalogMeasurementUnit getMeasurementUnitData() { return this.measurementUnitData; } + /** + * Getter for SubscriptionPlanData. + * Describes a subscription plan. For more information, see + * [Set Up and Manage a Subscription Plan](https://developer.squareup.com/docs/docs/subscriptions-api/setup-plan). + */ + @JsonGetter("subscription_plan_data") + public CatalogSubscriptionPlan getSubscriptionPlanData() { + return this.subscriptionPlanData; + } + /** * Getter for ItemOptionData. * A group of variations for a `CatalogItem`. @@ -422,8 +436,8 @@ public int hashCode() { catalogV1Ids, presentAtAllLocations, presentAtLocationIds, absentAtLocationIds, imageId, itemData, categoryData, itemVariationData, taxData, discountData, modifierListData, modifierData, timePeriodData, productSetData, pricingRuleData, imageData, - measurementUnitData, itemOptionData, itemOptionValueData, customAttributeDefinitionData, - quickAmountsSettingsData); + measurementUnitData, subscriptionPlanData, itemOptionData, itemOptionValueData, + customAttributeDefinitionData, quickAmountsSettingsData); } @Override @@ -458,6 +472,7 @@ public boolean equals(Object obj) { Objects.equals(pricingRuleData, catalogObject.pricingRuleData) && Objects.equals(imageData, catalogObject.imageData) && Objects.equals(measurementUnitData, catalogObject.measurementUnitData) && + Objects.equals(subscriptionPlanData, catalogObject.subscriptionPlanData) && Objects.equals(itemOptionData, catalogObject.itemOptionData) && Objects.equals(itemOptionValueData, catalogObject.itemOptionValueData) && Objects.equals(customAttributeDefinitionData, catalogObject.customAttributeDefinitionData) && @@ -493,6 +508,7 @@ public Builder toBuilder() { .pricingRuleData(getPricingRuleData()) .imageData(getImageData()) .measurementUnitData(getMeasurementUnitData()) + .subscriptionPlanData(getSubscriptionPlanData()) .itemOptionData(getItemOptionData()) .itemOptionValueData(getItemOptionValueData()) .customAttributeDefinitionData(getCustomAttributeDefinitionData()) @@ -527,6 +543,7 @@ public static class Builder { private CatalogPricingRule pricingRuleData; private CatalogImage imageData; private CatalogMeasurementUnit measurementUnitData; + private CatalogSubscriptionPlan subscriptionPlanData; private CatalogItemOption itemOptionData; private CatalogItemOptionValue itemOptionValueData; private CatalogCustomAttributeDefinition customAttributeDefinitionData; @@ -748,6 +765,15 @@ public Builder measurementUnitData(CatalogMeasurementUnit measurementUnitData) { this.measurementUnitData = measurementUnitData; return this; } + /** + * Setter for subscriptionPlanData + * @param subscriptionPlanData + * @return Builder + */ + public Builder subscriptionPlanData(CatalogSubscriptionPlan subscriptionPlanData) { + this.subscriptionPlanData = subscriptionPlanData; + return this; + } /** * Setter for itemOptionData * @param itemOptionData @@ -813,6 +839,7 @@ public CatalogObject build() { pricingRuleData, imageData, measurementUnitData, + subscriptionPlanData, itemOptionData, itemOptionValueData, customAttributeDefinitionData, diff --git a/src/main/java/com/squareup/square/models/CatalogSubscriptionPlan.java b/src/main/java/com/squareup/square/models/CatalogSubscriptionPlan.java new file mode 100644 index 00000000..32f1e2c1 --- /dev/null +++ b/src/main/java/com/squareup/square/models/CatalogSubscriptionPlan.java @@ -0,0 +1,121 @@ +package com.squareup.square.models; + +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for CatalogSubscriptionPlan type. + */ +public class CatalogSubscriptionPlan { + + /** + * Initialization constructor. + * @param name + * @param phases + */ + @JsonCreator + public CatalogSubscriptionPlan( + @JsonProperty("name") String name, + @JsonProperty("phases") List phases) { + this.name = name; + this.phases = phases; + } + + private final String name; + private final List phases; + /** + * Getter for Name. + * The name of the plan. + */ + @JsonGetter("name") + public String getName() { + return this.name; + } + + /** + * Getter for Phases. + * A list of SubscriptionPhase containing the [SubscriptionPhase](#type-SubscriptionPhase) for this plan. + */ + @JsonGetter("phases") + public List getPhases() { + return this.phases; + } + + + @Override + public int hashCode() { + return Objects.hash(name, phases); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof CatalogSubscriptionPlan)) { + return false; + } + CatalogSubscriptionPlan catalogSubscriptionPlan = (CatalogSubscriptionPlan) obj; + return Objects.equals(name, catalogSubscriptionPlan.name) && + Objects.equals(phases, catalogSubscriptionPlan.phases); + } + + /** + * Builds a new {@link CatalogSubscriptionPlan.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link CatalogSubscriptionPlan.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .name(getName()) + .phases(getPhases()); + return builder; + } + + /** + * Class to build instances of {@link CatalogSubscriptionPlan} + */ + public static class Builder { + private String name; + private List phases; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for name + * @param name + * @return Builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + /** + * Setter for phases + * @param phases + * @return Builder + */ + public Builder phases(List phases) { + this.phases = phases; + return this; + } + + /** + * Builds a new {@link CatalogSubscriptionPlan} object using the set fields. + * @return {@link CatalogSubscriptionPlan} + */ + public CatalogSubscriptionPlan build() { + return new CatalogSubscriptionPlan(name, + phases); + } + } +} diff --git a/src/main/java/com/squareup/square/models/CreateCustomerRequest.java b/src/main/java/com/squareup/square/models/CreateCustomerRequest.java index 6b6ea291..e8cd4427 100644 --- a/src/main/java/com/squareup/square/models/CreateCustomerRequest.java +++ b/src/main/java/com/squareup/square/models/CreateCustomerRequest.java @@ -64,7 +64,7 @@ public CreateCustomerRequest( private final String birthday; /** * Getter for IdempotencyKey. - * The idempotency key for the request. See the + * The idempotency key for the request. See the * [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency) guide for more information. */ @JsonGetter("idempotency_key") diff --git a/src/main/java/com/squareup/square/models/CreateSubscriptionRequest.java b/src/main/java/com/squareup/square/models/CreateSubscriptionRequest.java new file mode 100644 index 00000000..c2944852 --- /dev/null +++ b/src/main/java/com/squareup/square/models/CreateSubscriptionRequest.java @@ -0,0 +1,355 @@ +package com.squareup.square.models; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for CreateSubscriptionRequest type. + */ +public class CreateSubscriptionRequest { + + /** + * Initialization constructor. + * @param idempotencyKey + * @param locationId + * @param planId + * @param customerId + * @param startDate + * @param canceledDate + * @param taxPercentage + * @param priceOverrideMoney + * @param cardId + * @param timezone + */ + @JsonCreator + public CreateSubscriptionRequest( + @JsonProperty("idempotency_key") String idempotencyKey, + @JsonProperty("location_id") String locationId, + @JsonProperty("plan_id") String planId, + @JsonProperty("customer_id") String customerId, + @JsonProperty("start_date") String startDate, + @JsonProperty("canceled_date") String canceledDate, + @JsonProperty("tax_percentage") String taxPercentage, + @JsonProperty("price_override_money") Money priceOverrideMoney, + @JsonProperty("card_id") String cardId, + @JsonProperty("timezone") String timezone) { + this.idempotencyKey = idempotencyKey; + this.locationId = locationId; + this.planId = planId; + this.customerId = customerId; + this.startDate = startDate; + this.canceledDate = canceledDate; + this.taxPercentage = taxPercentage; + this.priceOverrideMoney = priceOverrideMoney; + this.cardId = cardId; + this.timezone = timezone; + } + + private final String idempotencyKey; + private final String locationId; + private final String planId; + private final String customerId; + private final String startDate; + private final String canceledDate; + private final String taxPercentage; + private final Money priceOverrideMoney; + private final String cardId; + private final String timezone; + /** + * Getter for IdempotencyKey. + * A unique string that identifies this `CreateSubscription` request. + * If you do not provide a unique string (or provide an empty string as the value), + * the endpoint treats each request as independent. + * For more information, see [Idempotency keys](https://developer.squareup.com/docs/docs/working-with-apis/idempotency). + */ + @JsonGetter("idempotency_key") + public String getIdempotencyKey() { + return this.idempotencyKey; + } + + /** + * Getter for LocationId. + * The ID of the location the subscription is associated with. + */ + @JsonGetter("location_id") + public String getLocationId() { + return this.locationId; + } + + /** + * Getter for PlanId. + * The ID of the subscription plan. For more information, see + * [Subscription Plan Overview](https://developer.squareup.com/docs/docs/subscriptions/overview). + */ + @JsonGetter("plan_id") + public String getPlanId() { + return this.planId; + } + + /** + * Getter for CustomerId. + * The ID of the [customer](#type-customer) profile. + */ + @JsonGetter("customer_id") + public String getCustomerId() { + return this.customerId; + } + + /** + * Getter for StartDate. + * The start date of the subscription, in YYYY-MM-DD format. For example, + * 2013-01-15. If the start date is left empty, the subscription begins + * immediately. + */ + @JsonGetter("start_date") + public String getStartDate() { + return this.startDate; + } + + /** + * Getter for CanceledDate. + * The date when the subscription should be canceled, in + * YYYY-MM-DD format (for example, 2025-02-29). This overrides the plan configuration + * if it comes before the date the subscription would otherwise end. + */ + @JsonGetter("canceled_date") + public String getCanceledDate() { + return this.canceledDate; + } + + /** + * Getter for TaxPercentage. + * The tax to add when billing the subscription. + * The percentage is expressed in decimal form, using a `'.'` as the decimal + * separator and without a `'%'` sign. For example, a value of 7.5 + * corresponds to 7.5%. + */ + @JsonGetter("tax_percentage") + public String getTaxPercentage() { + return this.taxPercentage; + } + + /** + * Getter for PriceOverrideMoney. + * Represents an amount of money. `Money` fields can be signed or unsigned. + * Fields that do not explicitly define whether they are signed or unsigned are + * considered unsigned and can only hold positive amounts. For signed fields, the + * sign of the value indicates the purpose of the money transfer. See + * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts) + * for more information. + */ + @JsonGetter("price_override_money") + public Money getPriceOverrideMoney() { + return this.priceOverrideMoney; + } + + /** + * Getter for CardId. + * The ID of the [customer](#type-customer) [card](#type-card) to charge. + * If not specified, Square sends an invoice via email. For an example to + * create a customer and add a card on file, see [Subscriptions Walkthrough](https://developer.squareup.com/docs/docs/subscriptions-api/walkthrough). + */ + @JsonGetter("card_id") + public String getCardId() { + return this.cardId; + } + + /** + * Getter for Timezone. + * The timezone that is used in date calculations for the subscription. If unset, defaults to + * the location timezone. If a timezone is not configured for the location, defaults to "America/New_York". + * Format: the IANA Timezone Database identifier for the location timezone. For + * a list of time zones, see [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + */ + @JsonGetter("timezone") + public String getTimezone() { + return this.timezone; + } + + + @Override + public int hashCode() { + return Objects.hash(idempotencyKey, locationId, planId, customerId, startDate, canceledDate, + taxPercentage, priceOverrideMoney, cardId, timezone); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof CreateSubscriptionRequest)) { + return false; + } + CreateSubscriptionRequest createSubscriptionRequest = (CreateSubscriptionRequest) obj; + return Objects.equals(idempotencyKey, createSubscriptionRequest.idempotencyKey) && + Objects.equals(locationId, createSubscriptionRequest.locationId) && + Objects.equals(planId, createSubscriptionRequest.planId) && + Objects.equals(customerId, createSubscriptionRequest.customerId) && + Objects.equals(startDate, createSubscriptionRequest.startDate) && + Objects.equals(canceledDate, createSubscriptionRequest.canceledDate) && + Objects.equals(taxPercentage, createSubscriptionRequest.taxPercentage) && + Objects.equals(priceOverrideMoney, createSubscriptionRequest.priceOverrideMoney) && + Objects.equals(cardId, createSubscriptionRequest.cardId) && + Objects.equals(timezone, createSubscriptionRequest.timezone); + } + + /** + * Builds a new {@link CreateSubscriptionRequest.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link CreateSubscriptionRequest.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder(idempotencyKey, + locationId, + planId, + customerId) + .startDate(getStartDate()) + .canceledDate(getCanceledDate()) + .taxPercentage(getTaxPercentage()) + .priceOverrideMoney(getPriceOverrideMoney()) + .cardId(getCardId()) + .timezone(getTimezone()); + return builder; + } + + /** + * Class to build instances of {@link CreateSubscriptionRequest} + */ + public static class Builder { + private String idempotencyKey; + private String locationId; + private String planId; + private String customerId; + private String startDate; + private String canceledDate; + private String taxPercentage; + private Money priceOverrideMoney; + private String cardId; + private String timezone; + + /** + * Initialization constructor + */ + public Builder(String idempotencyKey, + String locationId, + String planId, + String customerId) { + this.idempotencyKey = idempotencyKey; + this.locationId = locationId; + this.planId = planId; + this.customerId = customerId; + } + + /** + * Setter for idempotencyKey + * @param idempotencyKey + * @return Builder + */ + public Builder idempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + return this; + } + /** + * Setter for locationId + * @param locationId + * @return Builder + */ + public Builder locationId(String locationId) { + this.locationId = locationId; + return this; + } + /** + * Setter for planId + * @param planId + * @return Builder + */ + public Builder planId(String planId) { + this.planId = planId; + return this; + } + /** + * Setter for customerId + * @param customerId + * @return Builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + /** + * Setter for startDate + * @param startDate + * @return Builder + */ + public Builder startDate(String startDate) { + this.startDate = startDate; + return this; + } + /** + * Setter for canceledDate + * @param canceledDate + * @return Builder + */ + public Builder canceledDate(String canceledDate) { + this.canceledDate = canceledDate; + return this; + } + /** + * Setter for taxPercentage + * @param taxPercentage + * @return Builder + */ + public Builder taxPercentage(String taxPercentage) { + this.taxPercentage = taxPercentage; + return this; + } + /** + * Setter for priceOverrideMoney + * @param priceOverrideMoney + * @return Builder + */ + public Builder priceOverrideMoney(Money priceOverrideMoney) { + this.priceOverrideMoney = priceOverrideMoney; + return this; + } + /** + * Setter for cardId + * @param cardId + * @return Builder + */ + public Builder cardId(String cardId) { + this.cardId = cardId; + return this; + } + /** + * Setter for timezone + * @param timezone + * @return Builder + */ + public Builder timezone(String timezone) { + this.timezone = timezone; + return this; + } + + /** + * Builds a new {@link CreateSubscriptionRequest} object using the set fields. + * @return {@link CreateSubscriptionRequest} + */ + public CreateSubscriptionRequest build() { + return new CreateSubscriptionRequest(idempotencyKey, + locationId, + planId, + customerId, + startDate, + canceledDate, + taxPercentage, + priceOverrideMoney, + cardId, + timezone); + } + } +} diff --git a/src/main/java/com/squareup/square/models/CreateSubscriptionResponse.java b/src/main/java/com/squareup/square/models/CreateSubscriptionResponse.java new file mode 100644 index 00000000..e34d5d25 --- /dev/null +++ b/src/main/java/com/squareup/square/models/CreateSubscriptionResponse.java @@ -0,0 +1,142 @@ +package com.squareup.square.models; + +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.squareup.square.http.client.HttpContext; + + +/** + * This is a model class for CreateSubscriptionResponse type. + */ +public class CreateSubscriptionResponse { + + /** + * Initialization constructor. + * @param errors + * @param subscription + */ + @JsonCreator + public CreateSubscriptionResponse( + @JsonProperty("errors") List errors, + @JsonProperty("subscription") Subscription subscription) { + this.errors = errors; + this.subscription = subscription; + } + + private HttpContext httpContext; + private final List errors; + private final Subscription subscription; + + public HttpContext getContext() { + return httpContext; + } + + /** + * Getter for Errors. + * Information about errors encountered during the request. + */ + @JsonGetter("errors") + public List getErrors() { + return this.errors; + } + + /** + * Getter for Subscription. + * Represents a customer subscription to a subscription plan. + * For an overview of the `Subscription` type, see + * [Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). + */ + @JsonGetter("subscription") + public Subscription getSubscription() { + return this.subscription; + } + + + @Override + public int hashCode() { + return Objects.hash(errors, subscription); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof CreateSubscriptionResponse)) { + return false; + } + CreateSubscriptionResponse createSubscriptionResponse = (CreateSubscriptionResponse) obj; + return Objects.equals(errors, createSubscriptionResponse.errors) && + Objects.equals(subscription, createSubscriptionResponse.subscription); + } + + /** + * Builds a new {@link CreateSubscriptionResponse.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link CreateSubscriptionResponse.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .errors(getErrors()) + .subscription(getSubscription()); + return builder; + } + + /** + * Class to build instances of {@link CreateSubscriptionResponse} + */ + public static class Builder { + private HttpContext httpContext; + private List errors; + private Subscription subscription; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for httpContext + * @param httpContext + * @return Builder + */ + public Builder httpContext(HttpContext httpContext) { + this.httpContext = httpContext; + return this; + } + /** + * Setter for errors + * @param errors + * @return Builder + */ + public Builder errors(List errors) { + this.errors = errors; + return this; + } + /** + * Setter for subscription + * @param subscription + * @return Builder + */ + public Builder subscription(Subscription subscription) { + this.subscription = subscription; + return this; + } + + /** + * Builds a new {@link CreateSubscriptionResponse} object using the set fields. + * @return {@link CreateSubscriptionResponse} + */ + public CreateSubscriptionResponse build() { + CreateSubscriptionResponse model = new CreateSubscriptionResponse(errors, + subscription); + model.httpContext = httpContext; + return model; + } + } +} diff --git a/src/main/java/com/squareup/square/models/ListSubscriptionEventsRequest.java b/src/main/java/com/squareup/square/models/ListSubscriptionEventsRequest.java new file mode 100644 index 00000000..db9fed84 --- /dev/null +++ b/src/main/java/com/squareup/square/models/ListSubscriptionEventsRequest.java @@ -0,0 +1,124 @@ +package com.squareup.square.models; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for ListSubscriptionEventsRequest type. + */ +public class ListSubscriptionEventsRequest { + + /** + * Initialization constructor. + * @param cursor + * @param limit + */ + @JsonCreator + public ListSubscriptionEventsRequest( + @JsonProperty("cursor") String cursor, + @JsonProperty("limit") Integer limit) { + this.cursor = cursor; + this.limit = limit; + } + + private final String cursor; + private final Integer limit; + /** + * Getter for Cursor. + * A pagination cursor returned by a previous call to this endpoint. + * Provide this to retrieve the next set of results for the original query. + * For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). + */ + @JsonGetter("cursor") + public String getCursor() { + return this.cursor; + } + + /** + * Getter for Limit. + * The upper limit on the number of subscription events to return + * in the response. + * Default: `200` + */ + @JsonGetter("limit") + public Integer getLimit() { + return this.limit; + } + + + @Override + public int hashCode() { + return Objects.hash(cursor, limit); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof ListSubscriptionEventsRequest)) { + return false; + } + ListSubscriptionEventsRequest listSubscriptionEventsRequest = (ListSubscriptionEventsRequest) obj; + return Objects.equals(cursor, listSubscriptionEventsRequest.cursor) && + Objects.equals(limit, listSubscriptionEventsRequest.limit); + } + + /** + * Builds a new {@link ListSubscriptionEventsRequest.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link ListSubscriptionEventsRequest.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .cursor(getCursor()) + .limit(getLimit()); + return builder; + } + + /** + * Class to build instances of {@link ListSubscriptionEventsRequest} + */ + public static class Builder { + private String cursor; + private Integer limit; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for cursor + * @param cursor + * @return Builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + /** + * Setter for limit + * @param limit + * @return Builder + */ + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + /** + * Builds a new {@link ListSubscriptionEventsRequest} object using the set fields. + * @return {@link ListSubscriptionEventsRequest} + */ + public ListSubscriptionEventsRequest build() { + return new ListSubscriptionEventsRequest(cursor, + limit); + } + } +} diff --git a/src/main/java/com/squareup/square/models/ListSubscriptionEventsResponse.java b/src/main/java/com/squareup/square/models/ListSubscriptionEventsResponse.java new file mode 100644 index 00000000..ce892b17 --- /dev/null +++ b/src/main/java/com/squareup/square/models/ListSubscriptionEventsResponse.java @@ -0,0 +1,169 @@ +package com.squareup.square.models; + +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.squareup.square.http.client.HttpContext; + + +/** + * This is a model class for ListSubscriptionEventsResponse type. + */ +public class ListSubscriptionEventsResponse { + + /** + * Initialization constructor. + * @param errors + * @param subscriptionEvents + * @param cursor + */ + @JsonCreator + public ListSubscriptionEventsResponse( + @JsonProperty("errors") List errors, + @JsonProperty("subscription_events") List subscriptionEvents, + @JsonProperty("cursor") String cursor) { + this.errors = errors; + this.subscriptionEvents = subscriptionEvents; + this.cursor = cursor; + } + + private HttpContext httpContext; + private final List errors; + private final List subscriptionEvents; + private final String cursor; + + public HttpContext getContext() { + return httpContext; + } + + /** + * Getter for Errors. + * Information about errors encountered during the request. + */ + @JsonGetter("errors") + public List getErrors() { + return this.errors; + } + + /** + * Getter for SubscriptionEvents. + * The `SubscriptionEvents` retrieved. + */ + @JsonGetter("subscription_events") + public List getSubscriptionEvents() { + return this.subscriptionEvents; + } + + /** + * Getter for Cursor. + * When a response is truncated, it includes a cursor that you can + * use in a subsequent request to fetch the next set of events. + * If empty, this is the final response. + * For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). + */ + @JsonGetter("cursor") + public String getCursor() { + return this.cursor; + } + + + @Override + public int hashCode() { + return Objects.hash(errors, subscriptionEvents, cursor); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof ListSubscriptionEventsResponse)) { + return false; + } + ListSubscriptionEventsResponse listSubscriptionEventsResponse = (ListSubscriptionEventsResponse) obj; + return Objects.equals(errors, listSubscriptionEventsResponse.errors) && + Objects.equals(subscriptionEvents, listSubscriptionEventsResponse.subscriptionEvents) && + Objects.equals(cursor, listSubscriptionEventsResponse.cursor); + } + + /** + * Builds a new {@link ListSubscriptionEventsResponse.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link ListSubscriptionEventsResponse.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .errors(getErrors()) + .subscriptionEvents(getSubscriptionEvents()) + .cursor(getCursor()); + return builder; + } + + /** + * Class to build instances of {@link ListSubscriptionEventsResponse} + */ + public static class Builder { + private HttpContext httpContext; + private List errors; + private List subscriptionEvents; + private String cursor; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for httpContext + * @param httpContext + * @return Builder + */ + public Builder httpContext(HttpContext httpContext) { + this.httpContext = httpContext; + return this; + } + /** + * Setter for errors + * @param errors + * @return Builder + */ + public Builder errors(List errors) { + this.errors = errors; + return this; + } + /** + * Setter for subscriptionEvents + * @param subscriptionEvents + * @return Builder + */ + public Builder subscriptionEvents(List subscriptionEvents) { + this.subscriptionEvents = subscriptionEvents; + return this; + } + /** + * Setter for cursor + * @param cursor + * @return Builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Builds a new {@link ListSubscriptionEventsResponse} object using the set fields. + * @return {@link ListSubscriptionEventsResponse} + */ + public ListSubscriptionEventsResponse build() { + ListSubscriptionEventsResponse model = new ListSubscriptionEventsResponse(errors, + subscriptionEvents, + cursor); + model.httpContext = httpContext; + return model; + } + } +} diff --git a/src/main/java/com/squareup/square/models/RetrieveSubscriptionResponse.java b/src/main/java/com/squareup/square/models/RetrieveSubscriptionResponse.java new file mode 100644 index 00000000..14520b26 --- /dev/null +++ b/src/main/java/com/squareup/square/models/RetrieveSubscriptionResponse.java @@ -0,0 +1,142 @@ +package com.squareup.square.models; + +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.squareup.square.http.client.HttpContext; + + +/** + * This is a model class for RetrieveSubscriptionResponse type. + */ +public class RetrieveSubscriptionResponse { + + /** + * Initialization constructor. + * @param errors + * @param subscription + */ + @JsonCreator + public RetrieveSubscriptionResponse( + @JsonProperty("errors") List errors, + @JsonProperty("subscription") Subscription subscription) { + this.errors = errors; + this.subscription = subscription; + } + + private HttpContext httpContext; + private final List errors; + private final Subscription subscription; + + public HttpContext getContext() { + return httpContext; + } + + /** + * Getter for Errors. + * Information about errors encountered during the request. + */ + @JsonGetter("errors") + public List getErrors() { + return this.errors; + } + + /** + * Getter for Subscription. + * Represents a customer subscription to a subscription plan. + * For an overview of the `Subscription` type, see + * [Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). + */ + @JsonGetter("subscription") + public Subscription getSubscription() { + return this.subscription; + } + + + @Override + public int hashCode() { + return Objects.hash(errors, subscription); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof RetrieveSubscriptionResponse)) { + return false; + } + RetrieveSubscriptionResponse retrieveSubscriptionResponse = (RetrieveSubscriptionResponse) obj; + return Objects.equals(errors, retrieveSubscriptionResponse.errors) && + Objects.equals(subscription, retrieveSubscriptionResponse.subscription); + } + + /** + * Builds a new {@link RetrieveSubscriptionResponse.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link RetrieveSubscriptionResponse.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .errors(getErrors()) + .subscription(getSubscription()); + return builder; + } + + /** + * Class to build instances of {@link RetrieveSubscriptionResponse} + */ + public static class Builder { + private HttpContext httpContext; + private List errors; + private Subscription subscription; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for httpContext + * @param httpContext + * @return Builder + */ + public Builder httpContext(HttpContext httpContext) { + this.httpContext = httpContext; + return this; + } + /** + * Setter for errors + * @param errors + * @return Builder + */ + public Builder errors(List errors) { + this.errors = errors; + return this; + } + /** + * Setter for subscription + * @param subscription + * @return Builder + */ + public Builder subscription(Subscription subscription) { + this.subscription = subscription; + return this; + } + + /** + * Builds a new {@link RetrieveSubscriptionResponse} object using the set fields. + * @return {@link RetrieveSubscriptionResponse} + */ + public RetrieveSubscriptionResponse build() { + RetrieveSubscriptionResponse model = new RetrieveSubscriptionResponse(errors, + subscription); + model.httpContext = httpContext; + return model; + } + } +} diff --git a/src/main/java/com/squareup/square/models/SearchSubscriptionsFilter.java b/src/main/java/com/squareup/square/models/SearchSubscriptionsFilter.java new file mode 100644 index 00000000..b15ef5ca --- /dev/null +++ b/src/main/java/com/squareup/square/models/SearchSubscriptionsFilter.java @@ -0,0 +1,121 @@ +package com.squareup.square.models; + +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for SearchSubscriptionsFilter type. + */ +public class SearchSubscriptionsFilter { + + /** + * Initialization constructor. + * @param customerIds + * @param locationIds + */ + @JsonCreator + public SearchSubscriptionsFilter( + @JsonProperty("customer_ids") List customerIds, + @JsonProperty("location_ids") List locationIds) { + this.customerIds = customerIds; + this.locationIds = locationIds; + } + + private final List customerIds; + private final List locationIds; + /** + * Getter for CustomerIds. + * A filter to select subscriptions based on the customer. + */ + @JsonGetter("customer_ids") + public List getCustomerIds() { + return this.customerIds; + } + + /** + * Getter for LocationIds. + * A filter to select subscriptions based the location. + */ + @JsonGetter("location_ids") + public List getLocationIds() { + return this.locationIds; + } + + + @Override + public int hashCode() { + return Objects.hash(customerIds, locationIds); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof SearchSubscriptionsFilter)) { + return false; + } + SearchSubscriptionsFilter searchSubscriptionsFilter = (SearchSubscriptionsFilter) obj; + return Objects.equals(customerIds, searchSubscriptionsFilter.customerIds) && + Objects.equals(locationIds, searchSubscriptionsFilter.locationIds); + } + + /** + * Builds a new {@link SearchSubscriptionsFilter.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link SearchSubscriptionsFilter.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .customerIds(getCustomerIds()) + .locationIds(getLocationIds()); + return builder; + } + + /** + * Class to build instances of {@link SearchSubscriptionsFilter} + */ + public static class Builder { + private List customerIds; + private List locationIds; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for customerIds + * @param customerIds + * @return Builder + */ + public Builder customerIds(List customerIds) { + this.customerIds = customerIds; + return this; + } + /** + * Setter for locationIds + * @param locationIds + * @return Builder + */ + public Builder locationIds(List locationIds) { + this.locationIds = locationIds; + return this; + } + + /** + * Builds a new {@link SearchSubscriptionsFilter} object using the set fields. + * @return {@link SearchSubscriptionsFilter} + */ + public SearchSubscriptionsFilter build() { + return new SearchSubscriptionsFilter(customerIds, + locationIds); + } + } +} diff --git a/src/main/java/com/squareup/square/models/SearchSubscriptionsQuery.java b/src/main/java/com/squareup/square/models/SearchSubscriptionsQuery.java new file mode 100644 index 00000000..1d53d6b8 --- /dev/null +++ b/src/main/java/com/squareup/square/models/SearchSubscriptionsQuery.java @@ -0,0 +1,94 @@ +package com.squareup.square.models; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for SearchSubscriptionsQuery type. + */ +public class SearchSubscriptionsQuery { + + /** + * Initialization constructor. + * @param filter + */ + @JsonCreator + public SearchSubscriptionsQuery( + @JsonProperty("filter") SearchSubscriptionsFilter filter) { + this.filter = filter; + } + + private final SearchSubscriptionsFilter filter; + /** + * Getter for Filter. + * Represents a set of SearchSubscriptionsQuery filters used to limit the set of Subscriptions returned by SearchSubscriptions. + */ + @JsonGetter("filter") + public SearchSubscriptionsFilter getFilter() { + return this.filter; + } + + + @Override + public int hashCode() { + return Objects.hash(filter); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof SearchSubscriptionsQuery)) { + return false; + } + SearchSubscriptionsQuery searchSubscriptionsQuery = (SearchSubscriptionsQuery) obj; + return Objects.equals(filter, searchSubscriptionsQuery.filter); + } + + /** + * Builds a new {@link SearchSubscriptionsQuery.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link SearchSubscriptionsQuery.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .filter(getFilter()); + return builder; + } + + /** + * Class to build instances of {@link SearchSubscriptionsQuery} + */ + public static class Builder { + private SearchSubscriptionsFilter filter; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for filter + * @param filter + * @return Builder + */ + public Builder filter(SearchSubscriptionsFilter filter) { + this.filter = filter; + return this; + } + + /** + * Builds a new {@link SearchSubscriptionsQuery} object using the set fields. + * @return {@link SearchSubscriptionsQuery} + */ + public SearchSubscriptionsQuery build() { + return new SearchSubscriptionsQuery(filter); + } + } +} diff --git a/src/main/java/com/squareup/square/models/SearchSubscriptionsRequest.java b/src/main/java/com/squareup/square/models/SearchSubscriptionsRequest.java new file mode 100644 index 00000000..59aaf916 --- /dev/null +++ b/src/main/java/com/squareup/square/models/SearchSubscriptionsRequest.java @@ -0,0 +1,150 @@ +package com.squareup.square.models; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for SearchSubscriptionsRequest type. + */ +public class SearchSubscriptionsRequest { + + /** + * Initialization constructor. + * @param cursor + * @param limit + * @param query + */ + @JsonCreator + public SearchSubscriptionsRequest( + @JsonProperty("cursor") String cursor, + @JsonProperty("limit") Integer limit, + @JsonProperty("query") SearchSubscriptionsQuery query) { + this.cursor = cursor; + this.limit = limit; + this.query = query; + } + + private final String cursor; + private final Integer limit; + private final SearchSubscriptionsQuery query; + /** + * Getter for Cursor. + * A pagination cursor returned by a previous call to this endpoint. + * Provide this to retrieve the next set of results for the original query. + * For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). + */ + @JsonGetter("cursor") + public String getCursor() { + return this.cursor; + } + + /** + * Getter for Limit. + * The upper limit on the number of subscriptions to return + * in the response. + * Default: `200` + */ + @JsonGetter("limit") + public Integer getLimit() { + return this.limit; + } + + /** + * Getter for Query. + * Represents a query (including filtering criteria) used to search for subscriptions. + */ + @JsonGetter("query") + public SearchSubscriptionsQuery getQuery() { + return this.query; + } + + + @Override + public int hashCode() { + return Objects.hash(cursor, limit, query); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof SearchSubscriptionsRequest)) { + return false; + } + SearchSubscriptionsRequest searchSubscriptionsRequest = (SearchSubscriptionsRequest) obj; + return Objects.equals(cursor, searchSubscriptionsRequest.cursor) && + Objects.equals(limit, searchSubscriptionsRequest.limit) && + Objects.equals(query, searchSubscriptionsRequest.query); + } + + /** + * Builds a new {@link SearchSubscriptionsRequest.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link SearchSubscriptionsRequest.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .cursor(getCursor()) + .limit(getLimit()) + .query(getQuery()); + return builder; + } + + /** + * Class to build instances of {@link SearchSubscriptionsRequest} + */ + public static class Builder { + private String cursor; + private Integer limit; + private SearchSubscriptionsQuery query; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for cursor + * @param cursor + * @return Builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + /** + * Setter for limit + * @param limit + * @return Builder + */ + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + /** + * Setter for query + * @param query + * @return Builder + */ + public Builder query(SearchSubscriptionsQuery query) { + this.query = query; + return this; + } + + /** + * Builds a new {@link SearchSubscriptionsRequest} object using the set fields. + * @return {@link SearchSubscriptionsRequest} + */ + public SearchSubscriptionsRequest build() { + return new SearchSubscriptionsRequest(cursor, + limit, + query); + } + } +} diff --git a/src/main/java/com/squareup/square/models/SearchSubscriptionsResponse.java b/src/main/java/com/squareup/square/models/SearchSubscriptionsResponse.java new file mode 100644 index 00000000..0476f7d1 --- /dev/null +++ b/src/main/java/com/squareup/square/models/SearchSubscriptionsResponse.java @@ -0,0 +1,169 @@ +package com.squareup.square.models; + +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.squareup.square.http.client.HttpContext; + + +/** + * This is a model class for SearchSubscriptionsResponse type. + */ +public class SearchSubscriptionsResponse { + + /** + * Initialization constructor. + * @param errors + * @param subscriptions + * @param cursor + */ + @JsonCreator + public SearchSubscriptionsResponse( + @JsonProperty("errors") List errors, + @JsonProperty("subscriptions") List subscriptions, + @JsonProperty("cursor") String cursor) { + this.errors = errors; + this.subscriptions = subscriptions; + this.cursor = cursor; + } + + private HttpContext httpContext; + private final List errors; + private final List subscriptions; + private final String cursor; + + public HttpContext getContext() { + return httpContext; + } + + /** + * Getter for Errors. + * Information about errors encountered during the request. + */ + @JsonGetter("errors") + public List getErrors() { + return this.errors; + } + + /** + * Getter for Subscriptions. + * The search result. + */ + @JsonGetter("subscriptions") + public List getSubscriptions() { + return this.subscriptions; + } + + /** + * Getter for Cursor. + * When a response is truncated, it includes a cursor that you can + * use in a subsequent request to fetch the next set of subscriptions. + * If empty, this is the final response. + * For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination). + */ + @JsonGetter("cursor") + public String getCursor() { + return this.cursor; + } + + + @Override + public int hashCode() { + return Objects.hash(errors, subscriptions, cursor); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof SearchSubscriptionsResponse)) { + return false; + } + SearchSubscriptionsResponse searchSubscriptionsResponse = (SearchSubscriptionsResponse) obj; + return Objects.equals(errors, searchSubscriptionsResponse.errors) && + Objects.equals(subscriptions, searchSubscriptionsResponse.subscriptions) && + Objects.equals(cursor, searchSubscriptionsResponse.cursor); + } + + /** + * Builds a new {@link SearchSubscriptionsResponse.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link SearchSubscriptionsResponse.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .errors(getErrors()) + .subscriptions(getSubscriptions()) + .cursor(getCursor()); + return builder; + } + + /** + * Class to build instances of {@link SearchSubscriptionsResponse} + */ + public static class Builder { + private HttpContext httpContext; + private List errors; + private List subscriptions; + private String cursor; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for httpContext + * @param httpContext + * @return Builder + */ + public Builder httpContext(HttpContext httpContext) { + this.httpContext = httpContext; + return this; + } + /** + * Setter for errors + * @param errors + * @return Builder + */ + public Builder errors(List errors) { + this.errors = errors; + return this; + } + /** + * Setter for subscriptions + * @param subscriptions + * @return Builder + */ + public Builder subscriptions(List subscriptions) { + this.subscriptions = subscriptions; + return this; + } + /** + * Setter for cursor + * @param cursor + * @return Builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Builds a new {@link SearchSubscriptionsResponse} object using the set fields. + * @return {@link SearchSubscriptionsResponse} + */ + public SearchSubscriptionsResponse build() { + SearchSubscriptionsResponse model = new SearchSubscriptionsResponse(errors, + subscriptions, + cursor); + model.httpContext = httpContext; + return model; + } + } +} diff --git a/src/main/java/com/squareup/square/models/Subscription.java b/src/main/java/com/squareup/square/models/Subscription.java new file mode 100644 index 00000000..18f37c61 --- /dev/null +++ b/src/main/java/com/squareup/square/models/Subscription.java @@ -0,0 +1,489 @@ +package com.squareup.square.models; + +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for Subscription type. + */ +public class Subscription { + + /** + * Initialization constructor. + * @param id + * @param locationId + * @param planId + * @param customerId + * @param startDate + * @param canceledDate + * @param status + * @param taxPercentage + * @param invoiceIds + * @param priceOverrideMoney + * @param version + * @param createdAt + * @param cardId + * @param paidUntilDate + * @param timezone + */ + @JsonCreator + public Subscription( + @JsonProperty("id") String id, + @JsonProperty("location_id") String locationId, + @JsonProperty("plan_id") String planId, + @JsonProperty("customer_id") String customerId, + @JsonProperty("start_date") String startDate, + @JsonProperty("canceled_date") String canceledDate, + @JsonProperty("status") String status, + @JsonProperty("tax_percentage") String taxPercentage, + @JsonProperty("invoice_ids") List invoiceIds, + @JsonProperty("price_override_money") Money priceOverrideMoney, + @JsonProperty("version") Long version, + @JsonProperty("created_at") String createdAt, + @JsonProperty("card_id") String cardId, + @JsonProperty("paid_until_date") String paidUntilDate, + @JsonProperty("timezone") String timezone) { + this.id = id; + this.locationId = locationId; + this.planId = planId; + this.customerId = customerId; + this.startDate = startDate; + this.canceledDate = canceledDate; + this.status = status; + this.taxPercentage = taxPercentage; + this.invoiceIds = invoiceIds; + this.priceOverrideMoney = priceOverrideMoney; + this.version = version; + this.createdAt = createdAt; + this.cardId = cardId; + this.paidUntilDate = paidUntilDate; + this.timezone = timezone; + } + + private final String id; + private final String locationId; + private final String planId; + private final String customerId; + private final String startDate; + private final String canceledDate; + private final String status; + private final String taxPercentage; + private final List invoiceIds; + private final Money priceOverrideMoney; + private final Long version; + private final String createdAt; + private final String cardId; + private final String paidUntilDate; + private final String timezone; + /** + * Getter for Id. + * The Square-assigned ID of the subscription. + */ + @JsonGetter("id") + public String getId() { + return this.id; + } + + /** + * Getter for LocationId. + * The ID of the location associated with the subscription. + */ + @JsonGetter("location_id") + public String getLocationId() { + return this.locationId; + } + + /** + * Getter for PlanId. + * The ID of the associated [subscription plan](#type-catalogsubscriptionplan). + */ + @JsonGetter("plan_id") + public String getPlanId() { + return this.planId; + } + + /** + * Getter for CustomerId. + * The ID of the associated [customer](#type-customer) profile. + */ + @JsonGetter("customer_id") + public String getCustomerId() { + return this.customerId; + } + + /** + * Getter for StartDate. + * The start date of the subscription, in YYYY-MM-DD format (for example, + * 2013-01-15). + */ + @JsonGetter("start_date") + public String getStartDate() { + return this.startDate; + } + + /** + * Getter for CanceledDate. + * The subscription cancellation date, in YYYY-MM-DD format (for + * example, 2013-01-15). On this date, the subscription status changes + * to `CANCELED` and the subscription billing stops. + * If you don't set this field, the subscription plan dictates if and + * when subscription ends. + * You cannot update this field, you can only clear it. + */ + @JsonGetter("canceled_date") + public String getCanceledDate() { + return this.canceledDate; + } + + /** + * Getter for Status. + * Possible subscription status values. + */ + @JsonGetter("status") + public String getStatus() { + return this.status; + } + + /** + * Getter for TaxPercentage. + * The tax amount applied when billing the subscription. The + * percentage is expressed in decimal form, using a `'.'` as the decimal + * separator and without a `'%'` sign. For example, a value of `7.5` + * corresponds to 7.5%. + */ + @JsonGetter("tax_percentage") + public String getTaxPercentage() { + return this.taxPercentage; + } + + /** + * Getter for InvoiceIds. + * The IDs of the [invoices](#type-invoice) created for the + * subscription, listed in order when the invoices were created + * (oldest invoices appear first). + */ + @JsonGetter("invoice_ids") + public List getInvoiceIds() { + return this.invoiceIds; + } + + /** + * Getter for PriceOverrideMoney. + * Represents an amount of money. `Money` fields can be signed or unsigned. + * Fields that do not explicitly define whether they are signed or unsigned are + * considered unsigned and can only hold positive amounts. For signed fields, the + * sign of the value indicates the purpose of the money transfer. See + * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts) + * for more information. + */ + @JsonGetter("price_override_money") + public Money getPriceOverrideMoney() { + return this.priceOverrideMoney; + } + + /** + * Getter for Version. + * The version of the object. When updating an object, the version + * supplied must match the version in the database, otherwise the write will + * be rejected as conflicting. + */ + @JsonGetter("version") + public Long getVersion() { + return this.version; + } + + /** + * Getter for CreatedAt. + * The timestamp when the subscription was created, in RFC 3339 format. + */ + @JsonGetter("created_at") + public String getCreatedAt() { + return this.createdAt; + } + + /** + * Getter for CardId. + * The ID of the [customer](#type-customer) [card](#type-card) + * that is charged for the subscription. + */ + @JsonGetter("card_id") + public String getCardId() { + return this.cardId; + } + + /** + * Getter for PaidUntilDate. + * The date up to which the customer is invoiced for the + * subscription, in YYYY-MM-DD format (for example, 2013-01-15). + * After the invoice is paid for a given billing period, + * this date will be the last day of the billing period. + * For example, + * suppose for the month of May a customer gets an invoice + * (or charged the card) on May 1. For the monthly billing scenario, + * this date is then set to May 31. + */ + @JsonGetter("paid_until_date") + public String getPaidUntilDate() { + return this.paidUntilDate; + } + + /** + * Getter for Timezone. + * Timezone that will be used in date calculations for the subscription. + * Defaults to the timezone of the location based on `location_id`. + * Format: the IANA Timezone Database identifier for the location timezone (for example, `America/Los_Angeles`). + */ + @JsonGetter("timezone") + public String getTimezone() { + return this.timezone; + } + + + @Override + public int hashCode() { + return Objects.hash(id, locationId, planId, customerId, startDate, canceledDate, status, + taxPercentage, invoiceIds, priceOverrideMoney, version, createdAt, cardId, paidUntilDate, + timezone); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof Subscription)) { + return false; + } + Subscription subscription = (Subscription) obj; + return Objects.equals(id, subscription.id) && + Objects.equals(locationId, subscription.locationId) && + Objects.equals(planId, subscription.planId) && + Objects.equals(customerId, subscription.customerId) && + Objects.equals(startDate, subscription.startDate) && + Objects.equals(canceledDate, subscription.canceledDate) && + Objects.equals(status, subscription.status) && + Objects.equals(taxPercentage, subscription.taxPercentage) && + Objects.equals(invoiceIds, subscription.invoiceIds) && + Objects.equals(priceOverrideMoney, subscription.priceOverrideMoney) && + Objects.equals(version, subscription.version) && + Objects.equals(createdAt, subscription.createdAt) && + Objects.equals(cardId, subscription.cardId) && + Objects.equals(paidUntilDate, subscription.paidUntilDate) && + Objects.equals(timezone, subscription.timezone); + } + + /** + * Builds a new {@link Subscription.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link Subscription.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .id(getId()) + .locationId(getLocationId()) + .planId(getPlanId()) + .customerId(getCustomerId()) + .startDate(getStartDate()) + .canceledDate(getCanceledDate()) + .status(getStatus()) + .taxPercentage(getTaxPercentage()) + .invoiceIds(getInvoiceIds()) + .priceOverrideMoney(getPriceOverrideMoney()) + .version(getVersion()) + .createdAt(getCreatedAt()) + .cardId(getCardId()) + .paidUntilDate(getPaidUntilDate()) + .timezone(getTimezone()); + return builder; + } + + /** + * Class to build instances of {@link Subscription} + */ + public static class Builder { + private String id; + private String locationId; + private String planId; + private String customerId; + private String startDate; + private String canceledDate; + private String status; + private String taxPercentage; + private List invoiceIds; + private Money priceOverrideMoney; + private Long version; + private String createdAt; + private String cardId; + private String paidUntilDate; + private String timezone; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for id + * @param id + * @return Builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + /** + * Setter for locationId + * @param locationId + * @return Builder + */ + public Builder locationId(String locationId) { + this.locationId = locationId; + return this; + } + /** + * Setter for planId + * @param planId + * @return Builder + */ + public Builder planId(String planId) { + this.planId = planId; + return this; + } + /** + * Setter for customerId + * @param customerId + * @return Builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + /** + * Setter for startDate + * @param startDate + * @return Builder + */ + public Builder startDate(String startDate) { + this.startDate = startDate; + return this; + } + /** + * Setter for canceledDate + * @param canceledDate + * @return Builder + */ + public Builder canceledDate(String canceledDate) { + this.canceledDate = canceledDate; + return this; + } + /** + * Setter for status + * @param status + * @return Builder + */ + public Builder status(String status) { + this.status = status; + return this; + } + /** + * Setter for taxPercentage + * @param taxPercentage + * @return Builder + */ + public Builder taxPercentage(String taxPercentage) { + this.taxPercentage = taxPercentage; + return this; + } + /** + * Setter for invoiceIds + * @param invoiceIds + * @return Builder + */ + public Builder invoiceIds(List invoiceIds) { + this.invoiceIds = invoiceIds; + return this; + } + /** + * Setter for priceOverrideMoney + * @param priceOverrideMoney + * @return Builder + */ + public Builder priceOverrideMoney(Money priceOverrideMoney) { + this.priceOverrideMoney = priceOverrideMoney; + return this; + } + /** + * Setter for version + * @param version + * @return Builder + */ + public Builder version(Long version) { + this.version = version; + return this; + } + /** + * Setter for createdAt + * @param createdAt + * @return Builder + */ + public Builder createdAt(String createdAt) { + this.createdAt = createdAt; + return this; + } + /** + * Setter for cardId + * @param cardId + * @return Builder + */ + public Builder cardId(String cardId) { + this.cardId = cardId; + return this; + } + /** + * Setter for paidUntilDate + * @param paidUntilDate + * @return Builder + */ + public Builder paidUntilDate(String paidUntilDate) { + this.paidUntilDate = paidUntilDate; + return this; + } + /** + * Setter for timezone + * @param timezone + * @return Builder + */ + public Builder timezone(String timezone) { + this.timezone = timezone; + return this; + } + + /** + * Builds a new {@link Subscription} object using the set fields. + * @return {@link Subscription} + */ + public Subscription build() { + return new Subscription(id, + locationId, + planId, + customerId, + startDate, + canceledDate, + status, + taxPercentage, + invoiceIds, + priceOverrideMoney, + version, + createdAt, + cardId, + paidUntilDate, + timezone); + } + } +} diff --git a/src/main/java/com/squareup/square/models/SubscriptionEvent.java b/src/main/java/com/squareup/square/models/SubscriptionEvent.java new file mode 100644 index 00000000..4b42772f --- /dev/null +++ b/src/main/java/com/squareup/square/models/SubscriptionEvent.java @@ -0,0 +1,178 @@ +package com.squareup.square.models; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for SubscriptionEvent type. + */ +public class SubscriptionEvent { + + /** + * Initialization constructor. + * @param id + * @param subscriptionEventType + * @param effectiveDate + * @param planId + */ + @JsonCreator + public SubscriptionEvent( + @JsonProperty("id") String id, + @JsonProperty("subscription_event_type") String subscriptionEventType, + @JsonProperty("effective_date") String effectiveDate, + @JsonProperty("plan_id") String planId) { + this.id = id; + this.subscriptionEventType = subscriptionEventType; + this.effectiveDate = effectiveDate; + this.planId = planId; + } + + private final String id; + private final String subscriptionEventType; + private final String effectiveDate; + private final String planId; + /** + * Getter for Id. + * The ID of the subscription event. + */ + @JsonGetter("id") + public String getId() { + return this.id; + } + + /** + * Getter for SubscriptionEventType. + * The possible subscription event types. + */ + @JsonGetter("subscription_event_type") + public String getSubscriptionEventType() { + return this.subscriptionEventType; + } + + /** + * Getter for EffectiveDate. + * The date, in YYYY-MM-DD format (for + * example, 2013-01-15), when the subscription event went into effect. + */ + @JsonGetter("effective_date") + public String getEffectiveDate() { + return this.effectiveDate; + } + + /** + * Getter for PlanId. + * The ID of the subscription plan associated with the subscription. + */ + @JsonGetter("plan_id") + public String getPlanId() { + return this.planId; + } + + + @Override + public int hashCode() { + return Objects.hash(id, subscriptionEventType, effectiveDate, planId); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof SubscriptionEvent)) { + return false; + } + SubscriptionEvent subscriptionEvent = (SubscriptionEvent) obj; + return Objects.equals(id, subscriptionEvent.id) && + Objects.equals(subscriptionEventType, subscriptionEvent.subscriptionEventType) && + Objects.equals(effectiveDate, subscriptionEvent.effectiveDate) && + Objects.equals(planId, subscriptionEvent.planId); + } + + /** + * Builds a new {@link SubscriptionEvent.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link SubscriptionEvent.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder(id, + subscriptionEventType, + effectiveDate, + planId); + return builder; + } + + /** + * Class to build instances of {@link SubscriptionEvent} + */ + public static class Builder { + private String id; + private String subscriptionEventType; + private String effectiveDate; + private String planId; + + /** + * Initialization constructor + */ + public Builder(String id, + String subscriptionEventType, + String effectiveDate, + String planId) { + this.id = id; + this.subscriptionEventType = subscriptionEventType; + this.effectiveDate = effectiveDate; + this.planId = planId; + } + + /** + * Setter for id + * @param id + * @return Builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + /** + * Setter for subscriptionEventType + * @param subscriptionEventType + * @return Builder + */ + public Builder subscriptionEventType(String subscriptionEventType) { + this.subscriptionEventType = subscriptionEventType; + return this; + } + /** + * Setter for effectiveDate + * @param effectiveDate + * @return Builder + */ + public Builder effectiveDate(String effectiveDate) { + this.effectiveDate = effectiveDate; + return this; + } + /** + * Setter for planId + * @param planId + * @return Builder + */ + public Builder planId(String planId) { + this.planId = planId; + return this; + } + + /** + * Builds a new {@link SubscriptionEvent} object using the set fields. + * @return {@link SubscriptionEvent} + */ + public SubscriptionEvent build() { + return new SubscriptionEvent(id, + subscriptionEventType, + effectiveDate, + planId); + } + } +} diff --git a/src/main/java/com/squareup/square/models/SubscriptionPhase.java b/src/main/java/com/squareup/square/models/SubscriptionPhase.java new file mode 100644 index 00000000..5dcd331c --- /dev/null +++ b/src/main/java/com/squareup/square/models/SubscriptionPhase.java @@ -0,0 +1,204 @@ +package com.squareup.square.models; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for SubscriptionPhase type. + */ +public class SubscriptionPhase { + + /** + * Initialization constructor. + * @param cadence + * @param recurringPriceMoney + * @param uid + * @param periods + * @param ordinal + */ + @JsonCreator + public SubscriptionPhase( + @JsonProperty("cadence") String cadence, + @JsonProperty("recurring_price_money") Money recurringPriceMoney, + @JsonProperty("uid") String uid, + @JsonProperty("periods") Integer periods, + @JsonProperty("ordinal") Long ordinal) { + this.uid = uid; + this.cadence = cadence; + this.periods = periods; + this.recurringPriceMoney = recurringPriceMoney; + this.ordinal = ordinal; + } + + private final String uid; + private final String cadence; + private final Integer periods; + private final Money recurringPriceMoney; + private final Long ordinal; + /** + * Getter for Uid. + * The Square-assigned ID of the subscription phase. + */ + @JsonGetter("uid") + public String getUid() { + return this.uid; + } + + /** + * Getter for Cadence. + * Determines the billing cadence of a [Subscription](#type-Subscription) + */ + @JsonGetter("cadence") + public String getCadence() { + return this.cadence; + } + + /** + * Getter for Periods. + * The number of `cadence`s the phase lasts. If not set, the phase never ends. Only the last phase can be indefinite. + */ + @JsonGetter("periods") + public Integer getPeriods() { + return this.periods; + } + + /** + * Getter for RecurringPriceMoney. + * Represents an amount of money. `Money` fields can be signed or unsigned. + * Fields that do not explicitly define whether they are signed or unsigned are + * considered unsigned and can only hold positive amounts. For signed fields, the + * sign of the value indicates the purpose of the money transfer. See + * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts) + * for more information. + */ + @JsonGetter("recurring_price_money") + public Money getRecurringPriceMoney() { + return this.recurringPriceMoney; + } + + /** + * Getter for Ordinal. + * The position this phase appears in the sequence of phases defined for the plan, indexed from 0. + */ + @JsonGetter("ordinal") + public Long getOrdinal() { + return this.ordinal; + } + + + @Override + public int hashCode() { + return Objects.hash(uid, cadence, periods, recurringPriceMoney, ordinal); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof SubscriptionPhase)) { + return false; + } + SubscriptionPhase subscriptionPhase = (SubscriptionPhase) obj; + return Objects.equals(uid, subscriptionPhase.uid) && + Objects.equals(cadence, subscriptionPhase.cadence) && + Objects.equals(periods, subscriptionPhase.periods) && + Objects.equals(recurringPriceMoney, subscriptionPhase.recurringPriceMoney) && + Objects.equals(ordinal, subscriptionPhase.ordinal); + } + + /** + * Builds a new {@link SubscriptionPhase.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link SubscriptionPhase.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder(cadence, + recurringPriceMoney) + .uid(getUid()) + .periods(getPeriods()) + .ordinal(getOrdinal()); + return builder; + } + + /** + * Class to build instances of {@link SubscriptionPhase} + */ + public static class Builder { + private String cadence; + private Money recurringPriceMoney; + private String uid; + private Integer periods; + private Long ordinal; + + /** + * Initialization constructor + */ + public Builder(String cadence, + Money recurringPriceMoney) { + this.cadence = cadence; + this.recurringPriceMoney = recurringPriceMoney; + } + + /** + * Setter for cadence + * @param cadence + * @return Builder + */ + public Builder cadence(String cadence) { + this.cadence = cadence; + return this; + } + /** + * Setter for recurringPriceMoney + * @param recurringPriceMoney + * @return Builder + */ + public Builder recurringPriceMoney(Money recurringPriceMoney) { + this.recurringPriceMoney = recurringPriceMoney; + return this; + } + /** + * Setter for uid + * @param uid + * @return Builder + */ + public Builder uid(String uid) { + this.uid = uid; + return this; + } + /** + * Setter for periods + * @param periods + * @return Builder + */ + public Builder periods(Integer periods) { + this.periods = periods; + return this; + } + /** + * Setter for ordinal + * @param ordinal + * @return Builder + */ + public Builder ordinal(Long ordinal) { + this.ordinal = ordinal; + return this; + } + + /** + * Builds a new {@link SubscriptionPhase} object using the set fields. + * @return {@link SubscriptionPhase} + */ + public SubscriptionPhase build() { + return new SubscriptionPhase(cadence, + recurringPriceMoney, + uid, + periods, + ordinal); + } + } +} diff --git a/src/main/java/com/squareup/square/models/UpdateSubscriptionRequest.java b/src/main/java/com/squareup/square/models/UpdateSubscriptionRequest.java new file mode 100644 index 00000000..6abc9caa --- /dev/null +++ b/src/main/java/com/squareup/square/models/UpdateSubscriptionRequest.java @@ -0,0 +1,96 @@ +package com.squareup.square.models; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; + + +/** + * This is a model class for UpdateSubscriptionRequest type. + */ +public class UpdateSubscriptionRequest { + + /** + * Initialization constructor. + * @param subscription + */ + @JsonCreator + public UpdateSubscriptionRequest( + @JsonProperty("subscription") Subscription subscription) { + this.subscription = subscription; + } + + private final Subscription subscription; + /** + * Getter for Subscription. + * Represents a customer subscription to a subscription plan. + * For an overview of the `Subscription` type, see + * [Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). + */ + @JsonGetter("subscription") + public Subscription getSubscription() { + return this.subscription; + } + + + @Override + public int hashCode() { + return Objects.hash(subscription); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof UpdateSubscriptionRequest)) { + return false; + } + UpdateSubscriptionRequest updateSubscriptionRequest = (UpdateSubscriptionRequest) obj; + return Objects.equals(subscription, updateSubscriptionRequest.subscription); + } + + /** + * Builds a new {@link UpdateSubscriptionRequest.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link UpdateSubscriptionRequest.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .subscription(getSubscription()); + return builder; + } + + /** + * Class to build instances of {@link UpdateSubscriptionRequest} + */ + public static class Builder { + private Subscription subscription; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for subscription + * @param subscription + * @return Builder + */ + public Builder subscription(Subscription subscription) { + this.subscription = subscription; + return this; + } + + /** + * Builds a new {@link UpdateSubscriptionRequest} object using the set fields. + * @return {@link UpdateSubscriptionRequest} + */ + public UpdateSubscriptionRequest build() { + return new UpdateSubscriptionRequest(subscription); + } + } +} diff --git a/src/main/java/com/squareup/square/models/UpdateSubscriptionResponse.java b/src/main/java/com/squareup/square/models/UpdateSubscriptionResponse.java new file mode 100644 index 00000000..fb8054df --- /dev/null +++ b/src/main/java/com/squareup/square/models/UpdateSubscriptionResponse.java @@ -0,0 +1,142 @@ +package com.squareup.square.models; + +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.squareup.square.http.client.HttpContext; + + +/** + * This is a model class for UpdateSubscriptionResponse type. + */ +public class UpdateSubscriptionResponse { + + /** + * Initialization constructor. + * @param errors + * @param subscription + */ + @JsonCreator + public UpdateSubscriptionResponse( + @JsonProperty("errors") List errors, + @JsonProperty("subscription") Subscription subscription) { + this.errors = errors; + this.subscription = subscription; + } + + private HttpContext httpContext; + private final List errors; + private final Subscription subscription; + + public HttpContext getContext() { + return httpContext; + } + + /** + * Getter for Errors. + * Information about errors encountered during the request. + */ + @JsonGetter("errors") + public List getErrors() { + return this.errors; + } + + /** + * Getter for Subscription. + * Represents a customer subscription to a subscription plan. + * For an overview of the `Subscription` type, see + * [Subscription object](https://developer.squareup.com/docs/docs/subscriptions-api/overview#subscription-object-overview). + */ + @JsonGetter("subscription") + public Subscription getSubscription() { + return this.subscription; + } + + + @Override + public int hashCode() { + return Objects.hash(errors, subscription); + } + + @Override + public boolean equals(Object obj) { + if(obj == this) { + return true; + } + if(!(obj instanceof UpdateSubscriptionResponse)) { + return false; + } + UpdateSubscriptionResponse updateSubscriptionResponse = (UpdateSubscriptionResponse) obj; + return Objects.equals(errors, updateSubscriptionResponse.errors) && + Objects.equals(subscription, updateSubscriptionResponse.subscription); + } + + /** + * Builds a new {@link UpdateSubscriptionResponse.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link UpdateSubscriptionResponse.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .errors(getErrors()) + .subscription(getSubscription()); + return builder; + } + + /** + * Class to build instances of {@link UpdateSubscriptionResponse} + */ + public static class Builder { + private HttpContext httpContext; + private List errors; + private Subscription subscription; + + /** + * Initialization constructor + */ + public Builder() { + + } + + /** + * Setter for httpContext + * @param httpContext + * @return Builder + */ + public Builder httpContext(HttpContext httpContext) { + this.httpContext = httpContext; + return this; + } + /** + * Setter for errors + * @param errors + * @return Builder + */ + public Builder errors(List errors) { + this.errors = errors; + return this; + } + /** + * Setter for subscription + * @param subscription + * @return Builder + */ + public Builder subscription(Subscription subscription) { + this.subscription = subscription; + return this; + } + + /** + * Builds a new {@link UpdateSubscriptionResponse} object using the set fields. + * @return {@link UpdateSubscriptionResponse} + */ + public UpdateSubscriptionResponse build() { + UpdateSubscriptionResponse model = new UpdateSubscriptionResponse(errors, + subscription); + model.httpContext = httpContext; + return model; + } + } +}