Skip to content

Commit ff4a37c

Browse files
authored
Merge pull request #82 from square/release/22.0.0.20220720
Generated PR for Release: 22.0.0.20220720
2 parents 9da1aa9 + b5ee246 commit ff4a37c

File tree

7 files changed

+140
-15
lines changed

7 files changed

+140
-15
lines changed

doc/models/obtain-token-request.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
| `MigrationToken` | `String` | Optional | A legacy OAuth access token obtained using a Connect API version prior<br>to 2019-03-13. This parameter is required if `grant_type` is set to<br>`migration_token` to indicate that the application wants to get a replacement<br>OAuth access token. The response also returns a refresh token.<br>For more information, see [Migrate to Using Refresh Tokens](https://developer.squareup.com/docs/oauth-api/migrate-to-refresh-tokens).<br>**Constraints**: *Minimum Length*: `2`, *Maximum Length*: `1024` | String getMigrationToken() |
1919
| `Scopes` | `List<String>` | Optional | A JSON list of strings representing the permissions that the application is requesting.<br>For example, "`["MERCHANT_PROFILE_READ","PAYMENTS_READ","BANK_ACCOUNTS_READ"]`".<br><br>The access token returned in the response is granted the permissions<br>that comprise the intersection between the requested list of permissions and those<br>that belong to the provided refresh token. | List<String> getScopes() |
2020
| `ShortLived` | `Boolean` | Optional | A Boolean indicating a request for a short-lived access token.<br><br>The short-lived access token returned in the response expires in 24 hours. | Boolean getShortLived() |
21+
| `CodeVerifier` | `String` | Optional | Must be provided when using PKCE OAuth flow. The `code_verifier` will be used to verify against the<br>`code_challenge` associated with the `authorization_code`. | String getCodeVerifier() |
2122

2223
## Example (as JSON)
2324

doc/models/obtain-token-response.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
| `RefreshToken` | `String` | Optional | A refresh token. OAuth refresh tokens are 64 bytes long.<br>For more information, see [Refresh, Revoke, and Limit the Scope of OAuth Tokens](https://developer.squareup.com/docs/oauth-api/refresh-revoke-limit-scope).<br>**Constraints**: *Minimum Length*: `2`, *Maximum Length*: `1024` | String getRefreshToken() |
2020
| `ShortLived` | `Boolean` | Optional | A Boolean indicating that the access token is a short-lived access token.<br>The short-lived access token returned in the response expires in 24 hours. | Boolean getShortLived() |
2121
| `Errors` | [`List<Error>`](../../doc/models/error.md) | Optional | Any errors that occurred during the request. | List<Error> getErrors() |
22+
| `RefreshTokenExpiresAt` | `String` | Optional | The date when the `refresh_token` expires, in [ISO 8601](http://www.iso.org/iso/home/standards/iso8601.htm) format.<br>**Constraints**: *Minimum Length*: `20`, *Maximum Length*: `48` | String getRefreshTokenExpiresAt() |
23+
| `AppSubscriptionId` | `String` | Optional | The subscription id of a v2 subscription the merchant signed up<br>for. The subscription id is only present if the merchant signed up for a subscription during authorization. | String getAppSubscriptionId() |
24+
| `AppPlanId` | `String` | Optional | The plan id of a v2 subscription plan the merchant signed up<br>for. The plan id is only present if the merchant signed up for a subscription plan during authorization. | String getAppPlanId() |
2225

2326
## Example (as JSON)
2427

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.squareup</groupId>
66
<artifactId>square</artifactId>
7-
<version>21.0.0.20220720</version>
7+
<version>22.0.0.20220720</version>
88
<packaging>jar</packaging>
99

1010
<name>Square</name>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ public String getAccessToken() {
645645
* @return sdkVersion
646646
*/
647647
public String getSdkVersion() {
648-
return "21.0.0.20220720";
648+
return "22.0.0.20220720";
649649
}
650650

651651
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public abstract class BaseApi {
2222

2323
protected String internalUserAgent;
2424

25-
private static String userAgent = "Square-Java-SDK/21.0.0.20220720 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}";
25+
private static String userAgent = "Square-Java-SDK/22.0.0.20220720 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}";
2626

2727
/**
2828
* Protected variables to hold an instance of Configuration.

src/main/java/com/squareup/square/models/ObtainTokenRequest.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class ObtainTokenRequest {
2121
private final String migrationToken;
2222
private final List<String> scopes;
2323
private final Boolean shortLived;
24+
private final String codeVerifier;
2425

2526
/**
2627
* Initialization constructor.
@@ -33,6 +34,7 @@ public class ObtainTokenRequest {
3334
* @param migrationToken String value for migrationToken.
3435
* @param scopes List of String value for scopes.
3536
* @param shortLived Boolean value for shortLived.
37+
* @param codeVerifier String value for codeVerifier.
3638
*/
3739
@JsonCreator
3840
public ObtainTokenRequest(
@@ -44,7 +46,8 @@ public ObtainTokenRequest(
4446
@JsonProperty("refresh_token") String refreshToken,
4547
@JsonProperty("migration_token") String migrationToken,
4648
@JsonProperty("scopes") List<String> scopes,
47-
@JsonProperty("short_lived") Boolean shortLived) {
49+
@JsonProperty("short_lived") Boolean shortLived,
50+
@JsonProperty("code_verifier") String codeVerifier) {
4851
this.clientId = clientId;
4952
this.clientSecret = clientSecret;
5053
this.code = code;
@@ -54,6 +57,7 @@ public ObtainTokenRequest(
5457
this.migrationToken = migrationToken;
5558
this.scopes = scopes;
5659
this.shortLived = shortLived;
60+
this.codeVerifier = codeVerifier;
5761
}
5862

5963
/**
@@ -168,10 +172,22 @@ public Boolean getShortLived() {
168172
return shortLived;
169173
}
170174

175+
/**
176+
* Getter for CodeVerifier.
177+
* Must be provided when using PKCE OAuth flow. The `code_verifier` will be used to verify
178+
* against the `code_challenge` associated with the `authorization_code`.
179+
* @return Returns the String
180+
*/
181+
@JsonGetter("code_verifier")
182+
@JsonInclude(JsonInclude.Include.NON_NULL)
183+
public String getCodeVerifier() {
184+
return codeVerifier;
185+
}
186+
171187
@Override
172188
public int hashCode() {
173189
return Objects.hash(clientId, clientSecret, code, redirectUri, grantType, refreshToken,
174-
migrationToken, scopes, shortLived);
190+
migrationToken, scopes, shortLived, codeVerifier);
175191
}
176192

177193
@Override
@@ -191,7 +207,8 @@ public boolean equals(Object obj) {
191207
&& Objects.equals(refreshToken, other.refreshToken)
192208
&& Objects.equals(migrationToken, other.migrationToken)
193209
&& Objects.equals(scopes, other.scopes)
194-
&& Objects.equals(shortLived, other.shortLived);
210+
&& Objects.equals(shortLived, other.shortLived)
211+
&& Objects.equals(codeVerifier, other.codeVerifier);
195212
}
196213

197214
/**
@@ -203,7 +220,8 @@ public String toString() {
203220
return "ObtainTokenRequest [" + "clientId=" + clientId + ", clientSecret=" + clientSecret
204221
+ ", grantType=" + grantType + ", code=" + code + ", redirectUri=" + redirectUri
205222
+ ", refreshToken=" + refreshToken + ", migrationToken=" + migrationToken
206-
+ ", scopes=" + scopes + ", shortLived=" + shortLived + "]";
223+
+ ", scopes=" + scopes + ", shortLived=" + shortLived + ", codeVerifier="
224+
+ codeVerifier + "]";
207225
}
208226

209227
/**
@@ -218,7 +236,8 @@ public Builder toBuilder() {
218236
.refreshToken(getRefreshToken())
219237
.migrationToken(getMigrationToken())
220238
.scopes(getScopes())
221-
.shortLived(getShortLived());
239+
.shortLived(getShortLived())
240+
.codeVerifier(getCodeVerifier());
222241
return builder;
223242
}
224243

@@ -235,6 +254,7 @@ public static class Builder {
235254
private String migrationToken;
236255
private List<String> scopes;
237256
private Boolean shortLived;
257+
private String codeVerifier;
238258

239259
/**
240260
* Initialization constructor.
@@ -338,13 +358,23 @@ public Builder shortLived(Boolean shortLived) {
338358
return this;
339359
}
340360

361+
/**
362+
* Setter for codeVerifier.
363+
* @param codeVerifier String value for codeVerifier.
364+
* @return Builder
365+
*/
366+
public Builder codeVerifier(String codeVerifier) {
367+
this.codeVerifier = codeVerifier;
368+
return this;
369+
}
370+
341371
/**
342372
* Builds a new {@link ObtainTokenRequest} object using the set fields.
343373
* @return {@link ObtainTokenRequest}
344374
*/
345375
public ObtainTokenRequest build() {
346376
return new ObtainTokenRequest(clientId, clientSecret, grantType, code, redirectUri,
347-
refreshToken, migrationToken, scopes, shortLived);
377+
refreshToken, migrationToken, scopes, shortLived, codeVerifier);
348378
}
349379
}
350380
}

src/main/java/com/squareup/square/models/ObtainTokenResponse.java

Lines changed: 97 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public class ObtainTokenResponse {
2525
private final String refreshToken;
2626
private final Boolean shortLived;
2727
private final List<Error> errors;
28+
private final String refreshTokenExpiresAt;
29+
private final String appSubscriptionId;
30+
private final String appPlanId;
2831

2932
/**
3033
* Initialization constructor.
@@ -38,6 +41,9 @@ public class ObtainTokenResponse {
3841
* @param refreshToken String value for refreshToken.
3942
* @param shortLived Boolean value for shortLived.
4043
* @param errors List of Error value for errors.
44+
* @param refreshTokenExpiresAt String value for refreshTokenExpiresAt.
45+
* @param appSubscriptionId String value for appSubscriptionId.
46+
* @param appPlanId String value for appPlanId.
4147
*/
4248
@JsonCreator
4349
public ObtainTokenResponse(
@@ -50,7 +56,10 @@ public ObtainTokenResponse(
5056
@JsonProperty("id_token") String idToken,
5157
@JsonProperty("refresh_token") String refreshToken,
5258
@JsonProperty("short_lived") Boolean shortLived,
53-
@JsonProperty("errors") List<Error> errors) {
59+
@JsonProperty("errors") List<Error> errors,
60+
@JsonProperty("refresh_token_expires_at") String refreshTokenExpiresAt,
61+
@JsonProperty("app_subscription_id") String appSubscriptionId,
62+
@JsonProperty("app_plan_id") String appPlanId) {
5463
this.accessToken = accessToken;
5564
this.tokenType = tokenType;
5665
this.expiresAt = expiresAt;
@@ -61,6 +70,9 @@ public ObtainTokenResponse(
6170
this.refreshToken = refreshToken;
6271
this.shortLived = shortLived;
6372
this.errors = errors;
73+
this.refreshTokenExpiresAt = refreshTokenExpiresAt;
74+
this.appSubscriptionId = appSubscriptionId;
75+
this.appPlanId = appPlanId;
6476
}
6577

6678
@JsonIgnore
@@ -187,10 +199,47 @@ public List<Error> getErrors() {
187199
return errors;
188200
}
189201

202+
/**
203+
* Getter for RefreshTokenExpiresAt.
204+
* The date when the `refresh_token` expires, in [ISO
205+
* 8601](http://www.iso.org/iso/home/standards/iso8601.htm) format.
206+
* @return Returns the String
207+
*/
208+
@JsonGetter("refresh_token_expires_at")
209+
@JsonInclude(JsonInclude.Include.NON_NULL)
210+
public String getRefreshTokenExpiresAt() {
211+
return refreshTokenExpiresAt;
212+
}
213+
214+
/**
215+
* Getter for AppSubscriptionId.
216+
* The subscription id of a v2 subscription the merchant signed up for. The subscription id is
217+
* only present if the merchant signed up for a subscription during authorization.
218+
* @return Returns the String
219+
*/
220+
@JsonGetter("app_subscription_id")
221+
@JsonInclude(JsonInclude.Include.NON_NULL)
222+
public String getAppSubscriptionId() {
223+
return appSubscriptionId;
224+
}
225+
226+
/**
227+
* Getter for AppPlanId.
228+
* The plan id of a v2 subscription plan the merchant signed up for. The plan id is only present
229+
* if the merchant signed up for a subscription plan during authorization.
230+
* @return Returns the String
231+
*/
232+
@JsonGetter("app_plan_id")
233+
@JsonInclude(JsonInclude.Include.NON_NULL)
234+
public String getAppPlanId() {
235+
return appPlanId;
236+
}
237+
190238
@Override
191239
public int hashCode() {
192240
return Objects.hash(accessToken, tokenType, expiresAt, merchantId, subscriptionId, planId,
193-
idToken, refreshToken, shortLived, errors);
241+
idToken, refreshToken, shortLived, errors, refreshTokenExpiresAt, appSubscriptionId,
242+
appPlanId);
194243
}
195244

196245
@Override
@@ -211,7 +260,10 @@ public boolean equals(Object obj) {
211260
&& Objects.equals(idToken, other.idToken)
212261
&& Objects.equals(refreshToken, other.refreshToken)
213262
&& Objects.equals(shortLived, other.shortLived)
214-
&& Objects.equals(errors, other.errors);
263+
&& Objects.equals(errors, other.errors)
264+
&& Objects.equals(refreshTokenExpiresAt, other.refreshTokenExpiresAt)
265+
&& Objects.equals(appSubscriptionId, other.appSubscriptionId)
266+
&& Objects.equals(appPlanId, other.appPlanId);
215267
}
216268

217269
/**
@@ -223,7 +275,9 @@ public String toString() {
223275
return "ObtainTokenResponse [" + "accessToken=" + accessToken + ", tokenType=" + tokenType
224276
+ ", expiresAt=" + expiresAt + ", merchantId=" + merchantId + ", subscriptionId="
225277
+ subscriptionId + ", planId=" + planId + ", idToken=" + idToken + ", refreshToken="
226-
+ refreshToken + ", shortLived=" + shortLived + ", errors=" + errors + "]";
278+
+ refreshToken + ", shortLived=" + shortLived + ", errors=" + errors
279+
+ ", refreshTokenExpiresAt=" + refreshTokenExpiresAt + ", appSubscriptionId="
280+
+ appSubscriptionId + ", appPlanId=" + appPlanId + "]";
227281
}
228282

229283
/**
@@ -242,7 +296,10 @@ public Builder toBuilder() {
242296
.idToken(getIdToken())
243297
.refreshToken(getRefreshToken())
244298
.shortLived(getShortLived())
245-
.errors(getErrors());
299+
.errors(getErrors())
300+
.refreshTokenExpiresAt(getRefreshTokenExpiresAt())
301+
.appSubscriptionId(getAppSubscriptionId())
302+
.appPlanId(getAppPlanId());
246303
return builder;
247304
}
248305

@@ -261,6 +318,9 @@ public static class Builder {
261318
private String refreshToken;
262319
private Boolean shortLived;
263320
private List<Error> errors;
321+
private String refreshTokenExpiresAt;
322+
private String appSubscriptionId;
323+
private String appPlanId;
264324

265325

266326

@@ -374,14 +434,45 @@ public Builder errors(List<Error> errors) {
374434
return this;
375435
}
376436

437+
/**
438+
* Setter for refreshTokenExpiresAt.
439+
* @param refreshTokenExpiresAt String value for refreshTokenExpiresAt.
440+
* @return Builder
441+
*/
442+
public Builder refreshTokenExpiresAt(String refreshTokenExpiresAt) {
443+
this.refreshTokenExpiresAt = refreshTokenExpiresAt;
444+
return this;
445+
}
446+
447+
/**
448+
* Setter for appSubscriptionId.
449+
* @param appSubscriptionId String value for appSubscriptionId.
450+
* @return Builder
451+
*/
452+
public Builder appSubscriptionId(String appSubscriptionId) {
453+
this.appSubscriptionId = appSubscriptionId;
454+
return this;
455+
}
456+
457+
/**
458+
* Setter for appPlanId.
459+
* @param appPlanId String value for appPlanId.
460+
* @return Builder
461+
*/
462+
public Builder appPlanId(String appPlanId) {
463+
this.appPlanId = appPlanId;
464+
return this;
465+
}
466+
377467
/**
378468
* Builds a new {@link ObtainTokenResponse} object using the set fields.
379469
* @return {@link ObtainTokenResponse}
380470
*/
381471
public ObtainTokenResponse build() {
382472
ObtainTokenResponse model =
383473
new ObtainTokenResponse(accessToken, tokenType, expiresAt, merchantId,
384-
subscriptionId, planId, idToken, refreshToken, shortLived, errors);
474+
subscriptionId, planId, idToken, refreshToken, shortLived, errors,
475+
refreshTokenExpiresAt, appSubscriptionId, appPlanId);
385476
model.httpContext = httpContext;
386477
return model;
387478
}

0 commit comments

Comments
 (0)