Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support event is in the past flag #18

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions events/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ type Event struct {
Categories []Category `json:"categories,omitempty"`
ObjectCategories map[string]CategoryKey `json:"objectCategories,omitempty"`
Channels []Channel `json:"channels,omitempty"`
IsInThePast bool `json:"isInThePast"`
}
3 changes: 2 additions & 1 deletion events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ type CreateEventParams struct {
}

type UpdateEventParams struct {
ChartKey *string `json:"chartKey,omitempty"`
ChartKey *string `json:"chartKey,omitempty"`
IsInThePast *bool `json:"isInThePast,omitempty"`
*EventParams
}

Expand Down
17 changes: 17 additions & 0 deletions events_test/update_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package events_test
import (
"github.com/seatsio/seatsio-go"
"github.com/seatsio/seatsio-go/events"
"github.com/seatsio/seatsio-go/seasons"
"github.com/seatsio/seatsio-go/shared"
"github.com/seatsio/seatsio-go/test_util"
"github.com/stretchr/testify/require"
"testing"
Expand Down Expand Up @@ -196,3 +198,18 @@ func TestUpdateEventRemoveCategories(t *testing.T) {
require.NoError(t, err)
require.NotContains(t, updatedEvent.Categories, category)
}

func TestUpdateEventIsInThePast(t *testing.T) {
t.Parallel()
company := test_util.CreateTestCompany(t)
chartKey := test_util.CreateTestChart(t, company.Admin.SecretKey)
client := seatsio.NewSeatsioClient(test_util.BaseUrl, company.Admin.SecretKey)
_, err := client.Seasons.CreateSeasonWithOptions(chartKey, &seasons.CreateSeasonParams{EventKeys: []string{"event1"}})
require.NoError(t, err)

err = client.Events.Update("event1", &events.UpdateEventParams{IsInThePast: shared.OptionalBool(true)})
require.NoError(t, err)
updatedEvent, err := client.Events.Retrieve("event1")
require.NoError(t, err)
require.True(t, updatedEvent.IsInThePast)
}
5 changes: 5 additions & 0 deletions shared/optional.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package shared

func OptionalBool(value bool) *bool {
return &value
}