feat: add Apps endpoint and query parameter support
- add `Apps` endpoint to the `Client` struct and initialize it in `NewClient` - implement `doWithJsonResponse` helper to handle request execution and JSON decoding in one step - update `newRequest` to support passing and encoding query parameters via `net/url` - rename `Option` to `ClientOption` for better clarity in the `NewClient` signature - refactor `Ping` tests to use a more structured nested layout - remove `option.go` and `option_test.go` as part of the configuration refactor
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package onspring
|
||||
|
||||
import "net/http"
|
||||
|
||||
// ClientOption is a functional option for configuring a Client.
|
||||
type ClientOption func(*Client)
|
||||
|
||||
// WithHTTPClient sets a custom HTTP client for the Onspring client.
|
||||
// If not provided, the client will use http.DefaultClient.
|
||||
func WithHTTPClient(client *http.Client) ClientOption {
|
||||
return func(c *Client) {
|
||||
c.httpClient = client
|
||||
}
|
||||
}
|
||||
|
||||
// WithBaseURL sets a custom base URL for the Onspring API.
|
||||
// This is useful for testing or when using a different Onspring environment.
|
||||
func WithBaseURL(url string) ClientOption {
|
||||
return func(c *Client) {
|
||||
c.baseURL = url
|
||||
}
|
||||
}
|
||||
|
||||
// WithAPIVersion sets a custom API version for the Onspring client.
|
||||
// If not provided, the client will use the default API version.
|
||||
func WithAPIVersion(version string) ClientOption {
|
||||
return func(c *Client) {
|
||||
c.apiVersion = version
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user