Skip to content

Commit

Permalink
Fixed status case for 200 vs 201
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed May 2, 2022
1 parent 43204ea commit 19b3041
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions client.go
Expand Up @@ -3,7 +3,6 @@ package tonicpow
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strconv"
"time"
Expand Down Expand Up @@ -156,7 +155,10 @@ func (c *Client) Request(httpMethod string, requestEndpoint string,
if err = json.Unmarshal(response.Body, &response.Error); err != nil {
return
}
err = fmt.Errorf("%s", response.Error.Message)
err = errors.New(response.Error.Message)
if response.StatusCode == 0 { // If a 200 is expected, but you get a 201, this case occurs (improper status code check)
response.StatusCode = http.StatusInternalServerError
}
}

return
Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Expand Up @@ -208,7 +208,7 @@ func ExampleNewClient() {
return
}
fmt.Printf("loaded client: %s", client.Options().userAgent)
// Output:loaded client: go-tonicpow: v0.7.1
// Output:loaded client: go-tonicpow: v0.7.2
}

// BenchmarkNewClient benchmarks the method NewClient()
Expand Down
2 changes: 1 addition & 1 deletion definitions.go
Expand Up @@ -10,7 +10,7 @@ const (
defaultHTTPTimeout = 10 * time.Second // Default timeout for all GET requests in seconds
defaultRetryCount int = 2 // Default retry count for HTTP requests
defaultUserAgent = "go-tonicpow: " + version // Default user agent
version string = "v0.7.1" // go-tonicpow version
version string = "v0.7.2" // go-tonicpow version

// Field key names for various model requests
fieldAdvertiserProfileID = "advertiser_profile_id"
Expand Down
4 changes: 2 additions & 2 deletions tonicpow_test.go
Expand Up @@ -42,7 +42,7 @@ func TestVersion(t *testing.T) {
// See more examples in /examples/
func ExampleVersion() {
fmt.Printf("version: %s", Version())
// Output:version: v0.7.1
// Output:version: v0.7.2
}

// TestUserAgent will test the method UserAgent()
Expand All @@ -60,7 +60,7 @@ func TestUserAgent(t *testing.T) {
// See more examples in /examples/
func ExampleUserAgent() {
fmt.Printf("user agent: %s", UserAgent())
// Output:user agent: go-tonicpow: v0.7.1
// Output:user agent: go-tonicpow: v0.7.2
}

// TestGetFeedType will test the method GetFeedType()
Expand Down

0 comments on commit 19b3041

Please sign in to comment.