Skip to content

Commit

Permalink
Merge pull request #128 from square/eden/bump-square-version
Browse files Browse the repository at this point in the history
Bump Square Version
  • Loading branch information
mikekono authored Jan 23, 2025
2 parents e1390b9 + 797e4b0 commit 91b256f
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 132 deletions.
86 changes: 43 additions & 43 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-12-18"` |
| `squareVersion` | `String` | Square Connect API versions<br>*Default*: `"2025-01-23"` |
| `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` | [`Consumer<HttpClientConfiguration.Builder>`](http-client-configuration-builder.md) | Set up Http Client Configuration instance. |
Expand All @@ -16,55 +16,55 @@ The following parameters are configurable for the API Client:
The API client can be initialized as follows:

```java
SquareClient client = new SquareClient.Builder()
.httpClientConfig(configBuilder -> configBuilder
.timeout(0))
.squareVersion("2024-12-18")
.bearerAuthCredentials(new BearerAuthModel.Builder(
"AccessToken"
)
.build())
.environment(Environment.PRODUCTION)
.customUrl("https://connect.squareup.com")
SquareClient client = new SquareClient.Builder()
.httpClientConfig(configBuilder -> configBuilder
.timeout(0))
.squareVersion("2025-01-23")
.bearerAuthCredentials(new BearerAuthModel.Builder(
"AccessToken"
)
.build())
.environment(Environment.PRODUCTION)
.customUrl("https://connect.squareup.com")
.build();
```

## Make Calls with the API Client

```java
package com.example;

import com.squareup.square.Environment;
import com.squareup.square.SquareClient;
import com.squareup.square.api.LocationsApi;
import com.squareup.square.authentication.BearerAuthModel;

public class Program {

public static void main(String[] args) {
SquareClient client = new SquareClient.Builder()
.httpClientConfig(configBuilder -> configBuilder
.timeout(0))
.squareVersion("2024-12-18")
.bearerAuthCredentials(new BearerAuthModel.Builder(
"AccessToken"
)
.build())
.environment(Environment.PRODUCTION)
.customUrl("https://connect.squareup.com")
.build();

package com.example;

import com.squareup.square.Environment;
import com.squareup.square.SquareClient;
import com.squareup.square.api.LocationsApi;
import com.squareup.square.authentication.BearerAuthModel;

public class Program {

public static void main(String[] args) {
SquareClient client = new SquareClient.Builder()
.httpClientConfig(configBuilder -> configBuilder
.timeout(0))
.squareVersion("2025-01-23")
.bearerAuthCredentials(new BearerAuthModel.Builder(
"AccessToken"
)
.build())
.environment(Environment.PRODUCTION)
.customUrl("https://connect.squareup.com")
.build();

LocationsApi locationsApi = client.getLocationsApi();

locationsApi.listLocationsAsync().thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
}

locationsApi.listLocationsAsync().thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
}
}
```

Expand Down
178 changes: 89 additions & 89 deletions src/main/java/com/squareup/square/SquareClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -722,24 +722,24 @@ public String getSdkVersion() {
return "42.1.0.20241218";
}

/**
* The timeout to use for making HTTP requests.
* @deprecated This method will be removed in a future version. Use
* {@link #getHttpClientConfig()} instead.
*
* @return timeout
*/
@Deprecated
public long timeout() {
return httpClientConfig.getTimeout();
}

/**
* Get base URI by current environment.
* @param server Server for which to get the base URI
* @return Processed base URI
*/
public String getBaseUri(Server server) {
/**
* The timeout to use for making HTTP requests.
* @deprecated This method will be removed in a future version. Use
* {@link #getHttpClientConfig()} instead.
*
* @return timeout
*/
@Deprecated
public long timeout() {
return httpClientConfig.getTimeout();
}

/**
* Get base URI by current environment.
* @param server Server for which to get the base URI
* @return Processed base URI
*/
public String getBaseUri(Server server) {
Map<String, SimpleEntry<Object, Boolean>> parameters = new HashMap<>();
parameters.put("custom_url",
new SimpleEntry<Object, Boolean>(this.customUrl, false));
Expand All @@ -753,28 +753,28 @@ public String getBaseUri(Server server) {
* @return Processed base URI
*/
public String getBaseUri() {
return getBaseUri(Server.ENUM_DEFAULT);
}


/**
* Get base URI by current environment.
*
* @param server string for which to get the base URI
* @return Processed base URI
*/
public String getBaseUri(String server) {
return getBaseUri(Server.fromString(server));
}


/**
* Base URLs by environment and server aliases.
* @param environment Environment for which to get the base URI
* @param server Server for which to get the base URI
* @return base URL
*/
private static String environmentMapper(Environment environment, Server server) {
return getBaseUri(Server.ENUM_DEFAULT);
}


/**
* Get base URI by current environment.
*
* @param server string for which to get the base URI
* @return Processed base URI
*/
public String getBaseUri(String server) {
return getBaseUri(Server.fromString(server));
}


/**
* Base URLs by environment and server aliases.
* @param environment Environment for which to get the base URI
* @param server Server for which to get the base URI
* @return base URL
*/
private static String environmentMapper(Environment environment, Server server) {
if (environment.equals(Environment.PRODUCTION)) {
if (server.equals(Server.ENUM_DEFAULT)) {
return "https://connect.squareup.com";
Expand Down Expand Up @@ -832,7 +832,7 @@ public static class Builder {

private Environment environment = Environment.PRODUCTION;
private String customUrl = "https://connect.squareup.com";
private String squareVersion = "2024-12-18";
private String squareVersion = "2025-01-23";
private HttpClient httpClient;
private Headers additionalHeaders = new Headers();
private String userAgentDetail = null;
Expand Down Expand Up @@ -927,54 +927,54 @@ public Builder userAgentDetail(String userAgentDetail) {
return this;
}

/**
* The timeout to use for making HTTP requests.
* @deprecated This method will be removed in a future version. Use
* {@link #httpClientConfig(Consumer) httpClientConfig} instead.
* @param timeout must be greater then 0.
* @return Builder
*/
@Deprecated
public Builder timeout(long timeout) {
this.httpClientConfigBuilder.timeout(timeout);
return this;
}

/**
* HttpCallback.
* @param httpCallback Callback to be called before and after the HTTP call.
* @return Builder
*/
public Builder httpCallback(HttpCallback httpCallback) {
this.httpCallback = httpCallback;
return this;
}

/**
* Setter for the Builder of httpClientConfiguration, takes in an operation to be performed
* on the builder instance of HTTP client configuration.
*
* @param action Consumer for the builder of httpClientConfiguration.
* @return Builder
*/
public Builder httpClientConfig(Consumer<HttpClientConfiguration.Builder> action) {
action.accept(httpClientConfigBuilder);
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;
}

/**
/**
* The timeout to use for making HTTP requests.
* @deprecated This method will be removed in a future version. Use
* {@link #httpClientConfig(Consumer) httpClientConfig} instead.
* @param timeout must be greater then 0.
* @return Builder
*/
@Deprecated
public Builder timeout(long timeout) {
this.httpClientConfigBuilder.timeout(timeout);
return this;
}

/**
* HttpCallback.
* @param httpCallback Callback to be called before and after the HTTP call.
* @return Builder
*/
public Builder httpCallback(HttpCallback httpCallback) {
this.httpCallback = httpCallback;
return this;
}

/**
* Setter for the Builder of httpClientConfiguration, takes in an operation to be performed
* on the builder instance of HTTP client configuration.
*
* @param action Consumer for the builder of httpClientConfiguration.
* @return Builder
*/
public Builder httpClientConfig(Consumer<HttpClientConfiguration.Builder> action) {
action.accept(httpClientConfigBuilder);
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 Down

0 comments on commit 91b256f

Please sign in to comment.