-
Notifications
You must be signed in to change notification settings - Fork 0
/
drinktype.go
executable file
·48 lines (42 loc) · 942 Bytes
/
drinktype.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
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package shared
import (
"encoding/json"
"fmt"
)
// DrinkType - The type of drink.
type DrinkType string
const (
DrinkTypeCocktail DrinkType = "cocktail"
DrinkTypeNonAlcoholic DrinkType = "non-alcoholic"
DrinkTypeBeer DrinkType = "beer"
DrinkTypeWine DrinkType = "wine"
DrinkTypeSpirit DrinkType = "spirit"
DrinkTypeOther DrinkType = "other"
)
func (e DrinkType) ToPointer() *DrinkType {
return &e
}
func (e *DrinkType) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "cocktail":
fallthrough
case "non-alcoholic":
fallthrough
case "beer":
fallthrough
case "wine":
fallthrough
case "spirit":
fallthrough
case "other":
*e = DrinkType(v)
return nil
default:
return fmt.Errorf("invalid value for DrinkType: %v", v)
}
}