Skip to content

Commit

Permalink
Add objecttype batchUpdate method (#45)
Browse files Browse the repository at this point in the history
* Add objecttype batchUpdate method

* Update client version
  • Loading branch information
akajla09 authored Oct 11, 2023
1 parent bc73d61 commit 0d88380
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

const (
ClientVersion string = "5.2.0"
ClientVersion string = "5.3.0"
)

type ApiClient struct {
Expand Down
21 changes: 21 additions & 0 deletions objecttype/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ func Update(objectTypeId string, params *warrant.ObjectTypeParams) (*warrant.Obj
return getClient().Update(objectTypeId, params)
}

func (c Client) BatchUpdate(params []warrant.ObjectTypeParams) ([]warrant.ObjectType, error) {
resp, err := c.apiClient.MakeRequest("PUT", "/v1/object-types", params, &warrant.RequestOptions{})
if err != nil {
return nil, err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, warrant.WrapError("Error reading response", err)
}
var updatedObjectTypes []warrant.ObjectType
err = json.Unmarshal([]byte(body), &updatedObjectTypes)
if err != nil {
return nil, warrant.WrapError("Invalid response from server", err)
}
return updatedObjectTypes, nil
}

func BatchUpdate(params []warrant.ObjectTypeParams) ([]warrant.ObjectType, error) {
return getClient().BatchUpdate(params)
}

func (c Client) Delete(objectTypeId string) error {
_, err := c.apiClient.MakeRequest("DELETE", fmt.Sprintf("/v1/object-types/%s", objectTypeId), nil, &warrant.RequestOptions{})
if err != nil {
Expand Down

0 comments on commit 0d88380

Please sign in to comment.