-
Notifications
You must be signed in to change notification settings - Fork 460
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
Rename all properties in the library to match the API reference #544
Rename all properties in the library to match the API reference #544
Conversation
// File is a deprecated form of FileReader and Filename that will do the same thing, but | ||
// allows referencing a file directly. Please prefer the use of FileReader and Filename instead. | ||
File *os.File | ||
|
||
// FileReader is a reader with the contents of the file that should be uploaded. |
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.
Flagging that I seem to not be able to upload with FileReader
if I don't explicitly set Filename
too. Not sure if expected but I don't want to forget
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.
Hm, that shouldn't be the case, but we should look at that more closely.
event.go
Outdated
@@ -54,14 +54,14 @@ type EventListParams struct { | |||
Types []string `form:"types"` |
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.
Should this be a pointer to the array?
card.go
Outdated
Name string `form:"name"` | ||
Number string `form:"number"` | ||
Recipient string `form:"-"` | ||
Token string `form:"-"` | ||
|
||
// ID is used when tokenizing a card for shared customers | ||
ID string `form:"*"` |
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.
Should this be a pointer?
5832aee
to
4a5e87c
Compare
Haha, holy cow this is a monster! Amazing work Remi! Just to be explicit about it: is this ready for review? |
@brandur-stripe I think it is. The only todo left is to move/rename all constants to the upper package. This is less likely to break something and I will do it as one unique commit separately hopefully this week but we should not block on it. Let me know if I can help with the review in any way. The main gotcha I know of would be for parameters passed in the URL to be incorrectly sent as pointers address instead of the value. I haven't figured out a way to ensure this does not happen without just carefully reading the code though. |
We should write an "encode parameters" function that takes a splat and checks each value probably. I think we can push that to a different PR though. Maybe one that I could do for a change :) |
Ah yes we talked about this last week but that seemed like a lot of work and I was worried I might make things worse mixing this here. Do you think we should do this before merging? It does seem safer for sure. If you were to start the PR/build the method/examples, I can happily port all the clients to it afterwards |
55989a7
to
09fdca8
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.
Remi this is is just totally nuts! Alright, I left a few comments throughout the PR here. Most of them fall into three buckets:
- Eliminating the type aliases like
type Current string
like we talked about in Slack. We should probably do this along with the big breaking change, but now that I look here, I see what you mean that there's a lot of them. - In the response objects, some embedded structs are pointers (
*AdditionalOwner
) and some are just structs (AdditionalOwner
). I think we should skew all the way in one direction by just making them all pointers. - There's still quite a few constants embedded at the package level (e.g. in
sub/client.go
as opposed to at the top-levelstripe
package). See comments throughout, but we should probably hoist all of these up.
A few omissions with regards to Values
not being renamed to Data
in lists:
TopupList
SourceTransactionList
ExchangeRateList
A few omissions with regards to uint64
not being converted to int64
:
- All fields in the
DOB
struct. Limit
underListParams
.SubmissionCount
underEvidenceDetails
.Size
underFile
(indispute.go
).
Very excited to see this land! Thanks for all the hard work.
account.go
Outdated
BusinessNameKana *string `form:"business_name_kana"` | ||
BusinessNameKanji *string `form:"business_name_kanji"` | ||
BusinessTaxID *string `form:"business_tax_id"` | ||
BusinessVatID *string `form:"business_vat_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.
Should we used BusinessVATID
here (VAT = value added tax)? Admittedly, this is a pretty awkward name.
account.go
Outdated
SSNProvided bool `json:"ssn_last_4_provided" form:"-"` | ||
Type LegalEntityType `json:"type" form:"type"` | ||
Verification IdentityVerification `json:"verification" form:"verification"` | ||
AdditionalOwners []AdditionalOwner `json:"additional_owners"` |
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.
I notice that in other files, embedded structs tend to be points (e.g. []AdditionalOwner
). Should we do that for all the fields in LegalEntity
?
account.go
Outdated
FirstName string `json:"first_name"` | ||
FirstNameKana string `json:"first_name_kana"` | ||
FirstNameKanji string `json:"first_name_kanji"` | ||
Gender Gender `json:"gender"` |
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.
Where did we land on the type aliasing? Should we just remove Gender
in favor of string
?
account.go
Outdated
Verification IdentityVerification `json:"verification" form:"verification"` | ||
// AdditionalOwner is the structure for an account owner. | ||
type AdditionalOwner struct { | ||
Address AccountAddress `json:"address"` |
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.
Just flagging that the question around whether embedded structs should be pointers or not may apply to other structs in this file too.
func (d *IdentityDocument) AppendTo(body *form.Values, keyParts []string) { | ||
body.Add(form.FormatKey(keyParts), d.ID) | ||
Details string `json:"details"` | ||
DetailsCode IdentityVerificationDetailsCode `json:"details_code"` |
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.
Just flagging another type alias.
error.go
Outdated
InvalidRequest ErrorType = ErrorTypeInvalidRequest | ||
ErrorCodeCardDeclined ErrorCode = "card_declined" | ||
ErrorCodeExpiredCard ErrorCode = "expired_card" | ||
ErrorCodeIncorrectCvc ErrorCode = "incorrect_cvc" |
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.
Maybe change this to "CVC".
error.go
Outdated
ErrorCodeIncorrectCvc ErrorCode = "incorrect_cvc" | ||
ErrorCodeIncorrectZip ErrorCode = "incorrect_zip" | ||
ErrorCodeIncorrectNumber ErrorCode = "incorrect_number" | ||
ErrorCodeInvalidCvc ErrorCode = "invalid_cvc" |
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.
And same here: "CVC".
// File is a deprecated form of FileReader and Filename that will do the same thing, but | ||
// allows referencing a file directly. Please prefer the use of FileReader and Filename instead. | ||
File *os.File | ||
|
||
// FileReader is a reader with the contents of the file that should be uploaded. |
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.
Hm, that shouldn't be the case, but we should look at that more closely.
payout.go
Outdated
Card *Card `json:"card"` | ||
Created int64 `json:"created"` | ||
Currency Currency `json:"currency"` | ||
Destination PayoutDestination `json:"destination"` |
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.
Make this a point for consistency.
sub/client.go
Outdated
PastDue stripe.SubscriptionStatus = "past_due" | ||
Canceled stripe.SubscriptionStatus = "canceled" | ||
Unpaid stripe.SubscriptionStatus = "unpaid" | ||
All stripe.SubscriptionStatus = "all" |
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.
Maybe hoist these up to stripe
as well.
@brandur-stripe Thank you so much for the thorough review. I just fixed everything you raised that was an omission! Edit: Okay I had broken the build so I fixed it quickly. There's a small one that annoys me a bit which is
I can definitely do |
@brandur-stripe Okay I just started removing the "fake" types that we alias to string in the Before I go ahead and change the entire library again, can you confirm that this is the right approach and looks cleaner? Also, what do you think about not adding comments for those? That seems a bit much and most names are self explanatory. |
dc37d87
to
c77c833
Compare
Once we've done all constants, I'll then move to passing each embedded struct as a pointer too. |
Hah, yeah I thought about calling out status code too, but decided not to. If you look throughout the
Yep, that looks right. And +1 removing the comments.
Sounds good! Thanks Remi. |
@brandur-stripe My understanding is that we want to remove |
Yeah, good question. I think that since we sort of already have the list of constants, we should probably keep them around (but make them strings, so that the interface is compatible with just passing The counterargument is that some of these lists can be prone to becoming outdated (as new currencies are added and such), but my intuition would be that currencies (or more specifically, supported currencies) should be stable enough that isn't isn't likely to be a huge problem. |
825dce3
to
a9839a4
Compare
Did another big rebase for all changes in master since last attempt in April. |
@remi-stripe Amazing! Sorry again for the snail's pace here :$ Let me know when all your changes are ready. |
@brandur-stripe I need to undo the last 2 commits first and redo that work by moving all constants to the top level + renaming the types/names but not using them on parameters. Hopefully this can be done in a couple hours, but will ping you once ready. |
a9839a4
to
35258f8
Compare
@brandur-stripe Okay I think we're ~almost there. I'm not sure it's the final version yet but I would like some quick 👍 or 👎 on all the last few changes:
Also whether we want to also address one of your earlier comments in this PR too:
|
3ac12b5
to
ffbc8bd
Compare
Nice @remi-stripe! See below:
Did you change anything already? I think it'd be nice to have types where possible, but I don't think it matters that much. I'd suggest leaving the ones that exist in place, and probably just not adding anything new for now.
I'd just put it in top-level
Hm, did you get a feeling as to how much of a pain this is to fix? I still think this would be somewhat nice to have just so it's predictable (i.e., things area always pointers) when you're writing your integration code. |
Yes I did all the changes we agreed upon yesterday for all the packages. This means all params structs have This means that I undid all the changes I did last month and re-added each type (and manually added a few more that were missing) and made sure that all constants are now top-level and properly prefixed. Can you confirm this is what we expected?
That's what I did in ffbc8bd can you confirm that was correct?
I'm hopeful this is mostly a matter of reading each struct and replacing with a |
Oh man, you are a machine! Yes — this is what I was thinking.
Yep, this also looks good to me.
Okay then, yeah I think we may as well go for it given the number of other changes that we already have in here. Feel free to push back though if this will push you over the edge, haha. |
4da7292
to
e2e745f
Compare
While inspecting the logs of stripe-mock closely, I found a few examples of parameters that were passed incorrectly in the URL because the pointer address was sent instead of the value it referenced.
With some regex I found that one too. The test was skipped so it did not appear in the logs. I'm also unskipping the test since it's supported by stripe-mock.
We were incorrectly letting you use the full list of available parameters for Product creation while inline creation with a Plan has a limited subset of parameters
Card and Bank accounts used to be managed through /cards and /bank_accounts this has changed years ago to move to /sources and /external_accounts but we never fully updated the library to match this We now use the proper/latest endpoints. Listing cards/bank accounts now pass the right default parameters in the URL too to limit to those objects.
Adds a migration guide for the prospective version 32 of stripe-go which will include the changes in #544. Some of the breaking changes there are so sizable that I think we should special-case this with a particular upgrade guide to help ease user pain somewhat while they're upgrading. Here we explain some of the background context and make a list of all the included changes and put in suggestions for remediation.
0cf81bf
to
56c6c56
Compare
@brandur-stripe just rebased on the latest master. |
HERE WE GO! |
LOL! Yep. Released as 32.0.0! |
Hi Team, Can anybody help me to find the missing Let me know if you need any additional data. v13.6.0
|
@hiren-bacancy Please work with our support team for help on this instead moving forward, this is a close to 4 years old PR. To unblock you quickly the
Our support team can be contacted here https://support.stripe.com/contact for follow up questions |
* Pull default currency from user * Currency tests * base currency as module function * Using module function instead
This should be the final PR to rework most of the library to:
AmountZero
orCouponEmpty
and move all parameters to pointersWe can't list all the changes one by one as those are extensive but here are the ones likely to impact most integrations:
BusinessURL
.DynamicLast4
orSSNLast4
.Account
onBankAccount
becomingAccountNumber
to avoid confusing with its Connect counterpart which is now namedAccount
instead ofAccountID
.MonthAnchor
or constants such asMonth
are now renamed to match the corresponding parameter/value in the APIMonthlyAnchor
andMonthly
.Meta
andLive
have been renamed toMetadata
andLivemode
on all classesValues
on List objects has been renamed toData
Owner
is nowAdditionalOwner
,Transaction
is nowBalanceTransaction
with all constants and corresponding classes renamed to match thisTx
were also replaced byBalanceTransaction
in classes, properties and constantsFee
andFeeRefund
have been renamed toApplicationFee
andApplicationFeeRefund
along with all related classes, properties and constants.Sub
has been renamed toSubscription
along with all related classes, properties and constants.City
becomingAddressCity
andMonth
becomingExpMonth
.ErrorCode
such asErrorCodeCardDeclined
orErrorCodeIncorrectZip
.Object
andPreviousAttributes
and methodsGetObjectValue()
andGetPreviousValue()
.StartingAfter
,EndingBefore
andHasMore
.AddMeta()
has been renamed toAddMetadata()
,Expand()
toAddExpand()
This replaces #459 and #507