Skip to content

Commit

Permalink
Merge pull request veritrans#19 from haritsfahreza/features/fix-api-s…
Browse files Browse the repository at this point in the history
…tatus-code

Set HTTP Status Code into SnapResponse
  • Loading branch information
rizdaprasetya authored Aug 7, 2018
2 parents d223d32 + f2ac4da commit 0cca7e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"log"
"net/http"
"os"
"reflect"
"strconv"
"time"
)

Expand Down Expand Up @@ -103,7 +105,10 @@ func (c *Client) ExecuteRequest(req *http.Request, v interface{}) error {
}

if v != nil {
return json.Unmarshal(resBody, v)
if err = json.Unmarshal(resBody, v); err != nil {
return err
}
reflect.ValueOf(v).Elem().FieldByName("StatusCode").SetString(strconv.Itoa(res.StatusCode))
}

return nil
Expand Down

0 comments on commit 0cca7e8

Please sign in to comment.