Skip to content

Commit 03ce37a

Browse files
authored
Merge pull request #42 from Nelwhix/Nelwhix-main-5
feat: deprecating api-version query param in api calls
2 parents 7a23a1a + 9eb3776 commit 03ce37a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

api/api.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ func (c *Client) DoCustomRequest(ctx context.Context, method, path, version stri
3333

3434
// DoCustomRequestAndReturnRawResponse Executes a Custom Request and returns a APIResponse and the Raw HTTP Response
3535
func (c *Client) DoCustomRequestAndReturnRawResponse(ctx context.Context, method, path, version string, body interface{}, opts interface{}) (*http.Response, *APIResponse, error) {
36+
// version is no longer used and is ignored.
37+
return c.DoCustomRequestAndReturnRawResponseV5(ctx, method, path, body, opts)
38+
}
39+
40+
func (c *Client) DoCustomRequestAndReturnRawResponseV5(ctx context.Context, method, path string, body interface{}, opts interface{}) (*http.Response, *APIResponse, error) {
3641
firstTime := true
3742
start:
38-
u, err := generateURL(*c.baseURL, path, version, opts)
43+
u, err := generateURL(*c.baseURL, path, opts)
3944
if err != nil {
4045
return nil, nil, fmt.Errorf("Generating Path: %w", err)
4146
}

api/client.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,14 @@ func (c *Client) log(msg string, args ...interface{}) {
169169
fmt.Printf("[go-passbolt] "+msg+"\n", args...)
170170
}
171171

172-
func generateURL(base url.URL, p, version string, opt interface{}) (string, error) {
172+
func generateURL(base url.URL, p string, opt interface{}) (string, error) {
173173
base.Path = path.Join(base.Path, p)
174-
175174
vs, err := query.Values(opt)
176175
if err != nil {
177176
return "", fmt.Errorf("Getting URL Query Values: %w", err)
178177
}
179-
if version != "" {
180-
vs.Add("api-version", version)
181-
}
182178
base.RawQuery = vs.Encode()
179+
183180
return base.String(), nil
184181
}
185182

0 commit comments

Comments
 (0)