Skip to content

Commit ca63554

Browse files
authored
Allow custom Formal API versions (#59)
Use Formal API version 2025-02-24 by default
1 parent 9b8370c commit ca63554

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.7.2
1+
2.8.0

sdk/client.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ import "net/http"
55
type transport struct {
66
underlyingTransport http.RoundTripper
77
apiKey string
8+
apiVersion string
89
}
910

1011
func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
1112
req.Header.Add("X-Api-Key", t.apiKey)
13+
req.Header.Add("X-Formal-API-Version", "2025-02-24")
1214
return t.underlyingTransport.RoundTrip(req)
1315
}
1416

15-
func NewClient(apiKey string) *http.Client {
17+
func NewClient(apiKey, apiVersion string) *http.Client {
1618
return &http.Client{
1719
Transport: &transport{
1820
apiKey: apiKey,
21+
apiVersion: apiVersion,
1922
underlyingTransport: http.DefaultTransport,
2023
},
2124
}

sdk/sdk.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ func New(apiKey string) *FormalSDK {
3636
}
3737

3838
// NewWithUrl creates a new FormalSDK instance with a custom URL
39-
func NewWithUrl(apiKey string, url string) *FormalSDK {
40-
httpClient := NewClient(apiKey)
39+
func NewWithUrl(apiKey, url string) *FormalSDK {
40+
return NewWithParams(apiKey, "2025-02-24", url)
41+
}
42+
43+
// NewWithParams creates a new FormalSDK instance with all custom params
44+
func NewWithParams(apiKey, apiVersion, url string) *FormalSDK {
45+
httpClient := NewClient(apiKey, apiVersion)
4146

4247
return &FormalSDK{
4348
ConnectorServiceClient: corev1connect.NewConnectorServiceClient(httpClient, url),

0 commit comments

Comments
 (0)