Skip to content

Commit

Permalink
Merge pull request #967 from stripe/richardm-orderreturn-get
Browse files Browse the repository at this point in the history
Add orderreturn.Get method
  • Loading branch information
richardm-stripe authored Oct 9, 2019
2 parents bd26453 + 5e1bc00 commit 81d6819
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
6 changes: 0 additions & 6 deletions order.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ type OrderUpdateShippingParams struct {
TrackingNumber *string `form:"tracking_number"`
}

// OrderReturnParams is the set of parameters that can be used when returning orders.
type OrderReturnParams struct {
Params `form:"*"`
Items []*OrderItemParams `form:"items"`
}

// Shipping describes the shipping hash on an order.
type Shipping struct {
Address *Address `json:"address"`
Expand Down
7 changes: 7 additions & 0 deletions orderreturn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ package stripe

import "encoding/json"

// OrderReturnParams is the set of parameters that can be used when returning orders.
type OrderReturnParams struct {
Params `form:"*"`
Items []*OrderItemParams `form:"items"`
Order *string `form:"-"` // Included in the URL
}

// OrderReturn is the resource representing an order return.
// For more details see https://stripe.com/docs/api#order_returns.
type OrderReturn struct {
Expand Down
13 changes: 13 additions & 0 deletions orderreturn/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ type Client struct {
Key string
}

// Get returns the details of an order return
func Get(id string, params *stripe.OrderReturnParams) (*stripe.OrderReturn, error) {
return getC().Get(id, params)
}

// Get returns the details of an order return
func (c Client) Get(id string, params *stripe.OrderReturnParams) (*stripe.OrderReturn, error) {
path := stripe.FormatURLPath("/v1/order_returns/%s", id)
orderReturn := &stripe.OrderReturn{}
err := c.B.Call(http.MethodGet, path, c.Key, params, orderReturn)
return orderReturn, err
}

// List returns a list of order returns.
func List(params *stripe.OrderReturnListParams) *Iter {
return getC().List(params)
Expand Down
8 changes: 8 additions & 0 deletions orderreturn/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import (
_ "github.com/stripe/stripe-go/testing"
)

func TestOrderReturnGet(t *testing.T) {
orret, err := Get("orret_123", &stripe.OrderReturnParams{})

// Verify that we can get an order return
assert.Nil(t, err)
assert.NotNil(t, orret)
}

func TestOrderReturnList(t *testing.T) {
i := List(&stripe.OrderReturnListParams{})

Expand Down

0 comments on commit 81d6819

Please sign in to comment.