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
+24
View File
@@ -0,0 +1,24 @@
package onspring
import (
"fmt"
)
// OnspringAPIError represents an error returned by the Onspring API.
// It contains the HTTP status code and the error message from the API response.
// This error type implements the error interface.
type OnspringAPIError struct {
// StatusCode is the HTTP status code returned by the API.
StatusCode int
// Message is the error message returned by the API or the HTTP status text.
Message string
}
// Error returns a formatted error string containing the status code and message.
// It implements the error interface for OnspringAPIError.
//
// Returns:
// - string: A formatted error message in the format "onspring api error: status={code} message={message}"
func (e *OnspringAPIError) Error() string {
return fmt.Sprintf("onspring api error: status=%d message=%s", e.StatusCode, e.Message)
}