2019-06-18 16:55:47 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package console
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/skyrings/skyring-common/tools/uuid"
|
2019-07-01 20:16:49 +01:00
|
|
|
|
|
|
|
"storj.io/storj/internal/currency"
|
2019-06-18 16:55:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// UserCredits holds information to interact with database
|
|
|
|
type UserCredits interface {
|
2019-06-19 21:49:04 +01:00
|
|
|
GetCreditUsage(ctx context.Context, userID uuid.UUID, expirationEndDate time.Time) (*UserCreditUsage, error)
|
2019-06-18 16:55:47 +01:00
|
|
|
Create(ctx context.Context, userCredit UserCredit) (*UserCredit, error)
|
|
|
|
UpdateAvailableCredits(ctx context.Context, creditsToCharge int, id uuid.UUID, billingStartDate time.Time) (remainingCharge int, err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserCredit holds information about an user's credit
|
|
|
|
type UserCredit struct {
|
2019-07-01 20:16:49 +01:00
|
|
|
ID int
|
|
|
|
UserID uuid.UUID
|
|
|
|
OfferID int
|
|
|
|
ReferredBy uuid.UUID
|
|
|
|
CreditsEarned currency.USD
|
|
|
|
CreditsUsed currency.USD
|
|
|
|
ExpiresAt time.Time
|
|
|
|
CreatedAt time.Time
|
2019-06-18 16:55:47 +01:00
|
|
|
}
|
2019-06-19 21:49:04 +01:00
|
|
|
|
|
|
|
// UserCreditUsage holds information about credit usage information
|
|
|
|
type UserCreditUsage struct {
|
|
|
|
Referred int64
|
2019-07-01 20:16:49 +01:00
|
|
|
AvailableCredits currency.USD
|
|
|
|
UsedCredits currency.USD
|
2019-06-19 21:49:04 +01:00
|
|
|
}
|