Skip to content

Commit

Permalink
Added cost field per #56 and updated beta payloads to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
lleadbet committed Apr 7, 2021
1 parent 9884d28 commit 6f44814
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Method: "webhook",
Callback: "null",
},
Cost: 1,
CreatedAt: util.GetTimestamp().Format(time.RFC3339Nano),
},
Event: models.AuthorizationRevokeEvent{
Expand Down
1 change: 1 addition & 0 deletions internal/events/types/ban/ban.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Method: "webhook",
Callback: "null",
},
Cost: 0,
CreatedAt: util.GetTimestamp().Format(time.RFC3339Nano),
},
Event: models.BanEventSubEvent{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Method: "webhook",
Callback: "null",
},
Cost: 0,
CreatedAt: tNow,
},
Event: models.RedemptionEventSubEvent{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Method: "webhook",
Callback: "null",
},
Cost: 0,
CreatedAt: tNow,
},
Event: models.RewardEventSubEvent{
Expand Down
1 change: 1 addition & 0 deletions internal/events/types/cheer/cheer_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Method: "webhook",
Callback: "null",
},
Cost: 0,
CreatedAt: util.GetTimestamp().Format(time.RFC3339Nano),
},
Event: models.CheerEventSubEvent{
Expand Down
1 change: 1 addition & 0 deletions internal/events/types/follow/follow_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (e Event) GenerateEvent(p events.MockEventParameters) (events.MockEventResp
Method: "webhook",
Callback: "null",
},
Cost: 0,
CreatedAt: util.GetTimestamp().Format(time.RFC3339Nano),
},
Event: models.FollowEventSubEvent{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
ID: params.ID,
Status: "enabled",
Type: triggerMapping[params.Transport][params.Trigger],
Version: "beta",
Version: "1",
Condition: models.EventsubCondition{
BroadcasterUserID: params.ToUserID,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/events/types/raid/raid.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
ID: params.ID,
Status: "enabled",
Type: triggerMapping[params.Transport][params.Trigger],
Version: "beta",
Version: "1",
Condition: models.EventsubCondition{
ToBroadcasterUserID: params.ToUserID,
},
Expand Down
1 change: 1 addition & 0 deletions internal/events/types/stream_change/stream_change_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Method: "webhook",
Callback: "null",
},
Cost: 0,
CreatedAt: util.GetTimestamp().Format(time.RFC3339Nano),
},
Event: models.ChannelUpdateEventSubEvent{
Expand Down
4 changes: 2 additions & 2 deletions internal/events/types/streamdown/streamdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Method: "webhook",
Callback: "null",
},
Cost: 0,
CreatedAt: util.GetTimestamp().Format(time.RFC3339Nano),
},
Event: models.StreamDownEventSubEvent{
Expand All @@ -62,8 +63,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
}
case models.TransportWebSub:
body := *&models.StreamDownWebSubResponse{
Data: []models.StreamDownWebSubResponseData{
}}
Data: []models.StreamDownWebSubResponseData{}}

event, err = json.Marshal(body)
if err != nil {
Expand Down
27 changes: 14 additions & 13 deletions internal/events/types/streamup/streamup.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Method: "webhook",
Callback: "null",
},
Cost: 0,
CreatedAt: util.GetTimestamp().Format(time.RFC3339Nano),
},
Event: models.StreamUpEventSubEvent{
Expand All @@ -71,20 +72,20 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
body := models.StreamUpWebSubResponse{
Data: []models.StreamUpWebSubResponseData{
{
ID: params.ID,
UserID: params.ToUserID,
UserLogin: params.ToUserName,
UserName: params.ToUserName,
GameID: "509658",
Type: "live",
Title: params.StreamTitle,
ViewerCount: 1337,
StartedAt: util.GetTimestamp().Format(time.RFC3339),
Language: "en",
ThumbnailURL: "https://static-cdn.jtvnw.net/ttv-static/404_preview-440x248.jpg",
TagIDs: make([]string, 0),
ID: params.ID,
UserID: params.ToUserID,
UserLogin: params.ToUserName,
UserName: params.ToUserName,
GameID: "509658",
Type: "live",
Title: params.StreamTitle,
ViewerCount: 1337,
StartedAt: util.GetTimestamp().Format(time.RFC3339),
Language: "en",
ThumbnailURL: "https://static-cdn.jtvnw.net/ttv-static/404_preview-440x248.jpg",
TagIDs: make([]string, 0),
},
},
},
}

event, err = json.Marshal(body)
Expand Down
1 change: 1 addition & 0 deletions internal/events/types/subscribe/sub_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Method: "webhook",
Callback: "null",
},
Cost: 0,
CreatedAt: util.GetTimestamp().Format(time.RFC3339Nano),
},
Event: models.SubEventSubEvent{
Expand Down
1 change: 1 addition & 0 deletions internal/models/eventsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type EventsubSubscription struct {
Condition EventsubCondition `json:"condition"`
Transport EventsubTransport `json:"transport"`
CreatedAt string `json:"created_at"`
Cost int64 `json:"cost"`
}

type EventsubTransport struct {
Expand Down

0 comments on commit 6f44814

Please sign in to comment.