e8605d312e
* fix String converison * add method * rename to USD * fix types * fix parsing of forms * fix tests * fix header * use larger type * use int64 * rename func * move currency to separate package * convert types, renames * fix usercredits * remove unnecessary conversion * fix comment and named params
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package console
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/skyrings/skyring-common/tools/uuid"
|
|
|
|
"storj.io/storj/internal/currency"
|
|
)
|
|
|
|
// UserCredits holds information to interact with database
|
|
type UserCredits interface {
|
|
GetCreditUsage(ctx context.Context, userID uuid.UUID, expirationEndDate time.Time) (*UserCreditUsage, error)
|
|
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 {
|
|
ID int
|
|
UserID uuid.UUID
|
|
OfferID int
|
|
ReferredBy uuid.UUID
|
|
CreditsEarned currency.USD
|
|
CreditsUsed currency.USD
|
|
ExpiresAt time.Time
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
// UserCreditUsage holds information about credit usage information
|
|
type UserCreditUsage struct {
|
|
Referred int64
|
|
AvailableCredits currency.USD
|
|
UsedCredits currency.USD
|
|
}
|