Repository: VictorAvelar/mollie-api-go (go)

Issue:
Change Status property type of ErrorResponse struct
**Describe the bug**
The Status property of ErrorResponse struct have the wrong type. It should be an integer not a string, resulting in ErrorResponse object not being formed correctly.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to orders_test.go
2. Make a breakpoint at https://github.com/VictorAvelar/mollie-api-go/blob/6b85db55a644c3dcb763a39e6858fb50a798ed92/mollie/orders_test.go#L338
3. Run "debug test"
4. Type "errResp" on Debug Console, press Enter

**Expected behavior**
The Status property of ErrorResponse struct should have a value of 422

**Screenshots**
![image](https://user-images.githubusercontent.com/26384044/68181181-0641dd80-ffc9-11e9-92bd-af7830d6403b.png)
The Status should have a value of 422, as in the testdata package:
![image](https://user-images.githubusercontent.com/26384044/68181261-443f0180-ffc9-11e9-8794-4525be3c9f9a.png)


**Desktop:**
 - OS: Windows 8.1
 - Go version go1.12.6 windows/amd64


Pull request:
Issue/fix 43 wrong type
<!--- Provide a general summary of your changes in the Title above -->

## Description

Fix wrong type of Status (string) in ErrorResponse struct. Replace it with StatusCode (int). Included are other fixes that I found while I'm testing the orders_test.go as a side effect of my previous PR #41. This is why I'm not squashing my commits. Now, for the tests of TestOrdersService_CancelOrderLines, TestOrdersService_CreatePaymentFailed, and TestOrdersService_CreateOrderRefundFailed, for those to be failed the ErrorResponse should nil and the error should not nil.

## Motivation and context

Fixes #43 

## How has this been tested?
Tested using the built-in Golang test tools.
Golang version go1.12.6 windows/amd64.
Following the steps to reproduce, produces the expected results.

## Screenshots (if appropriate)
![image](https://user-images.githubusercontent.com/26384044/68463502-5f1bab00-0241-11ea-97ef-91ed5e63d3ab.png)


## Types of changes

What types of changes does your code introduce? Put an `x` in all the boxes that apply:
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:

Go over all the following points, and put an `x` in all the boxes that apply.

Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our continuous integration server to make sure your [tests and code style pass](https://help.github.com/articles/about-required-status-checks/).

- [x] I have read the **[CONTRIBUTING](CONTRIBUTING.md)** document.
- [x] My pull request addresses exactly one patch/feature.
- [x] I have created a branch for this patch/feature.
- [x] Each individual commit in the pull request is meaningful.
- [x] I have added tests to cover my changes.
- [x] If my change requires a change to the documentation, I have updated it accordingly.

If you're unsure about any of these, don't hesitate to ask. We're here to help!


Patch:
diff --git a/docs/README.md b/docs/README.md
index 5c9df73..caf2cbb 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -439,12 +439,12 @@ Error functions implement the Error interface on the zuora.Error struct.
 
 ```go
 type ErrorResponse struct {
-	Status string      `json:"status,omitempty"`
-	Title  string      `json:"title,omitempty"`
-	Detail string      `json:"detail,omitempty"`
-	Field  string      `json:"field,omitempty"`
-	Extra  interface{} `json:"extra,omitempty"`
-	Links  struct {
+	StatusCode int         `json:"status,omitempty"`
+	Title      string      `json:"title,omitempty"`
+	Detail     string      `json:"detail,omitempty"`
+	Field      string      `json:"field,omitempty"`
+	Extra      interface{} `json:"extra,omitempty"`
+	Links      struct {
 		Documentation URL `json:"documentation,omitempty"`
 	} `json:"_links,omitempty"`
 }
diff --git a/mollie/common_types.go b/mollie/common_types.go
index 6a52874..0e57b12 100644
--- a/mollie/common_types.go
+++ b/mollie/common_types.go
@@ -145,12 +145,12 @@ const (
 
 // ErrorResponse describes the cancel endpoint response if there is an error
 type ErrorResponse struct {
-	Status string      `json:"status,omitempty"`
-	Title  string      `json:"title,omitempty"`
-	Detail string      `json:"detail,omitempty"`
-	Field  string      `json:"field,omitempty"`
-	Extra  interface{} `json:"extra,omitempty"`
-	Links  struct {
+	StatusCode int         `json:"status,omitempty"`
+	Title      string      `json:"title,omitempty"`
+	Detail     string      `json:"detail,omitempty"`
+	Field      string      `json:"field,omitempty"`
+	Extra      interface{} `json:"extra,omitempty"`
+	Links      struct {
 		Documentation URL `json:"documentation,omitempty"`
 	} `json:"_links,omitempty"`
 }


Test patch:
diff --git a/mollie/orders_test.go b/mollie/orders_test.go
index 279fe54..eecbb9a 100644
--- a/mollie/orders_test.go
+++ b/mollie/orders_test.go
@@ -217,6 +217,7 @@ func TestOrdersService_CancelOrderLines(t *testing.T) {
 	defer teardown()
 
 	orderID := "ord_8wmqcHMN4U"
+	isError := false
 
 	_ = tClient.WithAuthenticationValue("test_token")
 	tMux.HandleFunc("/v2/orders/"+orderID+"/lines", func(w http.ResponseWriter, r *http.Request) {
@@ -240,6 +241,8 @@ func TestOrdersService_CancelOrderLines(t *testing.T) {
 				w.WriteHeader(http.StatusUnprocessableEntity)
 				_, _ = w.Write([]byte(testdata.CancelOrderLinesResponseCancelReject))
 
+				isError = true
+
 				break
 			}
 
@@ -247,11 +250,16 @@ func TestOrdersService_CancelOrderLines(t *testing.T) {
 				w.WriteHeader(http.StatusUnprocessableEntity)
 				_, _ = w.Write([]byte(testdata.CancelOrderLinesResponseAmountRequired))
 
+				isError = true
+
 				break
 			}
 		}
 
-		w.WriteHeader(http.StatusNoContent)
+		if !isError {
+			w.WriteHeader(http.StatusNoContent)
+		}
+
 	})
 
 	var ordLines Orders
@@ -260,7 +268,7 @@ func TestOrdersService_CancelOrderLines(t *testing.T) {
 	}
 
 	res, err := tClient.Orders.CancelOrderLine(orderID, &ordLines)
-	if err == nil {
+	if res == nil || err != nil {
 		t.Fail()
 	}
 	t.Log(res)
@@ -270,7 +278,7 @@ func TestOrdersService_CancelOrderLines(t *testing.T) {
 	}
 
 	res, err = tClient.Orders.CancelOrderLine(orderID, &ordLines)
-	if err == nil {
+	if res == nil || err != nil {
 		t.Fail()
 	}
 	t.Log(res)
@@ -335,7 +343,7 @@ func TestOrdersService_CreatePaymentFailed(t *testing.T) {
 	}
 
 	_, errResp, err := tClient.Orders.CreateOrderPayment(orderID, &ordPay)
-	if err == nil {
+	if errResp == nil || err != nil {
 		t.Fail()
 	}
 
@@ -401,7 +409,7 @@ func TestOrdersService_CreateOrderRefundFailed(t *testing.T) {
 	}
 
 	_, errResp, err := tClient.Orders.CreateOrderRefund(orderID, &order)
-	if err == nil {
+	if errResp == nil || err != nil {
 		t.Fail()
 	}