pricing

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2016 License: MIT Imports: 4 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PriceString

func PriceString(price *big.Rat, currency string) string

PriceString returns a human reprensetation of a price with a currency

Types

type Basket

type Basket []Usage

Basket represents a billing basket

func NewBasket

func NewBasket() *Basket

NewBasket return a new instance of Basket

func (*Basket) Add

func (b *Basket) Add(usage Usage) error

Add adds an Usage to a Basket

func (*Basket) Length

func (b *Basket) Length() int

Length returns the amount of Usages in a Basket

func (*Basket) SetDuration

func (b *Basket) SetDuration(duration time.Duration) error

SetDuration sets the duration for each Usages of a Basket

func (*Basket) Total

func (b *Basket) Total() *big.Rat

Total computes the Usage.Total() of all the Usages of a Basket

type List added in v1.7.0

type List []Object

List represents a list of Object

var CurrentPricing List

CurrentPricing tries to be up-to-date with the real pricing we cannot guarantee of these values since we hardcode values for now later, we should be able to call a dedicated pricing API

func (*List) GetByIdentifier added in v1.7.0

func (pl *List) GetByIdentifier(identifier string) *Object

GetByIdentifier returns an object matching a identifier

func (*List) GetByPath added in v1.7.0

func (pl *List) GetByPath(path string) *Object

GetByPath returns an object matching a path

type Object added in v1.7.0

type Object struct {
	Path             string
	Identifier       string
	Currency         string
	UsageUnit        string
	UnitPrice        *big.Rat
	UnitQuantity     *big.Rat
	UnitPriceCap     *big.Rat
	UsageGranularity time.Duration
}

Object represents a Pricing item definition

type Usage

type Usage struct {
	Object   *Object
	Quantity *big.Rat
}

Usage represents a billing usage

func NewUsage

func NewUsage(object *Object) Usage

NewUsage returns a new Usage

func NewUsageByPath

func NewUsageByPath(objectPath string) Usage

NewUsageByPath returns a new Usage with defaults fetched from a path

func NewUsageByPathWithQuantity

func NewUsageByPathWithQuantity(objectPath string, quantity *big.Rat) Usage

NewUsageByPathWithQuantity returns a NewUsageByPath with a specific quantity

func NewUsageWithQuantity

func NewUsageWithQuantity(object *Object, quantity *big.Rat) Usage

NewUsageWithQuantity returns a new Usage with quantity

func (*Usage) BillableQuantity

func (u *Usage) BillableQuantity() *big.Rat

BillableQuantity returns the billable quantity of an Usage

func (*Usage) LostQuantity

func (u *Usage) LostQuantity() *big.Rat

LostQuantity returns the lost quantity of an Usage

func (*Usage) SetDuration

func (u *Usage) SetDuration(duration time.Duration) error

SetDuration sets the duration of an Usage

func (*Usage) SetQuantity

func (u *Usage) SetQuantity(quantity *big.Rat) error

SetQuantity sets the quantity of an Usage

func (*Usage) SetStartEnd

func (u *Usage) SetStartEnd(start, end time.Time) error

SetStartEnd sets the start date and the end date of an Usage

func (*Usage) Total

func (u *Usage) Total() *big.Rat

Total returns the total of an Usage

func (*Usage) TotalString

func (u *Usage) TotalString() string

TotalString returns a string representing the total price of an Usage + its currency

Jump to

Keyboard shortcuts

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