Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated PR for Release: 40.0.0.20240515 #118

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The following parameters are configurable for the API Client:

| Parameter | Type | Description |
| --- | --- | --- |
| `squareVersion` | `String` | Square Connect API versions<br>*Default*: `"2024-04-17"` |
| `squareVersion` | `String` | Square Connect API versions<br>*Default*: `"2024-05-15"` |
| `customUrl` | `String` | Sets the base URL requests are made to. Defaults to `https://connect.squareup.com`<br>*Default*: `"https://connect.squareup.com"` |
| `environment` | `string` | The API environment. <br> **Default: `production`** |
| `httpClientConfig` | [`ReadonlyHttpClientConfiguration`](http-client-configuration.md) | Http Client Configuration instance. |
Expand All @@ -19,7 +19,7 @@ The API client can be initialized as follows:
SquareClient client = new SquareClient.Builder()
.httpClientConfig(configBuilder -> configBuilder
.timeout(0))
.squareVersion("2024-04-17")
.squareVersion("2024-05-15")
.bearerAuthCredentials(new BearerAuthModel.Builder(
"AccessToken"
)
Expand All @@ -44,7 +44,7 @@ public class Program {
SquareClient client = new SquareClient.Builder()
.httpClientConfig(configBuilder -> configBuilder
.timeout(0))
.squareVersion("2024-04-17")
.squareVersion("2024-05-15")
.bearerAuthCredentials(new BearerAuthModel.Builder(
"AccessToken"
)
Expand Down
3 changes: 2 additions & 1 deletion doc/models/catalog-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ A [CatalogObject](../../doc/models/catalog-object.md) instance of the `ITEM` typ
| `Description` | `String` | Optional | The item's description. This is a searchable attribute for use in applicable query filters, and its value length is of Unicode code points.<br><br>Deprecated at 2022-07-20, this field is planned to retire in 6 months. You should migrate to use `description_html` to set the description<br>of the [CatalogItem](entity:CatalogItem) instance. The `description` and `description_html` field values are kept in sync. If you try to<br>set the both fields, the `description_html` text value overwrites the `description` value. Updates in one field are also reflected in the other,<br>except for when you use an early version before Square API 2022-07-20 and `description_html` is set to blank, setting the `description` value to null<br>does not nullify `description_html`.<br>**Constraints**: *Maximum Length*: `4096` | String getDescription() |
| `Abbreviation` | `String` | Optional | The text of the item's display label in the Square Point of Sale app. Only up to the first five characters of the string are used.<br>This attribute is searchable, and its value length is of Unicode code points.<br>**Constraints**: *Maximum Length*: `24` | String getAbbreviation() |
| `LabelColor` | `String` | Optional | The color of the item's display label in the Square Point of Sale app. This must be a valid hex color code. | String getLabelColor() |
| `IsTaxable` | `Boolean` | Optional | Indicates whether the item is taxable (`true`) or non-taxable (`false`). Default is `true`. | Boolean getIsTaxable() |
| `AvailableOnline` | `Boolean` | Optional | If `true`, the item can be added to shipping orders from the merchant's online store. | Boolean getAvailableOnline() |
| `AvailableForPickup` | `Boolean` | Optional | If `true`, the item can be added to pickup orders from the merchant's online store. | Boolean getAvailableForPickup() |
| `AvailableElectronically` | `Boolean` | Optional | If `true`, the item can be added to electronically fulfilled orders from the merchant's online store. | Boolean getAvailableElectronically() |
Expand Down Expand Up @@ -44,7 +45,7 @@ A [CatalogObject](../../doc/models/catalog-object.md) instance of the `ITEM` typ
"description": "description6",
"abbreviation": "abbreviation8",
"label_color": "label_color8",
"available_online": false
"is_taxable": false
}
```

4 changes: 3 additions & 1 deletion doc/models/destination-details-card-refund-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
| --- | --- | --- | --- | --- |
| `Card` | [`Card`](../../doc/models/card.md) | Optional | Represents the payment details of a card to be used for payments. These<br>details are determined by the payment token generated by Web Payments SDK. | Card getCard() |
| `EntryMethod` | `String` | Optional | The method used to enter the card's details for the refund. The method can be<br>`KEYED`, `SWIPED`, `EMV`, `ON_FILE`, or `CONTACTLESS`.<br>**Constraints**: *Maximum Length*: `50` | String getEntryMethod() |
| `AuthResultCode` | `String` | Optional | The authorization code provided by the issuer when a refund is approved.<br>**Constraints**: *Maximum Length*: `10` | String getAuthResultCode() |

## Example (as JSON)

Expand All @@ -23,7 +24,8 @@
"exp_month": 228,
"exp_year": 68
},
"entry_method": "entry_method4"
"entry_method": "entry_method4",
"auth_result_code": "auth_result_code6"
}
```

3 changes: 2 additions & 1 deletion doc/models/destination-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Details about a refund's destination.
"exp_month": 228,
"exp_year": 68
},
"entry_method": "entry_method8"
"entry_method": "entry_method8",
"auth_result_code": "auth_result_code0"
}
}
```
Expand Down
3 changes: 2 additions & 1 deletion doc/models/get-payment-refund-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ present or it might be present in a FAILED state.
"exp_month": 228,
"exp_year": 68
},
"entry_method": "entry_method8"
"entry_method": "entry_method8",
"auth_result_code": "auth_result_code0"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion doc/models/list-payment-refunds-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ Either `errors` or `refunds` is present in a given response (never both).
"exp_month": 228,
"exp_year": 68
},
"entry_method": "entry_method8"
"entry_method": "entry_method8",
"auth_result_code": "auth_result_code0"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion doc/models/payment-refund.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ the original payment and the amount of money refunded.
"exp_month": 228,
"exp_year": 68
},
"entry_method": "entry_method8"
"entry_method": "entry_method8",
"auth_result_code": "auth_result_code0"
}
},
"amount_money": {
Expand Down
1 change: 1 addition & 0 deletions doc/models/payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Represents a payment processed by the Square API.
| `ReceiptUrl` | `String` | Optional | The URL for the payment's receipt.<br>The field is only populated for COMPLETED payments.<br>**Constraints**: *Maximum Length*: `255` | String getReceiptUrl() |
| `DeviceDetails` | [`DeviceDetails`](../../doc/models/device-details.md) | Optional | Details about the device that took the payment. | DeviceDetails getDeviceDetails() |
| `ApplicationDetails` | [`ApplicationDetails`](../../doc/models/application-details.md) | Optional | Details about the application that took the payment. | ApplicationDetails getApplicationDetails() |
| `IsOfflinePayment` | `Boolean` | Optional | Whether or not this payment was taken offline. | Boolean getIsOfflinePayment() |
| `VersionToken` | `String` | Optional | Used for optimistic concurrency. This opaque token identifies a specific version of the<br>`Payment` object. | String getVersionToken() |

## Example (as JSON)
Expand Down
3 changes: 2 additions & 1 deletion doc/models/refund-payment-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ present, or it might be present with a status of `FAILED`.
"exp_month": 228,
"exp_year": 68
},
"entry_method": "entry_method8"
"entry_method": "entry_method8",
"auth_result_code": "auth_result_code0"
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.squareup</groupId>
<artifactId>square</artifactId>
<version>39.0.0.20240417</version>
<version>40.0.0.20240515</version>
<packaging>jar</packaging>
<name>Square</name>
<description>Java client library for the Square API</description>
Expand Down Expand Up @@ -40,17 +40,17 @@
<dependency>
<groupId>io.apimatic</groupId>
<artifactId>core-interfaces</artifactId>
<version>[0.2, 0.3)</version>
<version>[0.3, 0.4)</version>
</dependency>
<dependency>
<groupId>io.apimatic</groupId>
<artifactId>core</artifactId>
<version>[0.5, 0.6)</version>
<version>[0.6, 0.7)</version>
</dependency>
<dependency>
<groupId>io.apimatic</groupId>
<artifactId>okhttp-client-adapter</artifactId>
<version>[0.2, 0.3)</version>
<version>[0.3, 0.4)</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
44 changes: 23 additions & 21 deletions src/main/java/com/squareup/square/SquareClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
* Gateway class for the library.
Expand Down Expand Up @@ -153,7 +154,7 @@ public final class SquareClient implements SquareClientInterface {

private static final CompatibilityFactory compatibilityFactory = new CompatibilityFactoryImpl();

private static String userAgent = "Square-Java-SDK/39.0.0.20240417 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}";
private static String userAgent = "Square-Java-SDK/40.0.0.20240515 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}";

/**
* Current API environment.
Expand Down Expand Up @@ -203,7 +204,7 @@ public final class SquareClient implements SquareClientInterface {
/**
* Map of authentication Managers.
*/
private Map<String, Authentication> authentications;
private Map<String, Authentication> authentications = new HashMap<String, Authentication>();

/**
* Callback to be called before and after the HTTP call for an endpoint is made.
Expand All @@ -213,7 +214,7 @@ public final class SquareClient implements SquareClientInterface {
private SquareClient(Environment environment, String customUrl, String squareVersion,
HttpClient httpClient, ReadonlyHttpClientConfiguration httpClientConfig,
Headers additionalHeaders, String userAgentDetail, BearerAuthModel bearerAuthModel,
Map<String, Authentication> authentications, HttpCallback httpCallback) {
HttpCallback httpCallback) {
this.environment = environment;
this.customUrl = customUrl;
this.squareVersion = squareVersion;
Expand All @@ -222,25 +223,17 @@ private SquareClient(Environment environment, String customUrl, String squareVer
this.additionalHeaders = additionalHeaders;
this.userAgentDetail = userAgentDetail;
this.httpCallback = httpCallback;
this.authentications =
(authentications == null) ? new HashMap<>() : new HashMap<>(authentications);
Map<String, String> userAgentConfig = new HashMap<>();
userAgentConfig.put("{api-version}",
squareVersion != null ? squareVersion : "");
userAgentConfig.put("{detail}",
userAgentDetail != null? ApiHelper.tryUrlEncode(userAgentDetail, true): "");

this.bearerAuthModel = bearerAuthModel;

if (this.authentications.containsKey("global")) {
this.bearerAuthManager = (BearerAuthManager) this.authentications.get("global");
}
this.bearerAuthModel = bearerAuthModel;

if (!this.authentications.containsKey("global")
|| !getBearerAuthCredentials().equals(bearerAuthModel.getAccessToken())) {
this.bearerAuthManager = new BearerAuthManager(bearerAuthModel);
this.authentications.put("global", bearerAuthManager);
}
this.bearerAuthManager = new BearerAuthManager(bearerAuthModel);
this.authentications.put("global", bearerAuthManager);

GlobalConfiguration globalConfig = new GlobalConfiguration.Builder()
.httpClient(httpClient).baseUri(server -> getBaseUri(server))
Expand Down Expand Up @@ -714,7 +707,7 @@ public String getAccessToken() {
* @return sdkVersion
*/
public String getSdkVersion() {
return "39.0.0.20240417";
return "40.0.0.20240515";
}

/**
Expand Down Expand Up @@ -815,10 +808,8 @@ public Builder newBuilder() {
builder.userAgentDetail = getUserAgentDetail();
builder.bearerAuthCredentials(getBearerAuthModel()
.toBuilder().build());
builder.authentications = authentications;
builder.httpCallback = httpCallback;
builder.httpClientConfig(configBldr -> configBldr =
((HttpClientConfiguration) httpClientConfig).newBuilder());
builder.httpClientConfig(() -> ((HttpClientConfiguration) httpClientConfig).newBuilder());
return builder;
}

Expand All @@ -829,12 +820,11 @@ public static class Builder {

private Environment environment = Environment.PRODUCTION;
private String customUrl = "https://connect.squareup.com";
private String squareVersion = "2024-04-17";
private String squareVersion = "2024-05-15";
private HttpClient httpClient;
private Headers additionalHeaders = new Headers();
private String userAgentDetail = null;
private BearerAuthModel bearerAuthModel = new BearerAuthModel.Builder("").build();
private Map<String, Authentication> authentications = null;
private HttpCallback httpCallback = null;
private HttpClientConfiguration.Builder httpClientConfigBuilder =
new HttpClientConfiguration.Builder();
Expand Down Expand Up @@ -960,6 +950,18 @@ public Builder httpClientConfig(Consumer<HttpClientConfiguration.Builder> action
return this;
}

/**
* Private Setter for the Builder of httpClientConfiguration, takes in an operation to be performed
* on the builder instance of HTTP client configuration.
*
* @param supplier Supplier for the builder of httpClientConfiguration.
* @return Builder
*/
private Builder httpClientConfig(Supplier<HttpClientConfiguration.Builder> supplier) {
httpClientConfigBuilder = supplier.get();
return this;
}

/**
* Builds a new SquareClient object using the set fields.
* @return SquareClient
Expand All @@ -970,7 +972,7 @@ public SquareClient build() {

return new SquareClient(environment, customUrl, squareVersion, httpClient,
httpClientConfig, additionalHeaders, userAgentDetail, bearerAuthModel,
authentications, httpCallback);
httpCallback);
}
}
}
25 changes: 17 additions & 8 deletions src/main/java/com/squareup/square/http/request/HttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,25 @@ public String toString() {
+ ", parameters=" + parameters + "]";
}

/**
* Get the request URL
*
* @param arraySerializationFormat Array serialization format
* @return The complete URL including serialized query parameters
*/
@Override
public String getUrl(ArraySerializationFormat arraySerializationFormat) {
StringBuilder urlBuilder = new StringBuilder(getQueryUrl());

// set query parameters
ApiHelper.appendUrlWithQueryParameters(urlBuilder, getQueryParameters(),
arraySerializationFormat);

// validate and preprocess url
return ApiHelper.cleanUrl(urlBuilder);
return getQueryUrl();
}

/**
* Get the request URL without query parameters
*
* @return The complete URL excluding query parameters
*/
@Override
public String getUrl() {
return ApiHelper.removeQueryParametersFromUrl(getQueryUrl());
}

}
Loading
Loading