Skip to content

Commit

Permalink
Solution For "Regarding ability to override stripe api url per API re… (
Browse files Browse the repository at this point in the history
#1476)

* Solution For "Regarding ability to override stripe api url per API request #1181".
#1181

* normalizeApiBase method added

* Replace ReflectionCheckingTypeAdapterFactory with a ReflectionAccessFilter (#1496)

* Replace ReflectionCheckingTypeAdapterFactory with a Filter

* Add test

* API Updates (#1497)

* Codegen for openapi v216

* Bump version to 22.4.0

* Actually release (#1499)

* Deprecate ApiResource.classUrl, etc.

* Tweak RequestOptions and ApiResource

* Format

* Codegen

* Overridden methods

* Update src/main/java/com/stripe/net/ApiResource.java

Co-authored-by: pakrym-stripe <[email protected]>

* Revert "Update src/main/java/com/stripe/net/ApiResource.java"

This reverts commit c263ce0.

Co-authored-by: Yasir Shabbir <[email protected]>
Co-authored-by: Richard Marmorstein <[email protected]>
Co-authored-by: Richard Marmorstein <[email protected]>
Co-authored-by: anniel-stripe <[email protected]>
Co-authored-by: pakrym-stripe <[email protected]>
  • Loading branch information
6 people authored Dec 29, 2022
1 parent 88aff00 commit 2390809
Show file tree
Hide file tree
Showing 102 changed files with 1,376 additions and 1,265 deletions.
56 changes: 28 additions & 28 deletions src/main/java/com/stripe/model/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ public CapabilityCollection capabilities(Map<String, Object> params) throws Stri
public CapabilityCollection capabilities(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s/capabilities", ApiResource.urlEncodeId(this.getId())));
return ApiResource.requestCollection(url, params, CapabilityCollection.class, options);
}
Expand All @@ -199,9 +199,9 @@ public CapabilityCollection capabilities(AccountCapabilitiesParams params)
public CapabilityCollection capabilities(AccountCapabilitiesParams params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s/capabilities", ApiResource.urlEncodeId(this.getId())));
return ApiResource.requestCollection(url, params, CapabilityCollection.class, options);
}
Expand All @@ -222,7 +222,7 @@ public static Account create(Map<String, Object> params) throws StripeException
*/
public static Account create(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/accounts");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/accounts");
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Account.class, options);
}

Expand All @@ -242,7 +242,7 @@ public static Account create(AccountCreateParams params) throws StripeException
*/
public static Account create(AccountCreateParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/accounts");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/accounts");
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Account.class, options);
}

Expand Down Expand Up @@ -304,9 +304,9 @@ public Account delete(Map<String, Object> params) throws StripeException {
*/
public Account delete(Map<String, Object> params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s", ApiResource.urlEncodeId(this.getId())));
return ApiResource.request(
ApiResource.RequestMethod.DELETE, url, params, Account.class, options);
Expand All @@ -328,7 +328,7 @@ public static AccountCollection list(Map<String, Object> params) throws StripeEx
*/
public static AccountCollection list(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/accounts");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/accounts");
return ApiResource.requestCollection(url, params, AccountCollection.class, options);
}

Expand All @@ -348,7 +348,7 @@ public static AccountCollection list(AccountListParams params) throws StripeExce
*/
public static AccountCollection list(AccountListParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/accounts");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/accounts");
return ApiResource.requestCollection(url, params, AccountCollection.class, options);
}

Expand All @@ -375,9 +375,9 @@ public PersonCollection persons(Map<String, Object> params) throws StripeExcepti
public PersonCollection persons(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s/persons", ApiResource.urlEncodeId(this.getId())));
return ApiResource.requestCollection(url, params, PersonCollection.class, options);
}
Expand All @@ -397,9 +397,9 @@ public PersonCollection persons(AccountPersonsParams params) throws StripeExcept
public PersonCollection persons(AccountPersonsParams params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s/persons", ApiResource.urlEncodeId(this.getId())));
return ApiResource.requestCollection(url, params, PersonCollection.class, options);
}
Expand All @@ -424,9 +424,9 @@ public Account reject(Map<String, Object> params) throws StripeException {
*/
public Account reject(Map<String, Object> params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s/reject", ApiResource.urlEncodeId(this.getId())));
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Account.class, options);
}
Expand All @@ -451,9 +451,9 @@ public Account reject(AccountRejectParams params) throws StripeException {
*/
public Account reject(AccountRejectParams params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s/reject", ApiResource.urlEncodeId(this.getId())));
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Account.class, options);
}
Expand All @@ -471,14 +471,14 @@ public static Account retrieve(RequestOptions options) throws StripeException {
/** Retrieves the details of an account. */
public static Account retrieve(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/account");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/account");
return ApiResource.request(ApiResource.RequestMethod.GET, url, params, Account.class, options);
}

/** Retrieves the details of an account. */
public static Account retrieve(AccountRetrieveParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/account");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/account");
return ApiResource.request(ApiResource.RequestMethod.GET, url, params, Account.class, options);
}

Expand All @@ -496,9 +496,9 @@ public static Account retrieve(String account, RequestOptions options) throws St
public static Account retrieve(String account, Map<String, Object> params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s", ApiResource.urlEncodeId(account)));
return ApiResource.request(ApiResource.RequestMethod.GET, url, params, Account.class, options);
}
Expand All @@ -507,9 +507,9 @@ public static Account retrieve(String account, Map<String, Object> params, Reque
public static Account retrieve(
String account, AccountRetrieveParams params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s", ApiResource.urlEncodeId(account)));
return ApiResource.request(ApiResource.RequestMethod.GET, url, params, Account.class, options);
}
Expand Down Expand Up @@ -546,9 +546,9 @@ public Account update(Map<String, Object> params) throws StripeException {
@Override
public Account update(Map<String, Object> params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s", ApiResource.urlEncodeId(this.getId())));
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Account.class, options);
}
Expand Down Expand Up @@ -583,9 +583,9 @@ public Account update(AccountUpdateParams params) throws StripeException {
*/
public Account update(AccountUpdateParams params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/accounts/%s", ApiResource.urlEncodeId(this.getId())));
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Account.class, options);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/stripe/model/AccountLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static AccountLink create(Map<String, Object> params) throws StripeExcept
*/
public static AccountLink create(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/account_links");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/account_links");
return ApiResource.request(
ApiResource.RequestMethod.POST, url, params, AccountLink.class, options);
}
Expand All @@ -76,7 +76,7 @@ public static AccountLink create(AccountLinkCreateParams params) throws StripeEx
*/
public static AccountLink create(AccountLinkCreateParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/account_links");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/account_links");
return ApiResource.request(
ApiResource.RequestMethod.POST, url, params, AccountLink.class, options);
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/stripe/model/ApplePayDomain.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static ApplePayDomain create(Map<String, Object> params) throws StripeExc
/** Create an apple pay domain. */
public static ApplePayDomain create(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/apple_pay/domains");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/apple_pay/domains");
return ApiResource.request(
ApiResource.RequestMethod.POST, url, params, ApplePayDomain.class, options);
}
Expand All @@ -70,7 +70,7 @@ public static ApplePayDomain create(ApplePayDomainCreateParams params) throws St
/** Create an apple pay domain. */
public static ApplePayDomain create(ApplePayDomainCreateParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/apple_pay/domains");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/apple_pay/domains");
return ApiResource.request(
ApiResource.RequestMethod.POST, url, params, ApplePayDomain.class, options);
}
Expand All @@ -94,9 +94,9 @@ public ApplePayDomain delete(Map<String, Object> params) throws StripeException
public ApplePayDomain delete(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/apple_pay/domains/%s", ApiResource.urlEncodeId(this.getId())));
return ApiResource.request(
ApiResource.RequestMethod.DELETE, url, params, ApplePayDomain.class, options);
Expand All @@ -110,7 +110,7 @@ public static ApplePayDomainCollection list(Map<String, Object> params) throws S
/** List apple pay domains. */
public static ApplePayDomainCollection list(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/apple_pay/domains");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/apple_pay/domains");
return ApiResource.requestCollection(url, params, ApplePayDomainCollection.class, options);
}

Expand All @@ -123,7 +123,7 @@ public static ApplePayDomainCollection list(ApplePayDomainListParams params)
/** List apple pay domains. */
public static ApplePayDomainCollection list(
ApplePayDomainListParams params, RequestOptions options) throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/apple_pay/domains");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/apple_pay/domains");
return ApiResource.requestCollection(url, params, ApplePayDomainCollection.class, options);
}

Expand All @@ -142,9 +142,9 @@ public static ApplePayDomain retrieve(String domain, RequestOptions options)
public static ApplePayDomain retrieve(
String domain, Map<String, Object> params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/apple_pay/domains/%s", ApiResource.urlEncodeId(domain)));
return ApiResource.request(
ApiResource.RequestMethod.GET, url, params, ApplePayDomain.class, options);
Expand All @@ -155,9 +155,9 @@ public static ApplePayDomain retrieve(
String domain, ApplePayDomainRetrieveParams params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/apple_pay/domains/%s", ApiResource.urlEncodeId(domain)));
return ApiResource.request(
ApiResource.RequestMethod.GET, url, params, ApplePayDomain.class, options);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/stripe/model/ApplicationFee.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public static ApplicationFeeCollection list(Map<String, Object> params) throws S
*/
public static ApplicationFeeCollection list(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/application_fees");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/application_fees");
return ApiResource.requestCollection(url, params, ApplicationFeeCollection.class, options);
}

Expand All @@ -231,7 +231,7 @@ public static ApplicationFeeCollection list(ApplicationFeeListParams params)
*/
public static ApplicationFeeCollection list(
ApplicationFeeListParams params, RequestOptions options) throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/application_fees");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/application_fees");
return ApiResource.requestCollection(url, params, ApplicationFeeCollection.class, options);
}

Expand All @@ -258,9 +258,9 @@ public static ApplicationFee retrieve(String id, RequestOptions options) throws
public static ApplicationFee retrieve(
String id, Map<String, Object> params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/application_fees/%s", ApiResource.urlEncodeId(id)));
return ApiResource.request(
ApiResource.RequestMethod.GET, url, params, ApplicationFee.class, options);
Expand All @@ -274,9 +274,9 @@ public static ApplicationFee retrieve(
String id, ApplicationFeeRetrieveParams params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/application_fees/%s", ApiResource.urlEncodeId(id)));
return ApiResource.request(
ApiResource.RequestMethod.GET, url, params, ApplicationFee.class, options);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/stripe/model/Balance.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static Balance retrieve(RequestOptions options) throws StripeException {
*/
public static Balance retrieve(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/balance");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/balance");
return ApiResource.request(ApiResource.RequestMethod.GET, url, params, Balance.class, options);
}

Expand All @@ -117,7 +117,7 @@ public static Balance retrieve(Map<String, Object> params, RequestOptions option
*/
public static Balance retrieve(BalanceRetrieveParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/balance");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/balance");
return ApiResource.request(ApiResource.RequestMethod.GET, url, params, Balance.class, options);
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/stripe/model/BalanceTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public static BalanceTransactionCollection list(Map<String, Object> params)
*/
public static BalanceTransactionCollection list(
Map<String, Object> params, RequestOptions options) throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/balance_transactions");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/balance_transactions");
return ApiResource.requestCollection(url, params, BalanceTransactionCollection.class, options);
}

Expand All @@ -205,7 +205,7 @@ public static BalanceTransactionCollection list(BalanceTransactionListParams par
*/
public static BalanceTransactionCollection list(
BalanceTransactionListParams params, RequestOptions options) throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/balance_transactions");
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, "/v1/balance_transactions");
return ApiResource.requestCollection(url, params, BalanceTransactionCollection.class, options);
}

Expand Down Expand Up @@ -236,9 +236,9 @@ public static BalanceTransaction retrieve(String id, RequestOptions options)
public static BalanceTransaction retrieve(
String id, Map<String, Object> params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/balance_transactions/%s", ApiResource.urlEncodeId(id)));
return ApiResource.request(
ApiResource.RequestMethod.GET, url, params, BalanceTransaction.class, options);
Expand All @@ -253,9 +253,9 @@ public static BalanceTransaction retrieve(
String id, BalanceTransactionRetrieveParams params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
ApiResource.fullUrl(
Stripe.getApiBase(),
options,
String.format("/v1/balance_transactions/%s", ApiResource.urlEncodeId(id)));
return ApiResource.request(
ApiResource.RequestMethod.GET, url, params, BalanceTransaction.class, options);
Expand Down
Loading

0 comments on commit 2390809

Please sign in to comment.