Skip to content

Commit

Permalink
Merge pull request #8 from seatsio/steve/filled_in_todos_and_missing_…
Browse files Browse the repository at this point in the history
…functionality

Final pass
  • Loading branch information
schaloner authored Jul 24, 2023
2 parents b184486 + fb8a913 commit e74ec60
Show file tree
Hide file tree
Showing 31 changed files with 1,320 additions and 478 deletions.
42 changes: 7 additions & 35 deletions events/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ type CreateChannelParams struct {
Key string `json:"key"`
Name string `json:"name"`
Color string `json:"color"`
Index int32 `json:"index"`
Objects []string `json:"objects"`
Index int32 `json:"index,omitempty"`
Objects []string `json:"objects,omitempty"`
}

type CreateChannelParamsOption func(Params *CreateChannelParams)

type UpdateChannelParams struct {
Name string `json:"name"`
Color string `json:"color"`
Objects []string `json:"objects"`
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`
Objects []string `json:"objects,omitempty"`
}

type changeChannelObjectsRequest struct {
Expand All @@ -33,10 +33,6 @@ type replaceChannelsRequest struct {
Channels []Channel `json:"channels"`
}

type channelSupportNS struct{}

var ChannelSupport channelSupportNS

func (channels *Channels) Create(eventKey string, params *CreateChannelParams) error {
result, err := channels.Client.R().
SetBody(params).
Expand All @@ -45,7 +41,7 @@ func (channels *Channels) Create(eventKey string, params *CreateChannelParams) e
return shared.AssertOkNoBody(result, err)
}

func (channels *Channels) CreateMultiple(eventKey string, params *[]CreateChannelParams) error {
func (channels *Channels) CreateMultiple(eventKey string, params ...*CreateChannelParams) error {
result, err := channels.Client.R().
SetBody(params).
SetPathParam("key", eventKey).
Expand Down Expand Up @@ -88,34 +84,10 @@ func (channels *Channels) RemoveObjects(eventKey string, channelKey string, obje
return shared.AssertOkNoBody(result, err)
}

func (channels *Channels) Replace(eventKey string, newChannels []Channel) error {
func (channels *Channels) Replace(eventKey string, newChannels ...Channel) error {
result, err := channels.Client.R().
SetBody(replaceChannelsRequest{newChannels}).
SetPathParam("eventKey", eventKey).
Post("/events/{eventKey}/channels/replace")
return shared.AssertOkNoBody(result, err)
}

func (channelSupportNS) WithIndex(index int32) CreateChannelParamsOption {
return func(params *CreateChannelParams) {
params.Index = index
}
}

func (channelSupportNS) WithObjects(objects []string) CreateChannelParamsOption {
return func(params *CreateChannelParams) {
params.Objects = objects
}
}

func NewCreateChannelParams(key string, name string, color string, opts ...CreateChannelParamsOption) *CreateChannelParams {
params := &CreateChannelParams{key, name, color, 0, []string{}}
for _, opt := range opts {
opt(params)
}
return params
}

func (channels *Channels) NewUpdateChannelParams(channel Channel) UpdateChannelParams {
return UpdateChannelParams{Name: channel.Name, Color: channel.Color, Objects: channel.Objects}
}
2 changes: 2 additions & 0 deletions events/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import "time"
type Event struct {
Id int64 `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
Date string `json:"date"`
ChartKey string `json:"chartKey"`
HoldToken string `json:"holdToken"`
TableBookingConfig TableBookingConfig `json:"tableBookingConfig"`
Expand Down
36 changes: 18 additions & 18 deletions events/event_object_info.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package events

type EventObjectInfo struct {
Status string `json:"status"`
OrderId string `json:"orderId"`
ExtraData ExtraData `json:"extraData"`
Label string `json:"label"`
Labels Labels `json:"labels"`
IDs IDs `json:"ids"`
CategoryLabel string `json:"categoryLabel"`
CategoryKey CategoryKey `json:"categoryKey"`
TicketType string `json:"ticketType"`
ForSale bool `json:"forSale"`
Section string `json:"section"`
Entrance string `json:"entrance"`
NumBooked int `json:"numBooked"`
Capacity int `json:"capacity"`
ObjectType string `json:"objectType"`
LeftNeighbour string `json:"leftNeighbour"`
RightNeighbour string `json:"rightNeighbour"`
HoldToken string `json:"holdToken"`
Status ObjectStatus `json:"status"`
OrderId string `json:"orderId"`
ExtraData ExtraData `json:"extraData"`
Label string `json:"label"`
Labels Labels `json:"labels"`
IDs IDs `json:"ids"`
CategoryLabel string `json:"categoryLabel"`
CategoryKey CategoryKey `json:"categoryKey"`
TicketType string `json:"ticketType"`
ForSale bool `json:"forSale"`
Section string `json:"section"`
Entrance string `json:"entrance"`
NumBooked int `json:"numBooked"`
Capacity int `json:"capacity"`
ObjectType string `json:"objectType"`
LeftNeighbour string `json:"leftNeighbour"`
RightNeighbour string `json:"rightNeighbour"`
HoldToken string `json:"holdToken"`
}

type IDs struct {
Expand Down
Loading

0 comments on commit e74ec60

Please sign in to comment.