-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecipe.go
126 lines (115 loc) · 5.47 KB
/
recipe.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
// Code generated by jsonschema. DO NOT EDIT.
package beerjson
import "encoding/json"
import "fmt"
// ID: https://raw.githubusercontent.com/beerjson/beerjson/master/json/recipe.json
// The efficiencyType stores each efficiency component.
type EfficiencyType struct {
// The percentage of sugar from the grain yield that is extracted and converted during the mash.
Conversion *PercentType `json:"conversion,omitempty"`
// The percentage of sugar that makes it from the mash tun to the kettle.
Lauter *PercentType `json:"lauter,omitempty"`
// The percentage of sugar that makes it from the grain to the kettle.
Mash *PercentType `json:"mash,omitempty"`
// The percentage of sugar that makes it from the grain to the fermenter.
Brewhouse PercentType `json:"brewhouse", validate:"required"`
}
type IngredientsType struct {
// fermentable_additions collects all the fermentable ingredients for use in a recipe
FermentableAdditions []FermentableAdditionType `json:"fermentable_additions", validate:"required"`
// hop_additions collects all the hops for use in a recipe
HopAdditions []HopAdditionType `json:"hop_additions,omitempty"`
// miscellaneous_additions collects all the miscellaneous items for use in a recipe
MiscellaneousAdditions []MiscellaneousAdditionType `json:"miscellaneous_additions,omitempty"`
// culture_additions collects all the culture items for use in a recipe
CultureAdditions []CultureAdditionType `json:"culture_additions,omitempty"`
// water_additions collects all the water items for use in a recipe
WaterAdditions []WaterAdditionType `json:"water_additions,omitempty"`
}
// RecipeType composes the information stored in a beerjson recipe.
type RecipeType struct {
// The final carbonation of the beer when packaged or served.
Carbonation *float64 `json:"carbonation,omitempty"`
// FermentationProcedureType defines the procedure for performing fermentation.
Fermentation *FermentationProcedureType `json:"fermentation,omitempty"`
// Defines the procedure for performing a boil. A boil procedure with no steps is the same as a standard single step boil.
Boil *BoilProcedureType `json:"boil,omitempty"`
// Used to store subjective tasting notes, and rating.
Taste *TasteType `json:"taste,omitempty"`
// This defines the procedure for performing unique mashing processes.
Mash *MashProcedureType `json:"mash,omitempty"`
// The gravity of beer at the end of fermentation.
FinalGravity *GravityType `json:"final_gravity,omitempty"`
// The final beer pH at the end of fermentation.
BeerPH *AcidityType `json:"beer_pH,omitempty"`
Created *DateType `json:"created,omitempty"`
// Used to store each efficiency component, including conversion, and brewhouse.
Efficiency EfficiencyType `json:"efficiency", validate:"required"`
Style *RecipeStyleType `json:"style,omitempty"`
// Describes the procedure for packaging your beverage.
Packaging *PackagingProcedureType `json:"packaging,omitempty"`
Name string `json:"name", validate:"required"`
Author string `json:"author", validate:"required"`
Coauthor *string `json:"coauthor,omitempty"`
// The gravity of wort when transffered to the fermenter.
OriginalGravity *GravityType `json:"original_gravity,omitempty"`
// The color of the finished beer, using SRM or EBC.
ColorEstimate *ColorType `json:"color_estimate,omitempty"`
// The total apparent attenuation of the finished beer after fermentation.
ApparentAttenuation *PercentType `json:"apparent_attenuation,omitempty"`
CaloriesPerPint *float64 `json:"calories_per_pint,omitempty"`
// The volume into the fermenter.
BatchSize VolumeType `json:"batch_size", validate:"required"`
// A collection of all ingredients used for the recipe.
Ingredients IngredientsType `json:"ingredients", validate:"required"`
Notes *string `json:"notes,omitempty"`
RecipeTypeType RecipeTypeType `json:"type", validate:"required"`
AlcoholByVolume *PercentType `json:"alcohol_by_volume,omitempty"`
// Used to differentiate which IBU formula is being used in a recipe. If formula is modified in any way, eg to support whirlpool/flameout additions etc etc, please use `Other` for transparency.
IbuEstimate *IBUEstimateType `json:"ibu_estimate,omitempty"`
}
type RecipeTypeType string
func (s *RecipeTypeType) UnmarshalJSON(b []byte) error {
var v string
err := json.Unmarshal(b, &v)
if err != nil {
return err
}
*s = RecipeTypeType(v)
switch *s {
case RecipeTypeType_Cider:
return nil
case RecipeTypeType_Kombucha:
return nil
case RecipeTypeType_Soda:
return nil
case RecipeTypeType_Other:
return nil
case RecipeTypeType_Mead:
return nil
case RecipeTypeType_Wine:
return nil
case RecipeTypeType_Extract:
return nil
case RecipeTypeType_PartialMash:
return nil
case RecipeTypeType_AllGrain:
return nil
}
return fmt.Errorf("RecipeTypeType: value '%v' does not match any value", v)
}
const (
RecipeTypeType_Cider RecipeTypeType = "cider"
RecipeTypeType_Kombucha RecipeTypeType = "kombucha"
RecipeTypeType_Soda RecipeTypeType = "soda"
RecipeTypeType_Other RecipeTypeType = "other"
RecipeTypeType_Mead RecipeTypeType = "mead"
RecipeTypeType_Wine RecipeTypeType = "wine"
RecipeTypeType_Extract RecipeTypeType = "extract"
RecipeTypeType_PartialMash RecipeTypeType = "partial mash"
RecipeTypeType_AllGrain RecipeTypeType = "all grain"
)
type TasteType struct {
Notes string `json:"notes", validate:"required"`
Rating float64 `json:"rating", validate:"required"`
}