Documentation
¶
Index ¶
- Constants
- type CartRequest
- type CartResponse
- type CheckoutContract
- type CheckoutPrices
- type CheckoutRequest
- type CheckoutResponse
- type EcoItemInfo
- type EcoItemInfoPrice
- type EcoItemInfos
- type EcoItemOption
- type EcoItemOptionPrice
- type EcoItemOptionRequest
- type EcoItemOptions
- type EcoItemPriceConfig
- type EcoItemRequest
- type EcoItemResponse
- type ItemConfiguration
- type ItemConfigurationRequest
- type ItemConfigurationRequests
- type ItemConfigurationResponse
- type Option
- type Options
- type Price
Constants ¶
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 CheckoutPrices ¶
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 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 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 ¶
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 ¶
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 ¶
func (c ItemConfigurationRequests) GetByLabel(label string) *ItemConfigurationRequest
GetByLabel returns the first configuration with the given label.
func (ItemConfigurationRequests) Merge ¶
func (c ItemConfigurationRequests) Merge(other ItemConfigurationRequests) ItemConfigurationRequests
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 ¶
func NewOptionsFromMap ¶
NewOptionsFromMap creates a new Options from a map. Using the map keys as family and the values as planCode.