service

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const BILLING_SERVICE = "billing"
View Source
const QUOTA_SERVICE = "quota"

Variables

This section is empty.

Functions

func NewBillingService

func NewBillingService() (core.Service, []core.ContextBuilderOption, error)

func NewQuotaService

func NewQuotaService() (core.Service, []core.ContextBuilderOption, error)

Types

type BillingServiceDefault

type BillingServiceDefault struct {
	// contains filtered or unexported fields
}

func (*BillingServiceDefault) CancelSubscription

func (b *BillingServiceDefault) CancelSubscription(ctx context.Context, userID uint) error

func (*BillingServiceDefault) ChangeSubscription

func (b *BillingServiceDefault) ChangeSubscription(ctx context.Context, userID uint, planID string) error

func (*BillingServiceDefault) Config

func (b *BillingServiceDefault) Config() (any, error)

func (*BillingServiceDefault) ConnectSubscription

func (b *BillingServiceDefault) ConnectSubscription(ctx context.Context, userID uint, paymentMethodID string) error

func (*BillingServiceDefault) CreateCustomer

func (b *BillingServiceDefault) CreateCustomer(ctx context.Context, user *models.User) error

func (*BillingServiceDefault) CreateCustomerById

func (b *BillingServiceDefault) CreateCustomerById(ctx context.Context, userID uint) error

func (*BillingServiceDefault) GenerateEphemeralKey

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

func (*BillingServiceDefault) GetPlans

func (*BillingServiceDefault) GetSubscription

func (b *BillingServiceDefault) GetSubscription(ctx context.Context, userID uint) (*messages.SubscriptionResponse, error)

func (*BillingServiceDefault) GetUserMaxDownload

func (b *BillingServiceDefault) GetUserMaxDownload(userID uint) (uint64, error)

func (*BillingServiceDefault) GetUserMaxStorage

func (b *BillingServiceDefault) GetUserMaxStorage(userID uint) (uint64, error)

func (*BillingServiceDefault) GetUserMaxUpload

func (b *BillingServiceDefault) GetUserMaxUpload(userID uint) (uint64, error)

func (*BillingServiceDefault) ID

func (b *BillingServiceDefault) ID() string

func (*BillingServiceDefault) RequestPaymentMethodChange

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

func (*BillingServiceDefault) UpdateBillingInfo

func (b *BillingServiceDefault) UpdateBillingInfo(ctx context.Context, userID uint, billingInfo *messages.BillingInfo) error

type Customer

type Customer struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

Customer represents the customer information in the payment request

type CustomerBilling

type CustomerBilling struct {
	Address CustomerBillingAddress `json:"address"`
	Email   string                 `json:"email"`
}

type CustomerBillingAddress

type CustomerBillingAddress struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	City      string `json:"city"`
	Country   string `json:"country"`
	Line1     string `json:"line1"`
	Zip       string `json:"zip"`
	State     string `json:"state"`
}

type EphemeralKeyRequest

type EphemeralKeyRequest struct {
	CustomerID string `json:"customer_id"`
}

type EphemeralKeyResponse

type EphemeralKeyResponse struct {
	Secret string `json:"secret"`
}

type PaymentCancelRequest

type PaymentCancelRequest struct {
	CancellationReason string `json:"cancellation_reason"`
}

type PaymentMetadata

type PaymentMetadata struct {
	SubscriptionID string `json:"subscription_id"`
	PlanID         string `json:"plan_id"`
}

PaymentMetadata represents the upload for a payment

type PaymentRequest

type PaymentRequest struct {
	Amount           float64         `json:"amount"`
	Currency         string          `json:"currency"`
	Confirm          bool            `json:"confirm"`
	Customer         Customer        `json:"customer"`
	Billing          CustomerBilling `json:"billing,omitempty"`
	Description      string          `json:"description"`
	Metadata         PaymentMetadata `json:"metadata"`
	SetupFutureUsage string          `json:"setup_future_usage"`
	PaymentType      string          `json:"payment_type"`
}

PaymentRequest represents the payment request payload

type PaymentResponse

type PaymentResponse struct {
	PaymentID    string `json:"payment_id"`
	ClientSecret string `json:"client_secret"`
}

PaymentResponse represents the response from the payment creation API

type QuotaServiceDefault

type QuotaServiceDefault struct {
	// contains filtered or unexported fields
}

func (*QuotaServiceDefault) CheckDownloadQuota

func (q *QuotaServiceDefault) CheckDownloadQuota(userID uint, requestedBytes uint64) (bool, error)

func (*QuotaServiceDefault) CheckStorageQuota

func (q *QuotaServiceDefault) CheckStorageQuota(userID uint, requestedBytes uint64) (bool, error)

func (*QuotaServiceDefault) CheckUploadQuota

func (q *QuotaServiceDefault) CheckUploadQuota(userID uint, requestedBytes uint64) (bool, error)

func (*QuotaServiceDefault) Config

func (b *QuotaServiceDefault) Config() (any, error)

func (*QuotaServiceDefault) GetCurrentUsage

func (q *QuotaServiceDefault) GetCurrentUsage(userID uint) (*messages.CurrentUsageResponse, error)

func (*QuotaServiceDefault) GetDownloadUsageHistory

func (q *QuotaServiceDefault) GetDownloadUsageHistory(userID uint, period int) ([]*messages.UsageData, error)

func (*QuotaServiceDefault) GetStorageUsageHistory

func (q *QuotaServiceDefault) GetStorageUsageHistory(userID uint, period int) ([]*messages.UsageData, error)

func (*QuotaServiceDefault) GetUploadUsageHistory

func (q *QuotaServiceDefault) GetUploadUsageHistory(userID uint, period int) ([]*messages.UsageData, error)

func (*QuotaServiceDefault) ID

func (q *QuotaServiceDefault) ID() string

func (*QuotaServiceDefault) Reconcile

func (q *QuotaServiceDefault) Reconcile() error

func (*QuotaServiceDefault) RecordDownload

func (q *QuotaServiceDefault) RecordDownload(uploadID, userID uint, bytes uint64, ip string) error

func (*QuotaServiceDefault) RecordStorage

func (q *QuotaServiceDefault) RecordStorage(uploadID, userID uint, bytes int64, ip string) error

func (*QuotaServiceDefault) RecordUpload

func (q *QuotaServiceDefault) RecordUpload(uploadID, userID uint, bytes uint64, ip string) error

type Subscription

type Subscription struct {
	SubscriptionID strfmt.UUID
	PlanName       *string
}

type UsageType

type UsageType string
const (
	StorageUsage  UsageType = "storage"
	UploadUsage   UsageType = "upload"
	DownloadUsage UsageType = "download"
)

Jump to

Keyboard shortcuts

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