Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service interface {
// API Key Management
// GenerateAPIKey creates a new API key for a developer.
// It returns the created APIKey model and the raw, unhashed key.
// The raw key should only be shown once to the developer.
GenerateAPIKey(ctx context.Context, developerID string, name string) (*model.APIKey, string, error)
// GetAPIKeys retrieves all active API keys for a specific developer.
GetAPIKeys(ctx context.Context, developerID string) ([]model.APIKey, error)
// RevokeAPIKey deactivates an API key, making it unusable for authentication.
RevokeAPIKey(ctx context.Context, developerID, keyID string) error
// ValidateAPIKey validates a raw API key against stored hashed keys.
// It returns the APIKey model if valid and active, otherwise an error.
// This method is typically used by authentication middleware.
ValidateAPIKey(ctx context.Context, rawKey string) (*model.APIKey, error)
// Webhook Subscription Management
// CreateWebhookSubscription creates a new webhook endpoint for a developer.
CreateWebhookSubscription(ctx context.Context, developerID string, url string, events []string, secret string) (*model.WebhookSubscription, error)
// GetWebhookSubscriptions retrieves all webhook subscriptions for a specific developer.
GetWebhookSubscriptions(ctx context.Context, developerID string) ([]model.WebhookSubscription, error)
// UpdateWebhookSubscription modifies an existing webhook subscription.
// Pointers are used for optional fields that may or may not be updated.
UpdateWebhookSubscription(ctx context.Context, developerID, subscriptionID string, url *string, events *[]string, secret *string, isActive *bool) (*model.WebhookSubscription, error)
// DeleteWebhookSubscription removes a webhook subscription.
DeleteWebhookSubscription(ctx context.Context, developerID, subscriptionID string) error
}
Service defines the interface for developer-related operations, specifically managing webhook subscriptions and API keys.
func NewService ¶
func NewService(repo repository.DeveloperRepository, log *logger.Logger, hasher security.APIKeyHasher) Service
NewService creates a new developer service with the given repository, logger, and API key hasher.