pricing

package
v0.0.0-...-a0f436b Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BookingEstimation

func BookingEstimation(t TimePricingStrategy, price float64, locationDurationInSecond float64, start time.Time, end *time.Time) (float64, error)

Types

type AccessPricingProfile

type AccessPricingProfile[T Strategy] struct {
	ID            string             `json:"id,omitempty" bson:"id,omitempty"`             // ID is the ID of the pricing
	Pricing       PricingStrategy[T] `json:"price,omitempty" bson:"price,omitempty"`       // Price is the price of the resource
	DefaultRefund RefundType         `json:"default_refund" bson:"default_refund"`         // DefaultRefund is the default refund type of the pricing
	RefundRatio   int32              `json:"refund_ratio" bson:"refund_ratio" default:"0"` // RefundRatio is the refund ratio if missing
}

func (*AccessPricingProfile[T]) GetID

func (b *AccessPricingProfile[T]) GetID() string

func (*AccessPricingProfile[T]) GetOverrideStrategyValue

func (b *AccessPricingProfile[T]) GetOverrideStrategyValue() int

type BuyingStrategy

type BuyingStrategy int
const (
	UNLIMITED BuyingStrategy = iota
	SUBSCRIPTION
	PAY_PER_USE
)

type ExploitPricingProfile

type ExploitPricingProfile[T Strategy] struct {
	AccessPricingProfile[T]
	AdditionnalRefundTypes []RefundType `json:"refund_types" bson:"refund_types"` // RefundTypes is the refund types of the pricing

	PrivilegeStrategy   ExploitPrivilegeStrategy `json:"privilege_strategy,omitempty" bson:"privilege_strategy,omitempty"` // Strategy is the strategy of the pricing
	GarantedDelaySecond uint

	Exceeding      bool
	ExceedingRatio int32 `json:"exceeding_ratio" bson:"exceeding_ratio" default:"0"` // ExceedingRatio is the exceeding ratio of the bill
}

type ExploitPrivilegeStrategy

type ExploitPrivilegeStrategy int
const (
	BASIC ExploitPrivilegeStrategy = iota
	GARANTED_ON_DELAY
	GARANTED
)

func (ExploitPrivilegeStrategy) String

func (t ExploitPrivilegeStrategy) String() string

type PricedItemITF

type PricedItemITF interface {
	GetID() string
	GetType() tools.DataType
	IsPurchased() bool
	GetCreatorID() string
	GetLocationStart() *time.Time
	SetLocationStart(start time.Time)
	SetLocationEnd(end time.Time)
	GetLocationEnd() *time.Time
	GetExplicitDurationInS() float64
	GetPrice() (float64, error)
}

type PricingProfileITF

type PricingProfileITF interface {
	GetID() string
	GetPrice(quantity float64, val float64, start time.Time, end time.Time, params ...string) (float64, error)
	IsPurchased() bool
	GetOverrideStrategyValue() int
}

type PricingStrategy

type PricingStrategy[T Strategy] struct {
	Price               float64             `json:"Price" bson:"Price" default:"0"`                                 // Price is the Price of the pricing
	BuyingStrategy      BuyingStrategy      `json:"buying_strategy" bson:"buying_strategy" default:"0"`             // BuyingStrategy is the buying strategy of the pricing
	TimePricingStrategy TimePricingStrategy `json:"time_pricing_strategy" bson:"time_pricing_strategy" default:"0"` // TimePricingStrategy is the time pricing strategy of the pricing
	OverrideStrategy    T                   `json:"override_strategy" bson:"override_strategy" default:"-1"`        // Modulation is the modulation of the pricing
}

hmmmm

func (PricingStrategy[T]) GetBuyingStrategy

func (p PricingStrategy[T]) GetBuyingStrategy() BuyingStrategy

func (PricingStrategy[T]) GetOverrideStrategy

func (p PricingStrategy[T]) GetOverrideStrategy() T

func (PricingStrategy[T]) GetPrice

func (p PricingStrategy[T]) GetPrice(amountOfData float64, bookingTimeDuration float64, start time.Time, end *time.Time) (float64, error)

QUANTITY can be how many of gb core per example

func (PricingStrategy[T]) GetTimePricingStrategy

func (p PricingStrategy[T]) GetTimePricingStrategy() TimePricingStrategy

func (PricingStrategy[T]) SetSpecificPerUseStrategy

func (p PricingStrategy[T]) SetSpecificPerUseStrategy(strategy T) error

func (PricingStrategy[T]) SetStrategy

func (p PricingStrategy[T]) SetStrategy(Price float64, BuyingStrategy BuyingStrategy, TimePricingStrategy TimePricingStrategy) error

type RefundType

type RefundType int
const (
	REFUND_DEAD_END RefundType = iota
	REFUND_ON_ERROR
	REFUND_ON_EARLY_END
)

type Strategy

type Strategy interface {
	GetStrategy() string
	GetStrategyValue() int
}

type TimePricingStrategy

type TimePricingStrategy int
const (
	ONCE TimePricingStrategy = iota
	PER_SECOND
	PER_MINUTE
	PER_HOUR
	PER_DAY
	PER_WEEK
	PER_MONTH
)

func (TimePricingStrategy) GetStrategy

func (t TimePricingStrategy) GetStrategy() string

func (TimePricingStrategy) GetStrategyValue

func (t TimePricingStrategy) GetStrategyValue() int

Jump to

Keyboard shortcuts

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