-
Notifications
You must be signed in to change notification settings - Fork 131
/
types_order_cart.go
137 lines (113 loc) · 4.06 KB
/
types_order_cart.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package ovh
import (
"fmt"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/ovh/terraform-provider-ovh/ovh/helpers"
)
type OrderCartCreateOpts struct {
OvhSubsidiary string `json:"ovhSubsidiary"`
Description *string `json:"description,omitempty"`
Expire *string `json:"expire,omitempty"`
}
func (opts *OrderCartCreateOpts) FromResource(d *schema.ResourceData) *OrderCartCreateOpts {
opts.OvhSubsidiary = strings.ToUpper(d.Get("ovh_subsidiary").(string))
opts.Description = helpers.GetNilStringPointerFromData(d, "description")
opts.Expire = helpers.GetNilStringPointerFromData(d, "expire")
return opts
}
type OrderCartPlanCreateOpts struct {
CatalogName *string `json:"catalogName,omitempty"`
Duration string `json:"duration"`
PlanCode string `json:"planCode"`
PricingMode string `json:"pricingMode"`
Quantity int `json:"quantity"`
}
func (opts *OrderCartPlanCreateOpts) FromResourceWithPath(d *schema.ResourceData, path string) *OrderCartPlanCreateOpts {
opts.CatalogName = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.catalog_name", path))
opts.Duration = d.Get(fmt.Sprintf("%s.duration", path)).(string)
opts.PlanCode = d.Get(fmt.Sprintf("%s.plan_code", path)).(string)
opts.PricingMode = d.Get(fmt.Sprintf("%s.pricing_mode", path)).(string)
return opts
}
func (opts *OrderCartPlanCreateOpts) String() string {
return fmt.Sprintf(
"planCode: %s, pricingMode: %s, duration: %s, quantity: %d, catalogName: %v",
opts.PlanCode,
opts.PricingMode,
opts.Duration,
opts.Quantity,
*opts.CatalogName,
)
}
type OrderCartPlanOptionsCreateOpts struct {
CatalogName *string `json:"catalogName,omitempty"`
Duration string `json:"duration"`
PlanCode string `json:"planCode"`
PricingMode string `json:"pricingMode"`
Quantity int `json:"quantity"`
ItemId int64 `json:"itemId"`
}
func (opts *OrderCartPlanOptionsCreateOpts) FromResourceWithPath(d *schema.ResourceData, path string) *OrderCartPlanOptionsCreateOpts {
opts.CatalogName = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.catalog_name", path))
opts.Duration = d.Get(fmt.Sprintf("%s.duration", path)).(string)
opts.PlanCode = d.Get(fmt.Sprintf("%s.plan_code", path)).(string)
opts.PricingMode = d.Get(fmt.Sprintf("%s.pricing_mode", path)).(string)
return opts
}
func (opts *OrderCartPlanOptionsCreateOpts) String() string {
return fmt.Sprintf(
"planCode: %s, pricingMode: %s, duration: %s, quantity: %d, itemId: %d, catalogName: %s",
opts.PlanCode,
opts.PricingMode,
opts.Duration,
opts.Quantity,
opts.ItemId,
*opts.CatalogName,
)
}
type OrderCart struct {
CartId string `json:"cartId"`
Description *string `json:"description"`
Expire *string `json:"expire"`
Items []int64 `json:"items"`
ReadOnly bool `json:"readOnly"`
}
func (v OrderCart) ToMap() map[string]interface{} {
obj := make(map[string]interface{})
obj["cart_id"] = v.CartId
obj["items"] = v.Items
obj["read_only"] = v.ReadOnly
if v.Description != nil {
obj["description"] = *v.Description
}
if v.Expire != nil {
obj["expire"] = *v.Expire
}
return obj
}
type OrderCartItemCreateOpts struct {
CatalogName *string `json:"catalogName,omitempty"`
Duration string `json:"duration"`
PlanCode string `json:"planCode"`
PricingMode string `json:"pricingMode"`
Quantity int `json:"quantity"`
}
func (opts *OrderCartItemCreateOpts) FromResource(d *schema.ResourceData) *OrderCartItemCreateOpts {
opts.CatalogName = helpers.GetNilStringPointerFromData(d, "catalog_name")
opts.Duration = strings.ToUpper(d.Get("duration").(string))
opts.PlanCode = strings.ToUpper(d.Get("plan_code").(string))
opts.PricingMode = strings.ToUpper(d.Get("pricing_mode").(string))
opts.Quantity = d.Get("quantity").(int)
return opts
}
type OrderCartCheckout struct {
OrderID int64 `json:"orderId"`
Prices OrderCartCheckoutPrices `json:"prices"`
}
type OrderCartCheckoutPrices struct {
WithoutTax OrderCartCheckoutPrice `json:"withoutTax"`
}
type OrderCartCheckoutPrice struct {
Value float64 `json:"value"`
}