Skip to content

Commit

Permalink
add url to product.
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarth committed May 27, 2015
1 parent 5256c0d commit b8fed87
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion product.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type ProductParams struct {
Caption string
Desc string
Attrs []string
Images []string `json:"images"`
Images []string
URL string
Shippable *bool
}

Expand All @@ -33,6 +34,7 @@ type Product struct {
Shippable bool `json:"shippable"`
Images []string `json:"images"`
Meta map[string]string `json:"metdata"`
URL string `json:"url"`
Skus *SKUList `json:"skus"`
}

Expand Down
8 changes: 8 additions & 0 deletions product/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (c Client) New(params *stripe.ProductParams) (*stripe.Product, error) {
}
}

if len(params.URL) > 0 {
body.Add("url", params.URL)
}

if params.Shippable != nil {
body.Add("shippable", strconv.FormatBool(*(params.Shippable)))
}
Expand Down Expand Up @@ -103,6 +107,10 @@ func (c Client) Update(id string, params *stripe.ProductParams) (*stripe.Product
}
}

if len(params.URL) > 0 {
body.Add("url", params.URL)
}

params.AppendTo(body)
}

Expand Down
5 changes: 5 additions & 0 deletions product/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestProduct(t *testing.T) {
Desc: "This is a description",
Caption: "This is a caption",
Attrs: []string{"attr1", "attr2"},
URL: "http://example.com",
Shippable: &shippable,
})

Expand Down Expand Up @@ -59,6 +60,10 @@ func TestProduct(t *testing.T) {
if p.Desc != "This is a description" {
t.Errorf("Description is invalid: %v", p.Desc)
}

if p.URL != "http://example.com" {
t.Errorf("URL is invalid: %v", p.URL)
}
}

func TestProductWithCustomID(t *testing.T) {
Expand Down

0 comments on commit b8fed87

Please sign in to comment.