feat: initialize client core and ping endpoint

establishes the foundational architecture for the Onspring Go SDK.

changes included:
- add `Client` struct and `NewClient` constructor with authentication.
- implement functional options pattern (WithHTTPClient, WithBaseURL, etc.).
- add `OnspringAPIError` type for handling non-2xx responses.
- implement internal request construction and execution logic.
- add `Ping` service for API health check verification.
- add comprehensive unit tests and mock server infrastructure.
This commit is contained in:
Stevan Freeborn
2025-12-05 21:33:23 -06:00
parent 3098779596
commit a9e49906e0
10 changed files with 568 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package onspring
import "net/http"
// Option is a functional option for configuring a Client.
type Option 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) Option {
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) Option {
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) Option {
return func(c *Client) {
c.apiVersion = version
}
}