Skip to content
Closed
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
16 changes: 16 additions & 0 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"cliVersion": "2.2.5",
"generatorName": "fernapi/fern-java-sdk",
"generatorVersion": "3.18.6",
"generatorConfig": {
"base-api-exception-class-name": "SquareApiException",
"base-exception-class-name": "SquareException",
"client-class-name": "SquareClient",
"inline-path-parameters": true,
"inline-file-properties": true,
"package-prefix": "com.squareup.square",
"package-layout": "flat",
"enable-forward-compatible-enums": true,
"publish-to": "central"
}
}
58 changes: 49 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@

The Square Java library provides convenient access to the Square APIs from Java.

## Table of Contents

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Instantiation](#instantiation)
- [Enums](#enums)
- [Versioning](#versioning)
- [Automatic Pagination](#automatic-pagination)
- [Retries](#retries)
- [Timeouts](#timeouts)
- [Environments](#environments)
- [Base Url](#base-url)
- [Exception Handling](#exception-handling)
- [Webhook Signature Verification](#webhook-signature-verification)
- [Reference](#reference)
- [Legacy Sdk](#legacy-sdk)
- [Advanced](#advanced)
- [Custom Client](#custom-client)
- [Retries](#retries)
- [Timeouts](#timeouts)
- [Custom Headers](#custom-headers)
- [Access Raw Response Data](#access-raw-response-data)
- [Contributing](#contributing)

## Requirements

Use of the Square Java SDK requires:
Expand All @@ -31,7 +56,7 @@ Add the dependency in your `pom.xml` file:
<dependency>
<groupId>com.squareup</groupId>
<artifactId>square</artifactId>
<version>45.1.0.20251016</version>
<version>0.0.538</version>
</dependency>
```

Expand Down Expand Up @@ -278,9 +303,9 @@ When the API returns a non-success status code (4xx or 5xx response), an API exc
```java
import com.squareup.square.core.SquareApiException;

try {
try{
client.payments().create(...);
} catch (SquareApiException e) {
} catch (SquareApiException e){
// Do something with the API exception...
}
```
Expand Down Expand Up @@ -336,8 +361,8 @@ Gradle:

```groovy
dependencies {
implementation 'com.squareup:square:45.1.0.20251016'
implementation 'com.squareup:square-legacy:45.1.0.20251016'
implementation 'com.squareup:square:0.0.538'
implementation 'com.squareup:square-legacy:0.0.538'
}
```

Expand All @@ -347,12 +372,12 @@ Maven:
<dependency>
<groupId>com.squareup</groupId>
<artifactId>square</artifactId>
<version>45.1.0.20251016</version>
<version>0.0.538</version>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>square-legacy</artifactId>
<version>45.1.0.20251016</version>
<version>0.0.538</version>
</dependency>
```

Expand All @@ -364,7 +389,7 @@ Maven:

### Custom Client

This SDK is built to work with any instance of `OkHttpClient`. By default, if no client is provided, the SDK will construct one.
This SDK is built to work with any instance of `OkHttpClient`. By default, if no client is provided, the SDK will construct one.
However, you can pass your own client like so:

```java
Expand All @@ -383,7 +408,9 @@ SquareClient client = SquareClient

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
retry limit (default: 2).
retry limit (default: 2). Before defaulting to exponential backoff, the SDK will first attempt to respect
the `Retry-After` header (as either in seconds or as an HTTP date), and then the `X-RateLimit-Reset` header
(as a Unix timestamp in epoch seconds); failing both of those, it will fall back to exponential backoff.

A request is deemed retryable when any of the following HTTP status codes is returned:

Expand Down Expand Up @@ -452,6 +479,19 @@ client.payments().create(
);
```

### Access Raw Response Data

The SDK provides access to raw response data, including headers, through the `withRawResponse()` method.
The `withRawResponse()` method returns a raw client that wraps all responses with `body()` and `headers()` methods.
(A normal client's `response` is identical to a raw client's `response.body()`.)

```java
CreateHttpResponse response = client.payments().withRawResponse().create(...);

System.out.println(response.body());
System.out.println(response.headers().get("X-My-Header"));
```

## Contributing

While we value open-source contributions to this SDK, this library is generated programmatically.
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ repositories {
}

dependencies {
api 'com.squareup.okhttp3:okhttp:4.12.0'
api 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2'
api 'com.squareup.okhttp3:okhttp:5.2.1'
api 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
Expand Down Expand Up @@ -47,7 +47,7 @@ java {

group = 'com.squareup'

version = '45.1.0.20251016'
version = '0.0.538'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -78,7 +78,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.squareup'
artifactId = 'square'
version = '45.1.0.20251016'
version = '0.0.538'
from components.java
pom {
name = 'square'
Expand Down
Loading
Loading