-
Notifications
You must be signed in to change notification settings - Fork 388
Introduce version pinning for autogen #651
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
Introduce version pinning for autogen #651
Conversation
| * Stripe version when made on behalf of others. This can be used when the returned response | ||
| * will not be deserialized into the current classes pinned to {@link Stripe#VERSION}. | ||
| */ | ||
| private final String stripeVersionOnBehalfOf; |
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.
Generalize the stripe version of mobile client required by ephemeral key to stripeVersionOnBehalfOf.
Putting in request option here avoid considering stripe version here has method params.
| : 0); | ||
| result = 31 * result + (idempotencyKey != null ? idempotencyKey.hashCode() : 0); | ||
| result = 31 * result + readTimeout; | ||
| result = 31 * result + (stripeAccount != null ? stripeAccount.hashCode() : 0); |
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.
stripeAccount is added, although not related to this PR. I think it was unintentionally left out
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.
+1. That's the thing with these manual implementations — it's really easy to forget things.
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.
We could probably replace these manual implementations with Lombok's @EqualsAndHashCode.
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.
whoops, sorry i missed this and merged to my branch without it. Will update in subsequent PR
brandur-stripe
left a comment
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.
A few minor comments, but LGTM.
@ob-stripe You may want to take a look as well.
src/main/java/com/stripe/Stripe.java
Outdated
| public static final String CONNECT_API_BASE = "https://connect.stripe.com"; | ||
| public static final String UPLOAD_API_BASE = "https://files.stripe.com"; | ||
| public static final String VERSION = "7.14.0"; | ||
| public static final String API_VERSION = "2018-11-08"; |
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.
Can you put API_VERSION in here alphabetically?
| private String apiKey; | ||
| private String clientId; | ||
| private String stripeVersion; | ||
| private String stripeVersionOnBehalfOf; |
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.
Similarly, alphabetize this (basically any list of things that looks like someone's put in the effort to alphabetize initially).
| * @param stripeVersionOnBehalfOf stripe version of the client to make request on behalf of | ||
| * @return option builder | ||
| */ | ||
| public RequestOptionsBuilder setStripeVersionOnBehalfOf(String stripeVersionOnBehalfOf) { |
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.
Not too sure about the naming here — can we just call it setStripeVersion? We can specify in the comments that it'll override the built-in version.
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.
@brandur, I'm wondering if i should make the name different here. I'm afraid that merchants who are using pre-pinning version still have setStripeVersion invocations, and once they migrate to pinned-version will not realize the semantic difference here.
Making it explicitly different here, and remove the old method will at least ensure that they set up the integration correctly.
Would naming like overrideStripeVersion would be a better alternative?
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.
Oh oops — I didn't read carefully enough and didn't realize that setStripeVersion could already be called for RequestOptions before.
Yeah, I was actually going to suggest using "override" in the name as an alternative before, so totally okay with that. I'd suggest stripeVersionOverride instead of overrideStripeVersion though since it sorts more nicely.
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.
acked!
9a34152 to
5c154c9
Compare
| return false; | ||
| } | ||
| if (stripeVersion != null ? !stripeVersion.equals(that.stripeVersion) | ||
| : that.stripeVersion != null) { |
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.
Reordering to match the alphabetically sorted instance variables, plus adding stripeAccount
5c154c9 to
4274a86
Compare
|
thank you @brandur! I cleaned up variable alphabetical order, and renamed the the |
|
LGTM! |
|
thank you both! will rebase this on my pre-autogen branch |
|
self-approving after rebase on autogen branch |
…rawong/version-pin-java make alphabetically order rename to override instead of onBehalf of
…rawong/version-pin-java make alphabetically order rename to override instead of onBehalf of
…rawong/version-pin-java make alphabetically order rename to override instead of onBehalf of
…rawong/version-pin-java make alphabetically order rename to override instead of onBehalf of
mickjermsurawong/autogen-pre-masterbranch, but i'm basing here on master to show compatibility and to pass master tests first.EphemeralKeythat does not use the static version. (This class is together with File, Event, are not autogenerated).stripeVersionOnBehalfOffor request options. This is different from both .NET and Go. where it takes version as the method params. I think that it would be better continue the pattern of header-related values to request option, and not in the parameters map.r? @brandur-stripe
cc @stripe/api-libraries