Skip to content
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

Add status_transitions filters to the List Orders params #683

Merged
merged 1 commit into from
Sep 5, 2018

Conversation

spastorelli-stripe
Copy link
Contributor

@spastorelli-stripe spastorelli-stripe commented Aug 31, 2018

Add status_transitions filters to the List Orders params.
Attempts to fix #682

r? @brandur-stripe
cc @stripe/api-libraries

@spastorelli-stripe spastorelli-stripe force-pushed the spastorelli-add-status-transitions-param branch from c49858e to 04dbeb9 Compare August 31, 2018 17:57
@spastorelli-stripe spastorelli-stripe changed the title [WIP] Add status_transitions filters to the List Orders params Add status_transitions filters to the List Orders params Aug 31, 2018
Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And thanks for taking this as well @spastorelli-stripe! Looks great. I left a couple minor comments below.

order.go Show resolved Hide resolved
order.go Outdated
// StatusTransitionsFilterParams are parameters that can used to filter on status_transition when listing orders.
type StatusTransitionsFilterParams struct {
StatusTransitions `form:"*"`
CanceledRange *RangeQueryParams `form:"canceled"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a field for each of Canceled, Fulfilled, Paid, and Returned which is a *int64? This is how we generally support either a range or a basic Unix timestamp like for Created. From the docs:

A filter on the list based on the object canceled field. The value can be a string with an integer Unix timestamp, or it can be a dictionary with the following options:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had implicitly provided these fields by embedding StatusTransitions in StatusTransitionsFilterParams.
Should I instead explicitly include each of the fields in StatusTransitionsFilterParams?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, can we do that please? e.g.

type StatusTransitionsFilterParams struct {
	StatusTransitions `form:"-"`
	Canceled          *int64 `form:"canceled"`
	CanceledRange     *RangeQueryParams `form:"canceled"`
	FulfilledRange    *RangeQueryParams `form:"fulfilled"`
...

It's nicely symmetrical with what we're doing with Created / CreatedRange just above.

ptal @spastorelli-stripe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Done.

order.go Outdated
Canceled int64 `json:"canceled" form:"canceled"`
Fulfilled int64 `json:"fulfiled" form:"fulfilled"`
Paid int64 `json:"paid" form:"paid"`
Returned int64 `json:"returned" form:"returned"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And let's drop the form annotations from this struct — they're not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

PaidRange: &stripe.RangeQueryParams{
GreaterThan: int64(123456),
},
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think adding the new predicate is strictly needed here because both the form annotations and RangeQueryParams serialization are pretty well tested already (see form/form_test.go and params_test.go).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Removed.

@spastorelli-stripe spastorelli-stripe force-pushed the spastorelli-add-status-transitions-param branch from 04dbeb9 to 24a8d26 Compare September 3, 2018 18:38
@spastorelli-stripe
Copy link
Contributor Author

Thanks @brandur-stripe for the review. PTAL

@spastorelli-stripe spastorelli-stripe force-pushed the spastorelli-add-status-transitions-param branch from 24a8d26 to 50a6890 Compare September 5, 2018 14:48
@spastorelli-stripe
Copy link
Contributor Author

Thanks @brandur-stripe for the follow up. PTAL

order.go Outdated
type StatusTransitionsFilterParams struct {
Canceled *int64 `form:"canceled"`
CanceledRange *RangeQueryParams `form:"canceled"`
Fulfilled *int64 `form:"fulfiled"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

One more very minor bug here: this form annotation should be "fulfilled" (with two Ls) like the one below it.

ptal @spastorelli-stripe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. Done.

@spastorelli-stripe spastorelli-stripe force-pushed the spastorelli-add-status-transitions-param branch from 50a6890 to d4cab50 Compare September 5, 2018 17:10
@spastorelli-stripe
Copy link
Contributor Author

Thanks @brandur-stripe. PTAL

@brandur-stripe
Copy link
Contributor

LGTM. Thanks!

@brandur-stripe brandur-stripe merged commit 4736668 into master Sep 5, 2018
@brandur-stripe brandur-stripe deleted the spastorelli-add-status-transitions-param branch September 5, 2018 17:13
@brandur-stripe
Copy link
Contributor

Released as 48.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support for order.List with status_transitions filters
3 participants