Skip to content

Commit

Permalink
Adds separate struct for UpdateAccessUsersSeats
Browse files Browse the repository at this point in the history
This was done to abide by convention
  • Loading branch information
auyer committed Jan 30, 2024
1 parent cc42775 commit 6c9c526
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion access_seats.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ type UpdateAccessUserSeatParams struct {
GatewaySeat *bool `json:"gateway_seat"`
}

// UpdateAccessUsersSeatsParams represents the update payload for multiple access seats.
type UpdateAccessUsersSeatsParams []struct {
SeatUID string `json:"seat_uid,omitempty"`
AccessSeat *bool `json:"access_seat"`
GatewaySeat *bool `json:"gateway_seat"`
}

// AccessUserSeatResponse represents the response from the access user seat endpoints.
type UpdateAccessUserSeatResponse struct {
Response
Expand Down Expand Up @@ -71,7 +78,7 @@ func (api *API) UpdateAccessUserSeat(ctx context.Context, rc *ResourceContainer,
// UpdateAccessUsersSeats updates many Access User Seats.
//
// API documentation: https://developers.cloudflare.com/api/operations/zero-trust-seats-update-a-user-seat
func (api *API) UpdateAccessUsersSeats(ctx context.Context, rc *ResourceContainer, params []UpdateAccessUserSeatParams) ([]AccessUpdateAccessUserSeatResult, error) {
func (api *API) UpdateAccessUsersSeats(ctx context.Context, rc *ResourceContainer, params UpdateAccessUsersSeatsParams) ([]AccessUpdateAccessUserSeatResult, error) {
if rc.Level != AccountRouteLevel {
return []AccessUpdateAccessUserSeatResult{}, fmt.Errorf(errInvalidResourceContainerAccess, rc.Level)
}
Expand Down
4 changes: 2 additions & 2 deletions access_seats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestUpdateAccessUsersSeats_MissingUID(t *testing.T) {
setup()
defer teardown()

_, err := client.UpdateAccessUsersSeats(context.Background(), testAccountRC, []UpdateAccessUserSeatParams{{GatewaySeat: BoolPtr(false), SeatUID: "seat_id"}, {SeatUID: "", AccessSeat: BoolPtr(true)}})
_, err := client.UpdateAccessUsersSeats(context.Background(), testAccountRC, UpdateAccessUsersSeatsParams{{GatewaySeat: BoolPtr(false), SeatUID: "seat_id"}, {SeatUID: "", AccessSeat: BoolPtr(true)}})
assert.EqualError(t, err, "missing required access seat UID")
}

Expand Down Expand Up @@ -164,7 +164,7 @@ func TestUpdateAccessUsersSeats(t *testing.T) {
},
}

actual, err := client.UpdateAccessUsersSeats(context.Background(), testAccountRC, []UpdateAccessUserSeatParams{
actual, err := client.UpdateAccessUsersSeats(context.Background(), testAccountRC, UpdateAccessUsersSeatsParams{
{
SeatUID: testAccessGroupSeatUID,
AccessSeat: BoolPtr(false),
Expand Down

0 comments on commit 6c9c526

Please sign in to comment.