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

Fix UpdateOrderParams for allow updating dollar amount values to zero #14

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions UpdateOrder.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ type UpdateOrderParams struct {
ToState string `json:"to_state,omitempty"`
ToCity string `json:"to_city,omitempty"`
ToStreet string `json:"to_street,omitempty"`
Amount float64 `json:"amount,omitempty"`
Shipping float64 `json:"shipping,omitempty"`
SalesTax float64 `json:"sales_tax,omitempty"`
Amount *float64 `json:"amount,omitempty"`
Shipping *float64 `json:"shipping,omitempty"`
SalesTax *float64 `json:"sales_tax,omitempty"`
CustomerID string `json:"customer_id,omitempty"`
ExemptionType string `json:"exemption_type,omitempty"`
LineItems []OrderLineItem `json:"line_items,omitempty"`
Expand Down Expand Up @@ -54,3 +54,17 @@ func (client *Config) UpdateOrder(params UpdateOrderParams) (*UpdateOrderRespons

return order, nil
}

// Float64 returns a pointer to the float64 value passed in.
func Float64(v float64) *float64 {
return &v
}

// Float64Value returns the value of the float64 pointer passed in or
// 0 if the pointer is nil.
func Float64Value(v *float64) float64 {
if v != nil {
return *v
}
return 0
}
6 changes: 3 additions & 3 deletions doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ func ExampleConfig_ListOrders() {
func ExampleConfig_UpdateOrder() {
res, err := client.UpdateOrder(taxjar.UpdateOrderParams{
TransactionID: "13579-246810",
Amount: 152.72,
Shipping: 10,
SalesTax: 10.74,
Amount: taxjar.Float64(152.72),
Shipping: taxjar.Float64(10),
SalesTax: taxjar.Float64(10.74),
LineItems: []taxjar.OrderLineItem{
{
ID: "1",
Expand Down
6 changes: 3 additions & 3 deletions example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ func main() {

res5, err := client.UpdateOrder(taxjar.UpdateOrderParams{
TransactionID: "13579-246810",
Amount: 152.72,
Shipping: 10,
SalesTax: 10.74,
Amount: taxjar.Float64(152.72),
Shipping: taxjar.Float64(10),
SalesTax: taxjar.Float64(10.74),
LineItems: []taxjar.OrderLineItem{
{
ID: "1",
Expand Down
6 changes: 3 additions & 3 deletions test/LiveToken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ var _ = Describe("using a live/sandbox token", func() {
It("updates an order", func() {
res, err := client.UpdateOrder(taxjar.UpdateOrderParams{
TransactionID: "24",
Amount: 161,
Shipping: 5,
SalesTax: 10.3,
Amount: taxjar.Float64(161),
Shipping: taxjar.Float64(5),
SalesTax: taxjar.Float64(10.3),
LineItems: []taxjar.OrderLineItem{
{
ID: "1",
Expand Down
4 changes: 2 additions & 2 deletions test/Methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ var _ = Describe("Method:", func() {
res, err := client.UpdateOrder(taxjar.UpdateOrderParams{

TransactionID: "24",
Amount: 161,
SalesTax: 10.3,
Amount: taxjar.Float64(161),
SalesTax: taxjar.Float64(10.3),
LineItems: []taxjar.OrderLineItem{
{
ID: "1",
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package taxjar

const version = "1.1.1"
const version = "1.1.2"