Documentation
¶
Index ¶
- Variables
- type KobbleWebhooks
- type WebhookEvent
- type WebhookPingData
- type WebhookPingEvent
- type WebhookQuotaReachedData
- type WebhookQuotaReachedEvent
- type WebhookSubscription
- type WebhookSubscriptionCreatedEvent
- type WebhookSubscriptionData
- type WebhookSubscriptionDeletedEvent
- type WebhookSubscriptionUpdatedEvent
- type WebhookUserCreatedData
- type WebhookUserCreatedEvent
Constants ¶
This section is empty.
Variables ¶
View Source
var WebhookSubscriptions = []string{
"user.created",
"quota.reached",
"subscription.created",
"subscription.updated",
"subscription.deleted",
"ping",
}
Functions ¶
This section is empty.
Types ¶
type KobbleWebhooks ¶
type KobbleWebhooks struct{}
KobbleWebhooks is a struct that provides methods to work with webhooks.
func NewKobbleWebhooks ¶
func NewKobbleWebhooks() *KobbleWebhooks
NewKobbleWebhooks creates a new instance of the KobbleWebhooks struct.
func (*KobbleWebhooks) ConstructEvent ¶ added in v1.0.4
func (k *KobbleWebhooks) ConstructEvent(body any, signature string, secret string) (WebhookEvent, error)
ConstructEvent construct a webhook event payload and verify its integrity. The `body` parameter is eventually serialized to a `Buffer` object in order to compute the signature. A `Buffer` can therefore be passed directly, but other types are accepted as well:
- A Go struct is serialized using `json.Marshal`.
- For any other type, native string conversion is attempted. The result is assumed to be UTF-8 encoded.
The expected `signature` is the one sent in the webhook header `Kobble-Signature`. The `secret` is the one associated with the webhook expected to receive the event. The fully typesafe payload is returned if the signature is valid.
type WebhookEvent ¶
type WebhookPingData ¶
type WebhookPingData struct {
WebhookID string `json:"webhook_id"`
}
type WebhookPingEvent ¶
type WebhookPingEvent struct { Type string `json:"type"` Data WebhookPingData `json:"data"` }
type WebhookQuotaReachedData ¶
type WebhookQuotaReachedEvent ¶
type WebhookQuotaReachedEvent struct { Type string `json:"type"` Data WebhookQuotaReachedData `json:"data"` }
type WebhookSubscription ¶
type WebhookSubscription string
type WebhookSubscriptionCreatedEvent ¶
type WebhookSubscriptionCreatedEvent struct { Type string `json:"type"` Data WebhookSubscriptionData `json:"data"` }
type WebhookSubscriptionData ¶
type WebhookSubscriptionData struct { Provider struct { SubscriptionID string `json:"subscription_id"` ProductID string `json:"product_id"` PriceID string `json:"price_id"` } `json:"provider"` ProjectID string `json:"project_id"` ProductID string `json:"product_id"` PriceID string `json:"price_id"` UserID string `json:"user_id"` Email string `json:"email"` StartDate *string `json:"start_date,omitempty"` EndedAt *string `json:"ended_at,omitempty"` CancelAt *string `json:"cancel_at,omitempty"` CanceledAt *string `json:"canceled_at,omitempty"` CancelAtPeriodEnd bool `json:"cancel_at_period_end"` Status string `json:"status"` TrialEnd *string `json:"trial_end,omitempty"` TrialStart *string `json:"trial_start,omitempty"` }
type WebhookSubscriptionDeletedEvent ¶
type WebhookSubscriptionDeletedEvent struct { Type string `json:"type"` Data WebhookSubscriptionData `json:"data"` }
type WebhookSubscriptionUpdatedEvent ¶
type WebhookSubscriptionUpdatedEvent struct { Type string `json:"type"` Data WebhookSubscriptionData `json:"data"` }
type WebhookUserCreatedData ¶
type WebhookUserCreatedEvent ¶
type WebhookUserCreatedEvent struct { Type string `json:"type"` Data WebhookUserCreatedData `json:"data"` }
Click to show internal directories.
Click to hide internal directories.