-
Notifications
You must be signed in to change notification settings - Fork 387
Autogen-8.0 #662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autogen-8.0 #662
Conversation
87394b5 to
6ce8daf
Compare
|
@remi-stripe the commit started with |
6ce8daf to
2733fc7
Compare
|
This is failing now because I rebased on the latest master |
c40db5e to
5340c29
Compare
ec2a54d to
fa53301
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ptal @brandur-stripe @ob-stripe
I enumerated 18 patterns of API methods encountered in stripe-java generated from sanity check here [0]
I put them in spreadsheet here and randomly manually check the implementations by myself here [1]
I made another random checks (under column in beta-8.0 PR) and annotate them on PR here for ease of review. Please feel free to spotcheck the endpoints in the spreadsheet. There are a few endpoints still to be merged.
[0] https://git.corp.stripe.com/stripe-internal/sdk-autogen-java/pull/46
[1] https://docs.google.com/spreadsheets/d/1Rv-ybR2vXbM9UC26UBOPcnTtqyopic9KTjkrunjjk-w/edit#gid=0
| * complete. | ||
| */ | ||
| public PersonCollection persons(Map<String, Object> params) | ||
| public static Account create(Map<String, Object> params, RequestOptions options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Create (standard): Static method to create a resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/Account.java
Lines 231 to 235 in 2aa5db5
| public static Account create(Map<String, Object> params, RequestOptions options) | |
| throws StripeException { | |
| String url = String.format("%s%s", Stripe.getApiBase(), "/v1/accounts"); | |
| return request(ApiResource.RequestMethod.POST, url, params, Account.class, options); | |
| } |
| * href="#balance_object">balance object</a> details available and pending amounts by source type. | ||
| */ | ||
| public static PayoutCollection list(Map<String, Object> params, RequestOptions options) | ||
| public static Payout create(Map<String, Object> params, RequestOptions options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Create (standard): Static method to create a resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/Payout.java
Lines 282 to 286 in 2aa5db5
| public static Payout create(Map<String, Object> params, RequestOptions options) | |
| throws StripeException { | |
| String url = String.format("%s%s", Stripe.getApiBase(), "/v1/payouts"); | |
| return request(ApiResource.RequestMethod.POST, url, params, Payout.class, options); | |
| } |
| Stripe.getApiBase(), this.getUrl()), params, FeeRefund.class, options); | ||
| String url = String.format("%s%s", Stripe.getApiBase(), this.getUrl()); | ||
| return ApiResource.request( | ||
| ApiResource.RequestMethod.POST, url, params, FeeRefund.class, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Create (standard): Instance method to create sub-resource on collection already containing ID of the parent resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/FeeRefundCollection.java
Lines 38 to 43 in 2aa5db5
| public FeeRefund create(Map<String, Object> params, RequestOptions options) | |
| throws StripeException { | |
| String url = String.format("%s%s", Stripe.getApiBase(), this.getUrl()); | |
| return ApiResource.request( | |
| ApiResource.RequestMethod.POST, url, params, FeeRefund.class, options); | |
| } |
| */ | ||
| public static UsageRecord create(Map<String, Object> params, RequestOptions options) | ||
| public static UsageRecord createOnSubscriptionItem( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Create (custom): Static method to create sub-resource on parent resource, taking of parent resource explicitly.
Contrast this to creating on sub-resource collection relying on the implicit parent resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/UsageRecord.java
Lines 69 to 79 in 2aa5db5
| public static UsageRecord createOnSubscriptionItem( | |
| String subscriptionItem, Map<String, Object> params, RequestOptions options) | |
| throws StripeException { | |
| String url = | |
| String.format( | |
| "%s%s", | |
| Stripe.getApiBase(), | |
| String.format("/v1/subscription_items/%s/usage_records", subscriptionItem)); | |
| return request(ApiResource.RequestMethod.POST, url, params, UsageRecord.class, options); | |
| } | |
| } |
| return request(RequestMethod.GET, singleClassUrl(Balance.class), params, Balance.class, | ||
| options); | ||
| String url = String.format("%s%s", Stripe.getApiBase(), "/v1/balance"); | ||
| return request(ApiResource.RequestMethod.GET, url, params, Balance.class, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Retrieve (standard): Static method to retrieve a singleton-like resource, taking no ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/Balance.java
Lines 80 to 84 in 2aa5db5
| public static Balance retrieve(Map<String, Object> params, RequestOptions options) | |
| throws StripeException { | |
| String url = String.format("%s%s", Stripe.getApiBase(), "/v1/balance"); | |
| return request(ApiResource.RequestMethod.GET, url, params, Balance.class, options); | |
| } |
| 0, | ||
| null); | ||
| } | ||
| return request(ApiResource.RequestMethod.POST, url, params, BankAccount.class, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Update (custom): Instance method to update sub-resource having business-logic impact besides mutating the data. Same behavior of relying on instance ID attributes of instance and its parent resource just just like the standard update method on sub-resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/BankAccount.java
Lines 279 to 300 in 2aa5db5
| /** Verify a specified bank account for a given customer. */ | |
| public BankAccount verify(Map<String, Object> params, RequestOptions options) | |
| throws StripeException { | |
| String url; | |
| if (this.getCustomer() != null) { | |
| url = | |
| String.format( | |
| "%s%s", | |
| Stripe.getApiBase(), | |
| String.format( | |
| "/v1/customers/%s/sources/%s/verify", this.getCustomer(), this.getId())); | |
| } else { | |
| throw new InvalidRequestException( | |
| "Unable to construct url because [customer] field(s) are all null", | |
| null, | |
| null, | |
| null, | |
| 0, | |
| null); | |
| } | |
| return request(ApiResource.RequestMethod.POST, url, params, BankAccount.class, options); | |
| } |
| String url = | ||
| String.format( | ||
| "%s%s", Stripe.getApiBase(), String.format("/v1/webhook_endpoints/%s", this.getId())); | ||
| return request(ApiResource.RequestMethod.DELETE, url, params, WebhookEndpoint.class, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Delete (standard): Instance method to delete a resource on itself, relying on ID attribute of the instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/WebhookEndpoint.java
Lines 182 to 193 in 2aa5db5
| /** | |
| * You can also delete webhook endpoints via the <a | |
| * href="https://dashboard.stripe.com/account/webhooks">webhook endpoint management</a> page of | |
| * the Stripe dashboard. | |
| */ | |
| public WebhookEndpoint delete(Map<String, Object> params, RequestOptions options) | |
| throws StripeException { | |
| String url = | |
| String.format( | |
| "%s%s", Stripe.getApiBase(), String.format("/v1/webhook_endpoints/%s", this.getId())); | |
| return request(ApiResource.RequestMethod.DELETE, url, params, WebhookEndpoint.class, options); | |
| } |
| 0, | ||
| null); | ||
| } | ||
| return request(ApiResource.RequestMethod.DELETE, url, params, Card.class, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Delete (standard): Instance method to delete a sub-resource on itself, relying on ID attributes of the instance, and of its parent resource. There is validation on parent resource ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/Card.java
Lines 334 to 364 in 2aa5db5
| /** | |
| * Delete a specified external account for a given account. | |
| * | |
| * <p>Delete a specified source for a given customer. | |
| */ | |
| public Card delete(Map<String, Object> params, RequestOptions options) throws StripeException { | |
| String url; | |
| if (this.getAccount() != null) { | |
| url = | |
| String.format( | |
| "%s%s", | |
| Stripe.getApiBase(), | |
| String.format( | |
| "/v1/accounts/%s/external_accounts/%s", this.getAccount(), this.getId())); | |
| } else if (this.getCustomer() != null) { | |
| url = | |
| String.format( | |
| "%s%s", | |
| Stripe.getApiBase(), | |
| String.format("/v1/customers/%s/sources/%s", this.getCustomer(), this.getId())); | |
| } else { | |
| throw new InvalidRequestException( | |
| "Unable to construct url because [account, customer] field(s) are all null", | |
| null, | |
| null, | |
| null, | |
| 0, | |
| null); | |
| } | |
| return request(ApiResource.RequestMethod.DELETE, url, params, Card.class, options); | |
| } |
| String url = | ||
| String.format( | ||
| "%s%s", Stripe.getApiBase(), String.format("/v1/customers/%s/discount", this.getId())); | ||
| return request(ApiResource.RequestMethod.DELETE, url, params, Discount.class, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Delete (custom): Instance method to delete an arbitrary resource relying ID attribute of the instance.
Method name makes it distinct from standard delete method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/Customer.java
Lines 285 to 292 in 2aa5db5
| /** Removes the currently applied discount on a customer. */ | |
| public Discount deleteDiscount(Map<String, Object> params, RequestOptions options) | |
| throws StripeException { | |
| String url = | |
| String.format( | |
| "%s%s", Stripe.getApiBase(), String.format("/v1/customers/%s/discount", this.getId())); | |
| return request(ApiResource.RequestMethod.DELETE, url, params, Discount.class, options); | |
| } |
| 0, | ||
| null); | ||
| } | ||
| return request(ApiResource.RequestMethod.DELETE, url, params, Source.class, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Delete (custom): Instance method to delete-like a sub-resource on itself, relying on ID attributes of the instance, and its reference to parent resource. POST should be used instead. Currently one method has this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripe-java/src/main/java/com/stripe/model/Source.java
Lines 187 to 206 in 2aa5db5
| /** Delete a specified source for a given customer. */ | |
| public Source detach(Map<String, Object> params, RequestOptions options) throws StripeException { | |
| String url; | |
| if (this.getCustomer() != null) { | |
| url = | |
| String.format( | |
| "%s%s", | |
| Stripe.getApiBase(), | |
| String.format("/v1/customers/%s/sources/%s", this.getCustomer(), this.getId())); | |
| } else { | |
| throw new InvalidRequestException( | |
| "Unable to construct url because [customer] field(s) are all null", | |
| null, | |
| null, | |
| null, | |
| 0, | |
| null); | |
| } | |
| return request(ApiResource.RequestMethod.DELETE, url, params, Source.class, options); | |
| } |
|
Added permalinks there for convenience of review without clicking to view the file |
5e2136d to
12b67a4
Compare
|
I looked over the snippets of code that you pulled out into comments; they look correct to me. |
|
I've spot-checked a few other random methods, particularly some non-CRUDL methods (charge capture, etc.) and nothing stood out to me either. This looks pretty great! |
…d Card in `/v1/customers/...`
…Link `craeteOnAccount`
Reversal to Transfer Reversal
…n favor of `createOnSubscriptionItem`
…03e408f22669 in master""
…on mismatch (#664) * make event data backward compat * implement versioned data * rename work * rename exception * improve deserializeUnsafeWith * add comments using static pinned version
…388f25f30d57 in master"" (#666)
…msurawong/subscription-schedules (#672)
test: CardTest ambiguous call with typed param
fix person
* extract common deserializer method extract common logic * implement ApiParamRequest add api param request * Add to base test lenient request params comparison for list/array int/long comparison * use List<Object> instead of Object[] in untyped deserializer * provide documentation to deserializer and api request param * reorder import statments * fix other imports in new files
* [generated] source: spec3.sdk.yaml@non-master-spec-e27a05e in mickjermsurawong/no-v-change * [generated] source: spec3.sdk.yaml@spec-82bb471 in master * [generated] source: spec3.sdk.yaml@spec-3869a7f in master * [generated] source: spec3.sdk.yaml@non-master-spec-02ef86a in mickjermsurawong/undoc-sensitive-enum
This reverts commit c3c1157.
This reverts commit a1c2175.
This reverts commit 1eb0f45.
0e3485b to
02502bb
Compare
|
thank you @remi-stripe @ob-stripe @tmaxwell-stripe @brandur-stripe !
|
|
LGTM I trust you, Mick 😄 |
This is a working branch for autogen-8.0 beta.
cc @stripe/api-libraries