-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.go
executable file
·110 lines (95 loc) · 2.08 KB
/
order.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
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package shared
import (
"encoding/json"
"fmt"
)
// OrderInput - An order for a drink or ingredient.
type OrderInput struct {
// The product code of the drink or ingredient.
ProductCode string `json:"productCode"`
// The number of units of the drink or ingredient to order.
Quantity int64 `json:"quantity"`
// The type of order.
Type OrderType `json:"type"`
}
func (o *OrderInput) GetProductCode() string {
if o == nil {
return ""
}
return o.ProductCode
}
func (o *OrderInput) GetQuantity() int64 {
if o == nil {
return 0
}
return o.Quantity
}
func (o *OrderInput) GetType() OrderType {
if o == nil {
return OrderType("")
}
return o.Type
}
// OrderStatus - The status of the order.
type OrderStatus string
const (
OrderStatusPending OrderStatus = "pending"
OrderStatusProcessing OrderStatus = "processing"
OrderStatusComplete OrderStatus = "complete"
)
func (e OrderStatus) ToPointer() *OrderStatus {
return &e
}
func (e *OrderStatus) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "pending":
fallthrough
case "processing":
fallthrough
case "complete":
*e = OrderStatus(v)
return nil
default:
return fmt.Errorf("invalid value for OrderStatus: %v", v)
}
}
// Order - An order for a drink or ingredient.
type Order struct {
// The product code of the drink or ingredient.
ProductCode string `json:"productCode"`
// The number of units of the drink or ingredient to order.
Quantity int64 `json:"quantity"`
// The status of the order.
Status OrderStatus `json:"status"`
// The type of order.
Type OrderType `json:"type"`
}
func (o *Order) GetProductCode() string {
if o == nil {
return ""
}
return o.ProductCode
}
func (o *Order) GetQuantity() int64 {
if o == nil {
return 0
}
return o.Quantity
}
func (o *Order) GetStatus() OrderStatus {
if o == nil {
return OrderStatus("")
}
return o.Status
}
func (o *Order) GetType() OrderType {
if o == nil {
return OrderType("")
}
return o.Type
}