Skip to content

ports ​

go
import "github.com/prescriptoo/prescriptoo-api/services/subscription/internal/ports"

Package ports defines repository interfaces for the subscription service. Legacy prototype definitions in this file are unmounted; production uses the billing implementation.

Index ​

type BillingReader ​

BillingReader returns persisted facts. Missing resources use ErrNotFound.

go
type BillingReader interface {
    Plan(context.Context, string) (*p.Plan, error)
    Plans(context.Context, p.Query) ([]p.Plan, error)
    Subscription(context.Context, string) (*p.Subscription, error)
    Current(context.Context, []string) (map[string]p.CurrentSubscription, error)
    Subscriptions(context.Context, p.Query) ([]p.Subscription, error)
    Invoice(context.Context, string) (*p.Invoice, error)
    Invoices(context.Context, p.Query, bool) ([]p.Invoice, error)
    Payment(context.Context, string) (*p.Payment, error)
    Payments(context.Context, p.Query) ([]p.Payment, error)
}

type BillingStore ​

BillingStore owns transaction lifetime; all returned transactional readers use row locks.

go
type BillingStore interface {
    BillingReader
    Run(context.Context, func(BillingTransaction) error) error
}

type BillingTransaction ​

BillingTransaction serializes business writes with the affected organization's relationships.

go
type BillingTransaction interface {
    BillingReader
    SubscriptionOrganization(context.Context, string) (string, error)
    PaymentInvoice(context.Context, string) (string, error)
    LockOrganization(context.Context, string) (org.BillingOrganization, error)
    SavePlan(context.Context, *p.Plan) error
    SaveSubscription(context.Context, *p.Subscription) error
    SaveInvoice(context.Context, *p.Invoice) error
    SavePayment(context.Context, *p.Payment) error
    NextInvoiceNumber(context.Context) (string, error)
    PaidTotal(context.Context, string) (int64, error)
    Retry(context.Context, string, string, string, string) (json.RawMessage, error)
    Remember(context.Context, string, string, string, string, any) error
    Append(context.Context, audit.OperationContext, audit.EventInput) error
}

type PlanOverrideRepository ​

PlanOverrideRepository defines the driven repository port for plan overrides.

go
type PlanOverrideRepository interface {
    Create(ctx context.Context, override *domain.PlanOverride) error
    GetBySubscriptionID(ctx context.Context, subscriptionID string) ([]*domain.PlanOverride, error)
    Update(ctx context.Context, override *domain.PlanOverride) error
    Delete(ctx context.Context, id string) error
}

type PlanRepository ​

PlanRepository defines the driven repository port for plans.

go
type PlanRepository interface {
    Create(ctx context.Context, plan *domain.Plan) error
    GetByID(ctx context.Context, id string) (*domain.Plan, error)
    GetBySlug(ctx context.Context, slug string) (*domain.Plan, error)
    ListPublic(ctx context.Context) ([]*domain.Plan, error)
    ListAll(ctx context.Context) ([]*domain.Plan, error)
    Update(ctx context.Context, plan *domain.Plan) error
    Delete(ctx context.Context, id string) error
}

type SubscriptionRepository ​

SubscriptionRepository defines the driven repository port for subscriptions.

go
type SubscriptionRepository interface {
    Create(ctx context.Context, sub *domain.Subscription) error
    GetByID(ctx context.Context, id string) (*domain.Subscription, error)
    GetByOrganizationID(ctx context.Context, orgID string) (*domain.Subscription, error)
    ListByOrganizationID(ctx context.Context, orgID string) ([]*domain.Subscription, error)
    ListAll(ctx context.Context) ([]*domain.Subscription, error)
    Update(ctx context.Context, sub *domain.Subscription) error
    Cancel(ctx context.Context, id string) error
}

Generated by gomarkdoc

Documentation follows the source. Planned contracts are marked explicitly.