Skip to content
Open
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
19 changes: 19 additions & 0 deletions mocks/integration_create_payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "integration.create",
"data": {
"connection_id": "112402021105124",
"webhook_secret": "whs_abcd",
"project": {
"id": "1230954036934033243",
"platform": "discord",
"platform_id": "3949456393249234923",
"type": "bot"
},
"user": {
"id": "3949456393249234923",
"platform_id": "3949456393249234923",
"name": "username",
"avatar_url": "<avatar url>"
}
}
}
6 changes: 6 additions & 0 deletions mocks/integration_delete_payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "integration.delete",
"data": {
"connection_id": "112402021105124"
}
}
21 changes: 21 additions & 0 deletions mocks/vote_create_payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "vote.create",
"data": {
"id": "808499215864008704",
"weight": 1,
"created_at": "2026-02-09T00:47:14.2510149+00:00",
"expires_at": "2026-02-09T12:47:14.2510149+00:00",
"project": {
"id": "803190510032756736",
"type": "bot",
"platform": "discord",
"platform_id": "160105994217586689"
},
"user": {
"id": "160105994217586689",
"platform_id": "160105994217586689",
"name": "username",
"avatar_url": "<avatar url>"
}
}
}
17 changes: 17 additions & 0 deletions mocks/webhook_test_payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"type": "webhook.test",
"data": {
"user": {
"id": "160105994217586689",
"platform_id": "160105994217586689",
"name": "username",
"avatar_url": "<avatar url>"
},
"project": {
"id": "803190510032756736",
"type": "bot",
"platform": "discord",
"platform_id": "160105994217586689"
}
}
}
37 changes: 37 additions & 0 deletions payload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package topgg

import "time"

// IntegrationCreatePayload represents an 'integration.create' webhook.payload. Fires when a user has connected to your webhook integration.
type IntegrationCreatePayload struct {
ConnectionId string `json:"connection_id"` // The unique identifier for this connection.
Secret string `json:"webhook_secret"` // The secret used to verify future webhook deliveries.
Project PartialProject `json:"project"` // The project that the integration refers to.
User User `json:"user"` // The user who triggered this event.
}

// IntegrationDeletePayload represents an 'integration.delete' webhook.payload. Fires when a user has disconnected from your webhook integration.
type IntegrationDeletePayload struct {
ConnectionId string `json:"connection_id"` // The unique identifier for this connection.
}

// TestPayload represents a 'webhook.test' webhook.payload. Fires upon sent test from the project dashboard.
type TestPayload struct {
Project PartialProject `json:"project"` // The project that the test refers to.
User User `json:"user"` // The user who triggered this test.
}

// VoteCreatePayload represents a 'vote.create' webhook.payload. Fires when a user votes for your project.
type VoteCreatePayload struct {
Id string `json:"id"` // The vote's ID.
Weight int `json:"weight"` // The number of votes this vote counted for. This is a rounded integer value which determines how many points this individual vote was worth.
VotedAt time.Time `json:"created_at"` // When the vote was cast.
ExpiresAt time.Time `json:"expires_at"` // When the vote expires and the user is required to vote again.
Project PartialProject `json:"project"` // The project that received this vote.
User User `json:"user"` // The user who voted for this project.
}

// Payload represents all possible webhook payloads.
type Payload interface {
IntegrationCreatePayload | IntegrationDeletePayload | TestPayload | VoteCreatePayload
}
110 changes: 0 additions & 110 deletions webhook.go

This file was deleted.

50 changes: 0 additions & 50 deletions webhook_test.go

This file was deleted.

Loading