repository

package
v0.0.0-...-bfe46a2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package repository provides access to data available in SQL-based data store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Issuer

type Issuer struct{}

func NewIssuer

func NewIssuer() *Issuer

func (*Issuer) Create

func (r *Issuer) Create(ctx context.Context, dbi sqlx.QueryerContext, req model.IssuerNew) (*model.Issuer, error)

func (*Issuer) GetByMerchID

func (r *Issuer) GetByMerchID(ctx context.Context, dbi sqlx.QueryerContext, merchID string) (*model.Issuer, error)

func (*Issuer) GetByPubKey

func (r *Issuer) GetByPubKey(ctx context.Context, dbi sqlx.QueryerContext, pubKey string) (*model.Issuer, error)

type MockIssuer

type MockIssuer struct {
	FnGetByMerchID func(ctx context.Context, dbi sqlx.QueryerContext, merchID string) (*model.Issuer, error)
	FnGetByPubKey  func(ctx context.Context, dbi sqlx.QueryerContext, pubKey string) (*model.Issuer, error)
	FnCreate       func(ctx context.Context, dbi sqlx.QueryerContext, req model.IssuerNew) (*model.Issuer, error)
}

func (*MockIssuer) Create

func (*MockIssuer) GetByMerchID

func (r *MockIssuer) GetByMerchID(ctx context.Context, dbi sqlx.QueryerContext, merchID string) (*model.Issuer, error)

func (*MockIssuer) GetByPubKey

func (r *MockIssuer) GetByPubKey(ctx context.Context, dbi sqlx.QueryerContext, pubKey string) (*model.Issuer, error)

type MockOrder

type MockOrder struct {
	FnGet                               func(ctx context.Context, dbi sqlx.QueryerContext, id uuid.UUID) (*model.Order, error)
	FnGetByExternalID                   func(ctx context.Context, dbi sqlx.QueryerContext, extID string) (*model.Order, error)
	FnCreate                            func(ctx context.Context, dbi sqlx.QueryerContext, oreq *model.OrderNew) (*model.Order, error)
	FnSetStatus                         func(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, status string) error
	FnSetExpiresAt                      func(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, when time.Time) error
	FnSetLastPaidAt                     func(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, when time.Time) error
	FnSetTrialDays                      func(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, ndays int64) error
	FnAppendMetadata                    func(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, key, val string) error
	FnAppendMetadataInt                 func(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, key string, val int) error
	FnAppendMetadataInt64               func(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, key string, val int64) error
	FnGetExpiredStripeCheckoutSessionID func(ctx context.Context, dbi sqlx.QueryerContext, orderID uuid.UUID) (string, error)
	FnIncrementNumPayFailed             func(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID) error
}

func (*MockOrder) AppendMetadata

func (r *MockOrder) AppendMetadata(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, key, val string) error

func (*MockOrder) AppendMetadataInt

func (r *MockOrder) AppendMetadataInt(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, key string, val int) error

func (*MockOrder) AppendMetadataInt64

func (r *MockOrder) AppendMetadataInt64(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, key string, val int64) error

func (*MockOrder) Create

func (r *MockOrder) Create(ctx context.Context, dbi sqlx.QueryerContext, oreq *model.OrderNew) (*model.Order, error)

func (*MockOrder) Get

func (r *MockOrder) Get(ctx context.Context, dbi sqlx.QueryerContext, id uuid.UUID) (*model.Order, error)

func (*MockOrder) GetByExternalID

func (r *MockOrder) GetByExternalID(ctx context.Context, dbi sqlx.QueryerContext, extID string) (*model.Order, error)

func (*MockOrder) GetExpiredStripeCheckoutSessionID

func (r *MockOrder) GetExpiredStripeCheckoutSessionID(ctx context.Context, dbi sqlx.QueryerContext, orderID uuid.UUID) (string, error)

func (*MockOrder) IncrementNumPayFailed

func (r *MockOrder) IncrementNumPayFailed(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID) error

func (*MockOrder) SetExpiresAt

func (r *MockOrder) SetExpiresAt(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, when time.Time) error

func (*MockOrder) SetLastPaidAt

func (r *MockOrder) SetLastPaidAt(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, when time.Time) error

func (*MockOrder) SetStatus

func (r *MockOrder) SetStatus(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, status string) error

func (*MockOrder) SetTrialDays

func (r *MockOrder) SetTrialDays(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, ndays int64) error

type MockOrderItem

type MockOrderItem struct {
	FnGet           func(ctx context.Context, dbi sqlx.QueryerContext, id uuid.UUID) (*model.OrderItem, error)
	FnFindByOrderID func(ctx context.Context, dbi sqlx.QueryerContext, orderID uuid.UUID) ([]model.OrderItem, error)
	FnInsertMany    func(ctx context.Context, dbi sqlx.ExtContext, items ...model.OrderItem) ([]model.OrderItem, error)
}

func (*MockOrderItem) FindByOrderID

func (r *MockOrderItem) FindByOrderID(ctx context.Context, dbi sqlx.QueryerContext, orderID uuid.UUID) ([]model.OrderItem, error)

func (*MockOrderItem) Get

func (*MockOrderItem) InsertMany

func (r *MockOrderItem) InsertMany(ctx context.Context, dbi sqlx.ExtContext, items ...model.OrderItem) ([]model.OrderItem, error)

type MockOrderPayHistory

type MockOrderPayHistory struct {
	FnInsert func(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, when time.Time) error
}

func (*MockOrderPayHistory) Insert

func (r *MockOrderPayHistory) Insert(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, when time.Time) error

type MockTLV2

type MockTLV2 struct {
	FnGetCredSubmissionReport func(ctx context.Context, dbi sqlx.QueryerContext, orderID, itemID, reqID uuid.UUID, firstBCred string) (model.TLV2CredSubmissionReport, error)
	FnUniqBatches             func(ctx context.Context, dbi sqlx.QueryerContext, orderID, itemID uuid.UUID, from, to time.Time) (int, error)
	FnDeleteLegacy            func(ctx context.Context, dbi sqlx.ExecerContext, orderID uuid.UUID) error
}

func (*MockTLV2) DeleteLegacy

func (r *MockTLV2) DeleteLegacy(ctx context.Context, dbi sqlx.ExecerContext, orderID uuid.UUID) error

func (*MockTLV2) GetCredSubmissionReport

func (r *MockTLV2) GetCredSubmissionReport(ctx context.Context, dbi sqlx.QueryerContext, orderID, itemID, reqID uuid.UUID, firstBCred string) (model.TLV2CredSubmissionReport, error)

func (*MockTLV2) UniqBatches

func (r *MockTLV2) UniqBatches(ctx context.Context, dbi sqlx.QueryerContext, orderID, itemID uuid.UUID, from, to time.Time) (int, error)

type Order

type Order struct{}

func NewOrder

func NewOrder() *Order

func (*Order) AppendMetadata

func (r *Order) AppendMetadata(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, key, val string) error

AppendMetadata sets value by key to order's metadata, and might create metadata if it was missing.

func (*Order) AppendMetadataInt

func (r *Order) AppendMetadataInt(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, key string, val int) error

AppendMetadataInt sets int value by key to order's metadata, and might create metadata if it was missing.

func (*Order) AppendMetadataInt64

func (r *Order) AppendMetadataInt64(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, key string, val int64) error

AppendMetadataInt64 sets int value by key to order's metadata, and might create metadata if it was missing.

func (*Order) Create

func (r *Order) Create(ctx context.Context, dbi sqlx.QueryerContext, oreq *model.OrderNew) (*model.Order, error)

Create creates an order with the data in req.

func (*Order) Get

func (r *Order) Get(ctx context.Context, dbi sqlx.QueryerContext, id uuid.UUID) (*model.Order, error)

Get retrieves the order for the given id.

func (*Order) GetByExternalID

func (r *Order) GetByExternalID(ctx context.Context, dbi sqlx.QueryerContext, extID string) (*model.Order, error)

GetByExternalID retrieves the order by extID in metadata.externalID.

func (*Order) GetExpiredStripeCheckoutSessionID

func (r *Order) GetExpiredStripeCheckoutSessionID(ctx context.Context, dbi sqlx.QueryerContext, orderID uuid.UUID) (string, error)

GetExpiredStripeCheckoutSessionID returns stripeCheckoutSessionId if it's found and expired.

func (*Order) GetExpiresAtAfterISOPeriod

func (r *Order) GetExpiresAtAfterISOPeriod(ctx context.Context, dbi sqlx.QueryerContext, id uuid.UUID) (time.Time, error)

GetExpiresAtAfterISOPeriod returns a new value for expires_at that is last_paid_at plus ISO period.

It falls back to now() when last_paid_at is NULL. It uses the maximum of the order items' valid_for_iso as inverval, and falls back to 1 month.

func (*Order) GetMetadata

func (r *Order) GetMetadata(ctx context.Context, dbi sqlx.QueryerContext, id uuid.UUID) (datastore.Metadata, error)

GetMetadata returns metadata of the order.

func (*Order) GetTimeBounds

func (r *Order) GetTimeBounds(ctx context.Context, dbi sqlx.QueryerContext, id uuid.UUID) (model.OrderTimeBounds, error)

GetTimeBounds returns valid_for and last_paid_at for the order.

func (*Order) HasExternalID

func (r *Order) HasExternalID(ctx context.Context, dbi sqlx.QueryerContext, extID string) (bool, error)

HasExternalID indicates whether an order with the metadata.externalID exists.

func (*Order) IncrementNumPayFailed

func (r *Order) IncrementNumPayFailed(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID) error

func (*Order) SetExpiresAt

func (r *Order) SetExpiresAt(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, when time.Time) error

SetExpiresAt sets expires_at.

func (*Order) SetLastPaidAt

func (r *Order) SetLastPaidAt(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, when time.Time) error

SetLastPaidAt sets last_paid_at to when.

func (*Order) SetStatus

func (r *Order) SetStatus(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, status string) error

SetStatus sets status to status.

func (*Order) SetTrialDays

func (r *Order) SetTrialDays(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, ndays int64) error

SetTrialDays sets trial_days to ndays.

func (*Order) UpdateMetadata

func (r *Order) UpdateMetadata(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, data datastore.Metadata) error

UpdateMetadata _sets_ metadata to data.

type OrderItem

type OrderItem struct{}

func NewOrderItem

func NewOrderItem() *OrderItem

func (*OrderItem) FindByOrderID

func (r *OrderItem) FindByOrderID(ctx context.Context, dbi sqlx.QueryerContext, orderID uuid.UUID) ([]model.OrderItem, error)

FindByOrderID returns order items for the given orderID.

func (*OrderItem) Get

Get retrieves the order item by the given id.

func (*OrderItem) InsertMany

func (r *OrderItem) InsertMany(ctx context.Context, dbi sqlx.ExtContext, items ...model.OrderItem) ([]model.OrderItem, error)

InsertMany inserts given items and returns the result.

type OrderPayHistory

type OrderPayHistory struct{}

func NewOrderPayHistory

func NewOrderPayHistory() *OrderPayHistory

func (*OrderPayHistory) Insert

func (r *OrderPayHistory) Insert(ctx context.Context, dbi sqlx.ExecerContext, id uuid.UUID, when time.Time) error

type TLV2

type TLV2 struct{}

func NewTLV2

func NewTLV2() *TLV2

func (*TLV2) DeleteLegacy

func (r *TLV2) DeleteLegacy(ctx context.Context, dbi sqlx.ExecerContext, orderID uuid.UUID) error

DeleteLegacy deletes creds where request_id matches the item_id.

Most of the time, there will be only one such set of creds for a given period of time because there is only one item in an order.

TODO(pavelb): Reconsider this when it's time for Bundles. By that time this method might be gone.

func (*TLV2) GetCredSubmissionReport

func (r *TLV2) GetCredSubmissionReport(ctx context.Context, dbi sqlx.QueryerContext, orderID, itemID, reqID uuid.UUID, firstBCred string) (model.TLV2CredSubmissionReport, error)

func (*TLV2) UniqBatches

func (r *TLV2) UniqBatches(ctx context.Context, dbi sqlx.QueryerContext, orderID, itemID uuid.UUID, from, to time.Time) (int, error)

Jump to

Keyboard shortcuts

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