Skip to content

Commit

Permalink
Add status_transitions filters to the List Orders params
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorelli-stripe committed Aug 31, 2018
1 parent 6ed5f05 commit 04dbeb9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
30 changes: 20 additions & 10 deletions order.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,30 @@ type OrderList struct {

// OrderListParams is the set of parameters that can be used when listing orders.
type OrderListParams struct {
ListParams `form:"*"`
Created *int64 `form:"created"`
CreatedRange *RangeQueryParams `form:"created"`
Customer *string `form:"customer"`
IDs []*string `form:"ids"`
Status *string `form:"status"`
ListParams `form:"*"`
Created *int64 `form:"created"`
CreatedRange *RangeQueryParams `form:"created"`
Customer *string `form:"customer"`
IDs []*string `form:"ids"`
Status *string `form:"status"`
StatusTransitions *StatusTransitionsFilterParams `form:"status_transitions"`
}

// StatusTransitionsFilterParams are parameters that can used to filter on status_transition when listing orders.
type StatusTransitionsFilterParams struct {
StatusTransitions `form:"*"`
CanceledRange *RangeQueryParams `form:"canceled"`
FulfilledRange *RangeQueryParams `form:"fulfilled"`
PaidRange *RangeQueryParams `form:"paid"`
ReturnedRange *RangeQueryParams `form:"returned"`
}

// StatusTransitions are the timestamps at which the order status was updated.
type StatusTransitions struct {
Canceled int64 `json:"canceled"`
Fulfilled int64 `json:"fulfiled"`
Paid int64 `json:"paid"`
Returned int64 `json:"returned"`
Canceled int64 `json:"canceled" form:"canceled"`
Fulfilled int64 `json:"fulfiled" form:"fulfilled"`
Paid int64 `json:"paid" form:"paid"`
Returned int64 `json:"returned" form:"returned"`
}

// OrderPayParams is the set of parameters that can be used when paying orders.
Expand Down
8 changes: 7 additions & 1 deletion order/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ func TestOrderGet(t *testing.T) {
}

func TestOrderList(t *testing.T) {
i := List(&stripe.OrderListParams{})
i := List(&stripe.OrderListParams{
StatusTransitions: &stripe.StatusTransitionsFilterParams{
PaidRange: &stripe.RangeQueryParams{
GreaterThan: int64(123456),
},
},
})

// Verify that we can get at least one order
assert.True(t, i.Next())
Expand Down

0 comments on commit 04dbeb9

Please sign in to comment.