Skip to content

Commit

Permalink
refactor: move base url to const
Browse files Browse the repository at this point in the history
  • Loading branch information
scanpatch committed Jul 13, 2021
1 parent bb44e02 commit 89dff70
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/spyse.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
authorizationType = "Bearer"
contentTypeHeaderName = "Content-Type"
defaultContentType = "application/json"
defaultBaseURL = "https://api.spyse.com/v4/data/"
)

// HTTPClient defines an interface for an http.Client implementation so that alternative
Expand Down Expand Up @@ -41,15 +42,16 @@ func NewClient(accessToken string, httpClient HTTPClient) (*Client, error) {
httpClient = http.DefaultClient
}

parsedBaseURL, err := url.Parse("https://api.spyse.com/v4/data/")
if err != nil {
return nil, err
}
return &Client{
c := &Client{
client: httpClient,
baseURL: parsedBaseURL,
accessToken: accessToken,
}, nil
}

if err := c.SetBaseURL(defaultBaseURL); err != nil {
return nil, err
}

return c, nil
}

func newRequestWithContext(ctx context.Context, method, url string, body io.Reader) (*http.Request, error) {
Expand Down

0 comments on commit 89dff70

Please sign in to comment.