Skip to content

Commit b821076

Browse files
authored
Merge pull request #130 from square/eden/update-list-payment-refunds
feat: Add additional `updatedAtBeginTime`, `updatedAtEndTime`, and `sortField` query parameters to `listPaymentRefunds` endpoint.
2 parents b0d3ab0 + e2ba6c9 commit b821076

File tree

7 files changed

+299
-74
lines changed

7 files changed

+299
-74
lines changed

doc/api/refunds.md

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ RefundsApi refundsApi = client.getRefundsApi();
1010

1111
## Methods
1212

13-
* [List Payment Refunds](../../doc/api/refunds.md#list-payment-refunds)
14-
* [Refund Payment](../../doc/api/refunds.md#refund-payment)
13+
* [List Payment Refunds](../../doc/api/refunds.md#list-payment-refunds)
14+
* [Refund Payment](../../doc/api/refunds.md#refund-payment)
1515
* [Get Payment Refund](../../doc/api/refunds.md#get-payment-refund)
1616

1717

1818
# List Payment Refunds
1919

20-
Retrieves a list of refunds for the account making the request.
21-
22-
Results are eventually consistent, and new refunds or changes to refunds might take several
23-
seconds to appear.
24-
20+
Retrieves a list of refunds for the account making the request.
21+
22+
Results are eventually consistent, and new refunds or changes to refunds might take several
23+
seconds to appear.
24+
2525
The maximum results per page is 100.
2626

2727
```java
@@ -33,7 +33,10 @@ CompletableFuture<ListPaymentRefundsResponse> listPaymentRefundsAsync(
3333
final String locationId,
3434
final String status,
3535
final String sourceType,
36-
final Integer limit)
36+
final Integer limit,
37+
final String updatedAtBeginTime,
38+
final String updatedAtEndTime,
39+
final String sortField)
3740
```
3841

3942
## Parameters
@@ -48,6 +51,9 @@ CompletableFuture<ListPaymentRefundsResponse> listPaymentRefundsAsync(
4851
| `status` | `String` | Query, Optional | If provided, only refunds with the given status are returned.<br>For a list of refund status values, see [PaymentRefund](entity:PaymentRefund).<br><br>Default: If omitted, refunds are returned regardless of their status. |
4952
| `sourceType` | `String` | Query, Optional | If provided, only returns refunds whose payments have the indicated source type.<br>Current values include `CARD`, `BANK_ACCOUNT`, `WALLET`, `CASH`, and `EXTERNAL`.<br>For information about these payment source types, see<br>[Take Payments](https://developer.squareup.com/docs/payments-api/take-payments).<br><br>Default: If omitted, refunds are returned regardless of the source type. |
5053
| `limit` | `Integer` | Query, Optional | The maximum number of results to be returned in a single page.<br><br>It is possible to receive fewer results than the specified limit on a given page.<br><br>If the supplied value is greater than 100, no more than 100 results are returned.<br><br>Default: 100 |
54+
| `updatedAtBeginTime` | `string` | Query, Optional | Indicates the start of the time range to retrieve each `PaymentRefund` for, in RFC 3339<br>format. The range is determined using the `updated_at` field for each `PaymentRefund`.<br><br>Default: if omitted, the time range starts at `beginTime`. |
55+
| `updatedAtEndTime` | `string` | Query, Optional | Indicates the end of the time range to retrieve each `PaymentRefund` for, in RFC 3339<br>format. The range is determined using the `updated_at` field for each `PaymentRefund`.<br><br>Default: The current time. |
56+
| `sortField` | `string` | Query, Optional | The field used to sort results by. The default is `CREATED_AT`.<br>Current values include `CREATED_AT` and `UPDATED_AT`.<br> |
5157

5258
## Response Type
5359

@@ -56,22 +62,22 @@ CompletableFuture<ListPaymentRefundsResponse> listPaymentRefundsAsync(
5662
## Example Usage
5763

5864
```java
59-
refundsApi.listPaymentRefundsAsync(null, null, null, null, null, null, null, null).thenAccept(result -> {
60-
// TODO success callback handler
61-
System.out.println(result);
62-
}).exceptionally(exception -> {
63-
// TODO failure callback handler
64-
exception.printStackTrace();
65-
return null;
65+
refundsApi.listPaymentRefundsAsync(null, null, null, null, null, null, null, null, null, null, null).thenAccept(result -> {
66+
// TODO success callback handler
67+
System.out.println(result);
68+
}).exceptionally(exception -> {
69+
// TODO failure callback handler
70+
exception.printStackTrace();
71+
return null;
6672
});
6773
```
6874

6975

7076
# Refund Payment
7177

72-
Refunds a payment. You can refund the entire payment amount or a
73-
portion of it. You can use this endpoint to refund a card payment or record a
74-
refund of a cash or external payment. For more information, see
78+
Refunds a payment. You can refund the entire payment amount or a
79+
portion of it. You can use this endpoint to refund a card payment or record a
80+
refund of a cash or external payment. For more information, see
7581
[Refund Payment](https://developer.squareup.com/docs/payments-api/refund-payments).
7682

7783
```java
@@ -92,28 +98,28 @@ CompletableFuture<RefundPaymentResponse> refundPaymentAsync(
9298
## Example Usage
9399

94100
```java
95-
RefundPaymentRequest body = new RefundPaymentRequest.Builder(
96-
"9b7f2dcf-49da-4411-b23e-a2d6af21333a",
97-
new Money.Builder()
98-
.amount(1000L)
99-
.currency("USD")
100-
.build()
101-
)
102-
.appFeeMoney(new Money.Builder()
103-
.amount(10L)
104-
.currency("USD")
105-
.build())
106-
.paymentId("R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY")
107-
.reason("Example")
108-
.build();
109-
110-
refundsApi.refundPaymentAsync(body).thenAccept(result -> {
111-
// TODO success callback handler
112-
System.out.println(result);
113-
}).exceptionally(exception -> {
114-
// TODO failure callback handler
115-
exception.printStackTrace();
116-
return null;
101+
RefundPaymentRequest body = new RefundPaymentRequest.Builder(
102+
"9b7f2dcf-49da-4411-b23e-a2d6af21333a",
103+
new Money.Builder()
104+
.amount(1000L)
105+
.currency("USD")
106+
.build()
107+
)
108+
.appFeeMoney(new Money.Builder()
109+
.amount(10L)
110+
.currency("USD")
111+
.build())
112+
.paymentId("R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY")
113+
.reason("Example")
114+
.build();
115+
116+
refundsApi.refundPaymentAsync(body).thenAccept(result -> {
117+
// TODO success callback handler
118+
System.out.println(result);
119+
}).exceptionally(exception -> {
120+
// TODO failure callback handler
121+
exception.printStackTrace();
122+
return null;
117123
});
118124
```
119125

@@ -140,15 +146,15 @@ CompletableFuture<GetPaymentRefundResponse> getPaymentRefundAsync(
140146
## Example Usage
141147

142148
```java
143-
String refundId = "refund_id4";
144-
145-
refundsApi.getPaymentRefundAsync(refundId).thenAccept(result -> {
146-
// TODO success callback handler
147-
System.out.println(result);
148-
}).exceptionally(exception -> {
149-
// TODO failure callback handler
150-
exception.printStackTrace();
151-
return null;
149+
String refundId = "refund_id4";
150+
151+
refundsApi.getPaymentRefundAsync(refundId).thenAccept(result -> {
152+
// TODO success callback handler
153+
System.out.println(result);
154+
}).exceptionally(exception -> {
155+
// TODO failure callback handler
156+
exception.printStackTrace();
157+
return null;
152158
});
153159
```
154160

doc/client.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The following parameters are configurable for the API Client:
55

66
| Parameter | Type | Description |
77
| --- | --- | --- |
8-
| `squareVersion` | `String` | Square Connect API versions<br>*Default*: `"2025-01-23"` |
8+
| `squareVersion` | `String` | Square Connect API versions<br>*Default*: `"2025-02-20"` |
99
| `customUrl` | `String` | Sets the base URL requests are made to. Defaults to `https://connect.squareup.com`<br>*Default*: `"https://connect.squareup.com"` |
1010
| `environment` | `string` | The API environment. <br> **Default: `production`** |
1111
| `httpClientConfig` | [`Consumer<HttpClientConfiguration.Builder>`](http-client-configuration-builder.md) | Set up Http Client Configuration instance. |
@@ -19,7 +19,7 @@ The API client can be initialized as follows:
1919
SquareClient client = new SquareClient.Builder()
2020
.httpClientConfig(configBuilder -> configBuilder
2121
.timeout(0))
22-
.squareVersion("2025-01-23")
22+
.squareVersion("2025-02-20")
2323
.bearerAuthCredentials(new BearerAuthModel.Builder(
2424
"AccessToken"
2525
)
@@ -45,7 +45,7 @@ public class Program {
4545
SquareClient client = new SquareClient.Builder()
4646
.httpClientConfig(configBuilder -> configBuilder
4747
.timeout(0))
48-
.squareVersion("2025-01-23")
48+
.squareVersion("2025-02-20")
4949
.bearerAuthCredentials(new BearerAuthModel.Builder(
5050
"AccessToken"
5151
)

doc/models/list-payment-refunds-request.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
# List Payment Refunds Request
33

4-
Describes a request to list refunds using
5-
[ListPaymentRefunds](../../doc/api/refunds.md#list-payment-refunds).
6-
4+
Describes a request to list refunds using
5+
[ListPaymentRefunds](../../doc/api/refunds.md#list-payment-refunds).
6+
77
The maximum results per page is 100.
88

99
## Structure
@@ -22,6 +22,9 @@ The maximum results per page is 100.
2222
| `Status` | `String` | Optional | If provided, only refunds with the given status are returned.<br>For a list of refund status values, see [PaymentRefund](entity:PaymentRefund).<br><br>Default: If omitted, refunds are returned regardless of their status. | String getStatus() |
2323
| `SourceType` | `String` | Optional | If provided, only returns refunds whose payments have the indicated source type.<br>Current values include `CARD`, `BANK_ACCOUNT`, `WALLET`, `CASH`, and `EXTERNAL`.<br>For information about these payment source types, see<br>[Take Payments](https://developer.squareup.com/docs/payments-api/take-payments).<br><br>Default: If omitted, refunds are returned regardless of the source type. | String getSourceType() |
2424
| `Limit` | `Integer` | Optional | The maximum number of results to be returned in a single page.<br><br>It is possible to receive fewer results than the specified limit on a given page.<br><br>If the supplied value is greater than 100, no more than 100 results are returned.<br><br>Default: 100 | Integer getLimit() |
25+
| `UpdatedAtBeginTime` | `string` | Optional | Indicates the start of the time range to retrieve each `PaymentRefund` for, in RFC 3339<br>format. The range is determined using the `updated_at` field for each `PaymentRefund`.<br><br>Default: if omitted, the time range starts at `beginTime`. |
26+
| `UpdatedAtEndTime` | `string` | Optional | Indicates the end of the time range to retrieve each `PaymentRefund` for, in RFC 3339<br>format. The range is determined using the `updated_at` field for each `PaymentRefund`.<br><br>Default: The current time. |
27+
| `SortField` | `string` | Optional | The field used to sort results by. The default is `CREATED_AT`.<br>Current values include `CREATED_AT` and `UPDATED_AT`.<br> |
2528

2629
## Example (as JSON)
2730

src/main/java/com/squareup/square/SquareClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public final class SquareClient implements SquareClientInterface {
157157

158158
private static final CompatibilityFactory compatibilityFactory = new CompatibilityFactoryImpl();
159159

160-
private static String userAgent = "Square-Java-SDK/43.0.0.20250123 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}";
160+
private static String userAgent = "Square-Java-SDK/43.1.0.20250220 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}";
161161

162162
/**
163163
* Current API environment.
@@ -719,7 +719,7 @@ public String getAccessToken() {
719719
* @return sdkVersion
720720
*/
721721
public String getSdkVersion() {
722-
return "43.0.0.20250123";
722+
return "43.1.0.20250220";
723723
}
724724

725725
/**
@@ -832,7 +832,7 @@ public static class Builder {
832832

833833
private Environment environment = Environment.PRODUCTION;
834834
private String customUrl = "https://connect.squareup.com";
835-
private String squareVersion = "2025-01-23";
835+
private String squareVersion = "2025-02-20";
836836
private HttpClient httpClient;
837837
private Headers additionalHeaders = new Headers();
838838
private String userAgentDetail = null;

src/main/java/com/squareup/square/api/DefaultRefundsApi.java

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ public DefaultRefundsApi(GlobalConfiguration globalConfig) {
6363
* page. It is possible to receive fewer results than the specified limit on a given
6464
* page. If the supplied value is greater than 100, no more than 100 results are
6565
* returned. Default: 100
66+
* @param updatedAtBeginTime Optional parameter: Indicates the start of the time range to retrieve each
67+
* `PaymentRefund` for, in RFC 3339 format. The range is determined using the
68+
* `updated_at` field for each `PaymentRefund`. Default: if omitted, the time range starts at `beginTime`.
69+
* @param updatedAtEndTime Optional parameter: Indicates the end of the time range to retrieve each
70+
* `PaymentRefund` for, in RFC 3339 format. The range is determined using the
71+
* `updated_at` field for each `PaymentRefund`. Default: The current time.
72+
* @param sortField Optional parameter: The field used to sort results by. The default is `CREATED_AT`.
73+
* Current values include `CREATED_AT` and `UPDATED_AT`.
6674
* @return Returns the ListPaymentRefundsResponse response from the API call
6775
* @throws ApiException Represents error response from the server.
6876
* @throws IOException Signals that an I/O exception of some sort has occurred.
@@ -75,9 +83,12 @@ public ListPaymentRefundsResponse listPaymentRefunds(
7583
final String locationId,
7684
final String status,
7785
final String sourceType,
78-
final Integer limit) throws ApiException, IOException {
86+
final Integer limit,
87+
final String updatedAtBeginTime,
88+
final String updatedAtEndTime,
89+
final String sortField) throws ApiException, IOException {
7990
return prepareListPaymentRefundsRequest(beginTime, endTime, sortOrder, cursor, locationId,
80-
status, sourceType, limit).execute();
91+
status, sourceType, limit, updatedAtBeginTime, updatedAtEndTime, sortField).execute();
8192
}
8293

8394
/**
@@ -113,6 +124,14 @@ public ListPaymentRefundsResponse listPaymentRefunds(
113124
* page. It is possible to receive fewer results than the specified limit on a given
114125
* page. If the supplied value is greater than 100, no more than 100 results are
115126
* returned. Default: 100
127+
* @param updatedAtBeginTime Optional parameter: Indicates the start of the time range to retrieve each
128+
* `PaymentRefund` for, in RFC 3339 format. The range is determined using the
129+
* `updated_at` field for each `PaymentRefund`. Default: if omitted, the time range starts at `beginTime`.
130+
* @param updatedAtEndTime Optional parameter: Indicates the end of the time range to retrieve each
131+
* `PaymentRefund` for, in RFC 3339 format. The range is determined using the
132+
* `updated_at` field for each `PaymentRefund`. Default: The current time.
133+
* @param sortField Optional parameter: The field used to sort results by. The default is `CREATED_AT`.
134+
* Current values include `CREATED_AT` and `UPDATED_AT`.
116135
* @return Returns the ListPaymentRefundsResponse response from the API call
117136
*/
118137
public CompletableFuture<ListPaymentRefundsResponse> listPaymentRefundsAsync(
@@ -123,10 +142,13 @@ public CompletableFuture<ListPaymentRefundsResponse> listPaymentRefundsAsync(
123142
final String locationId,
124143
final String status,
125144
final String sourceType,
126-
final Integer limit) {
145+
final Integer limit,
146+
final String updatedAtBeginTime,
147+
final String updatedAtEndTime,
148+
final String sortField) {
127149
try {
128150
return prepareListPaymentRefundsRequest(beginTime, endTime, sortOrder, cursor, locationId,
129-
status, sourceType, limit).executeAsync();
151+
status, sourceType, limit, updatedAtBeginTime, updatedAtEndTime, sortField).executeAsync();
130152
} catch (Exception e) {
131153
throw new CompletionException(e);
132154
}
@@ -143,7 +165,10 @@ private ApiCall<ListPaymentRefundsResponse, ApiException> prepareListPaymentRefu
143165
final String locationId,
144166
final String status,
145167
final String sourceType,
146-
final Integer limit) throws IOException {
168+
final Integer limit,
169+
final String updatedAtBeginTime,
170+
final String updatedAtEndTime,
171+
final String sortField) throws IOException {
147172
return new ApiCall.Builder<ListPaymentRefundsResponse, ApiException>()
148173
.globalConfig(getGlobalConfiguration())
149174
.requestBuilder(requestBuilder -> requestBuilder
@@ -165,6 +190,12 @@ private ApiCall<ListPaymentRefundsResponse, ApiException> prepareListPaymentRefu
165190
.value(sourceType).isRequired(false))
166191
.queryParam(param -> param.key("limit")
167192
.value(limit).isRequired(false))
193+
.queryParam(param -> param.key("updated_at_begin_time")
194+
.value(updatedAtBeginTime).isRequired(false))
195+
.queryParam(param -> param.key("updated_at_end_time")
196+
.value(updatedAtEndTime).isRequired(false))
197+
.queryParam(param -> param.key("sort_field")
198+
.value(sortField).isRequired(false))
168199
.headerParam(param -> param.key("accept").value("application/json"))
169200
.withAuth(auth -> auth
170201
.add("global"))

0 commit comments

Comments
 (0)