service

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const BILLING_SERVICE = service.BILLING_SERVICE
View Source
const QUOTA_SERVICE = service.QUOTA_SERVICE

Variables

This section is empty.

Functions

This section is empty.

Types

type BillingService

type BillingService interface {
	core.Service
	core.Configurable

	// CreateCustomer creates a new customer
	CreateCustomer(ctx context.Context, user *models.User) error

	// CreateCustomerById creates a new customer by user id
	CreateCustomerById(ctx context.Context, userID uint) error

	// UpdateBillingInfo updates the billing info for a given user
	UpdateBillingInfo(ctx context.Context, userID uint, billingInfo *messages.BillingInfo) error

	// GetUserQuota returns the quota for a given user
	GetUserMaxStorage(userID uint) (uint64, error)

	// GetUserMaxUpload returns the max upload for a given user
	GetUserMaxUpload(userID uint) (uint64, error)

	// GetUserMaxDownload returns the max download for a given user
	GetUserMaxDownload(userID uint) (uint64, error)

	// GetPlans returns all available subscription plans
	GetPlans(ctx context.Context) ([]*messages.SubscriptionPlan, error)

	// GetSubscription returns the subscription for a given user
	GetSubscription(ctx context.Context, userID uint) (*messages.SubscriptionResponse, error)

	// ChangeSubscription changes the subscription for a given user
	ChangeSubscription(ctx context.Context, userID uint, planID string) error

	// ConnectSubscription connects a payment method to a user's subscription
	ConnectSubscription(ctx context.Context, userID uint, paymentMethodID string) error

	GenerateEphemeralKey(ctx context.Context, userID uint) (*messages.EphemeralKeyResponse, error)

	RequestPaymentMethodChange(ctx context.Context, userID uint) (*messages.RequestPaymentMethodChangeResponse, error)

	// CancelSubscription cancels a user's subscription
	CancelSubscription(ctx context.Context, userID uint) error
}

type QuotaService

type QuotaService interface {
	core.Service
	core.Configurable

	// RecordDownload records a download for a user
	RecordDownload(uploadID, userID uint, bytes uint64, ip string) error

	// RecordUpload records an upload for a user
	RecordUpload(uploadID, userID uint, bytes uint64, ip string) error

	// RecordStorage records a storage usage for a user
	RecordStorage(uploadID, userID uint, bytes int64, ip string) error

	// CheckStorageQuota checks if a user has enough storage quota for a requested number of bytes
	CheckStorageQuota(userID uint, requestedBytes uint64) (bool, error)

	// CheckUploadQuota checks if a user has enough upload quota for a requested number of bytes
	CheckUploadQuota(userID uint, requestedBytes uint64) (bool, error)

	// CheckDownloadQuota checks if a user has enough download quota for a requested number of bytes
	CheckDownloadQuota(userID uint, requestedBytes uint64) (bool, error)

	// Reconcile reconciles the quota usage for the previous day
	Reconcile() error

	// GetCurrentUsage retrieves the current usage for a user
	GetCurrentUsage(userID uint) (*messages.CurrentUsageResponse, error)

	// GetUploadUsageHistory retrieves the upload usage history for a user for the specified number of days
	GetUploadUsageHistory(userID uint, days int) ([]*messages.UsageData, error)

	// GetDownloadUsageHistory retrieves the download usage history for a user for the specified number of days
	GetDownloadUsageHistory(userID uint, days int) ([]*messages.UsageData, error)

	// GetStorageUsageHistory retrieves the storage usage history for a user for the specified number of days
	GetStorageUsageHistory(userID uint, days int) ([]*messages.UsageData, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL