order

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PriceDuration P1M represents a duration of 1 month.
	// There are other durations like P0D for installation price only, P1Y for 1 year, etc...
	PriceDuration = "P1M"
	// PricingMode default means no commitment.
	// there are other price modes like degressivityX for degressiv prices over X months, upfrontX, etc...
	PricingMode = "default"
	PricingType = "rental"
	// PricingCapacityRenew renew means renewals are possible
	PricingCapacityRenew = "renew"

	QuantityDefault = 1

	ConfigurationLabelDatacenter = "dedicated_datacenter"
	ConfigurationLabelRegion     = "region"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CartRequest

type CartRequest struct {
	Description   string `json:"description"`
	Expire        string `json:"expire"`
	OvhSubsidiary string `json:"ovhSubsidiary"`
}

CartRequest represents the request to create a cart.

type CartResponse

type CartResponse struct {
	CartID string `json:"cartId"`
}

CartResponse represents the response of a cart creation.

type CheckoutContract

type CheckoutContract struct {
	Name    string `json:"name"`
	Content string `json:"content"`
	URL     string `json:"url"`
}

type CheckoutPrices

type CheckoutPrices struct {
	OriginalWithoutTax Price `json:"originalWithoutTax,omitempty"`
	Reduction          Price `json:"reduction,omitempty"`
	Tax                Price `json:"tax,omitempty"`
	WithTax            Price `json:"withTax,omitempty"`
	WithoutTax         Price `json:"withoutTax,omitempty"`
}

type CheckoutRequest

type CheckoutRequest struct {
	AutoPayWithPreferredPaymentMethod bool `json:"autoPayWithPreferredPaymentMethod,omitempty"`
	WaiveRetractationPeriod           bool `json:"waiveRetractationPeriod,omitempty"`
}

CheckoutRequest represents the request to checkout.

type CheckoutResponse

type CheckoutResponse struct {
	OrderID   int                `json:"orderId,omitempty"`
	URL       string             `json:"url,omitempty"`
	Contracts []CheckoutContract `json:"contracts,omitempty"`
	Prices    CheckoutPrices     `json:"prices,omitempty"`
}

CheckoutResponse represents the response of a checkout.

type EcoItemInfo

type EcoItemInfo struct {
	PlanCode    string             `json:"planCode"`
	Prices      []EcoItemInfoPrice `json:"prices"`
	ProductName string             `json:"productName"`
	ProductType string             `json:"productType"`
}

type EcoItemInfoPrice

type EcoItemInfoPrice struct {
	Capacities      []string `json:"capacities"`
	Description     string   `json:"description"`
	Duration        string   `json:"duration"`
	Interval        int      `json:"interval"`
	MaximumQuantity int      `json:"maximumQuantity"`
	MaximumRepeat   int      `json:"maximumRepeat"`
	MinimumQuantity int      `json:"minimumQuantity"`
	MinimumRepeat   int      `json:"minimumRepeat"`
	Price           Price    `json:"price"`
	PriceInUcents   int      `json:"priceInUcents"`
	PricingMode     string   `json:"pricingMode"`
	PricingType     string   `json:"pricingType"`
}

type EcoItemInfos

type EcoItemInfos []EcoItemInfo

func (EcoItemInfos) GetByPlanCode

func (e EcoItemInfos) GetByPlanCode(planCode string) *EcoItemInfo

GetByPlanCode returns the EcoItemInfo with the given plan code.

func (EcoItemInfos) GetPriceConfigOrDefault

func (e EcoItemInfos) GetPriceConfigOrDefault(planCode string, priceConfig EcoItemPriceConfig) EcoItemPriceConfig

GetPriceConfigOrDefault does best effort to return a price config for the given plan code, and priceConfig. It tries to find a matching priceConfig, and if not it returns a default price config.

type EcoItemOption

type EcoItemOption struct {
	Option `json:",inline"`

	Mandatory   bool                 `json:"mandatory"`
	Prices      []EcoItemOptionPrice `json:"prices"`
	ProductName string               `json:"productName"`
}

EcoItemOption represents the options for an eco item.

func (EcoItemOption) GetPriceByConfig

func (i EcoItemOption) GetPriceByConfig(priceConfig EcoItemPriceConfig) *EcoItemOptionPrice

GetPriceByConfig returns the first price that matches the provided EcoItemPriceConfig.

type EcoItemOptionPrice

type EcoItemOptionPrice struct {
	Duration      string `json:"duration"`
	PricingMode   string `json:"pricingMode"`
	PriceInUcents int    `json:"priceInUcents"`
	Price         Price  `json:"price"`
}

type EcoItemOptionRequest

type EcoItemOptionRequest struct {
	EcoItemRequest `json:",inline"`

	ItemID int `json:"itemId"`
}

EcoItemOptionRequest represents the request to add an option to an eco item in the cart.

type EcoItemOptions

type EcoItemOptions []EcoItemOption

func (EcoItemOptions) Get

func (i EcoItemOptions) Get(family string) *EcoItemOption

Get returns the option that matches the provided family.

func (EcoItemOptions) GetCheapestMandatoryOptions

func (i EcoItemOptions) GetCheapestMandatoryOptions() EcoItemOptions

GetCheapestMandatoryOptions returns the cheapest mandatory options. It compares prices matching PriceDuration and PricingMode.

func (EcoItemOptions) ToOptions

func (i EcoItemOptions) ToOptions() Options

ToOptions converts EcoItemOptions to Options.

type EcoItemPriceConfig

type EcoItemPriceConfig struct {
	Duration    string `json:"duration"`
	PricingMode string `json:"pricingMode"`
}

type EcoItemRequest

type EcoItemRequest struct {
	EcoItemPriceConfig `json:",inline"`

	PlanCode string `json:"planCode"`
	Quantity int    `json:"quantity"`
}

EcoItemRequest represents the request to add an eco item to the cart

type EcoItemResponse

type EcoItemResponse struct {
	CartID string `json:"cartId"`
	ItemID int    `json:"itemId"`
}

EcoItemResponse represents the response of an eco item added to the cart

type ItemConfiguration

type ItemConfiguration struct {
	AllowedValues []string `json:"allowedValues"`
	Fields        []string `json:"fields"`
	Label         string   `json:"label"`
	Required      bool     `json:"required"`
	Type          string   `json:"type"`
}

ItemConfiguration represents an available option for an item configuration.

type ItemConfigurationRequest

type ItemConfigurationRequest struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

ItemConfigurationRequest represents the request to add a configuration to an item in the cart.

type ItemConfigurationRequests

type ItemConfigurationRequests []ItemConfigurationRequest

func NewItemConfigurationsFromMap

func NewItemConfigurationsFromMap(values map[string]string) ItemConfigurationRequests

NewItemConfigurationsFromMap creates a new ItemConfigurations. It uses the map keys as labels and the map values as values.

func (*ItemConfigurationRequests) Add

func (c *ItemConfigurationRequests) Add(label, value string)

Add adds a configuration if it does not exist.

func (ItemConfigurationRequests) GetByLabel

GetByLabel returns the first configuration with the given label.

func (ItemConfigurationRequests) Merge

Merge merges other ItemConfigurations into the current one. It does not overwrite existing configurations.

type ItemConfigurationResponse

type ItemConfigurationResponse struct {
	ItemConfigurationRequest `json:",inline"`

	ID int `json:"id"`
}

ItemConfigurationResponse represents the response of an item configuration added to the cart.

type Option

type Option struct {
	Family   string `json:"family"`
	PlanCode string `json:"planCode"`
}

func NewOptionsFromMap

func NewOptionsFromMap(optionsMap map[string]string) []Option

NewOptionsFromMap creates a new Options from a map. Using the map keys as family and the values as planCode.

type Options

type Options []Option

func (Options) Merge

func (opts Options) Merge(other []Option) Options

Merge merges the provided Options with the current Options. It does not overwrite existing options.

type Price

type Price struct {
	CurrencyCode  string  `json:"currencyCode"`
	PriceInUcents int     `json:"priceInUcents"`
	Text          string  `json:"text"`
	Value         float64 `json:"value"`
}

Jump to

Keyboard shortcuts

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