45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package models
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
type FoundryState struct {
|
|
IsAdmin bool `json:"isAdmin,omitempty"`
|
|
IsSetup bool `json:"isSetup,omitempty"`
|
|
Languages []Language `json:"languages,omitempty"`
|
|
Modules []DataTemplate `json:"modules"`
|
|
Release Release `json:"release"`
|
|
Systems []DataTemplate `json:"systems,omitempty"`
|
|
Worlds []DataTemplate `json:"worlds,omitempty"`
|
|
World *DataTemplate `json:"world,omitempty"`
|
|
Users Users `json:"users,omitempty"`
|
|
Options struct {
|
|
Language string `json:"language,omitempty"`
|
|
} `json:"options,omitempty"`
|
|
|
|
//coreUpdate struct{}
|
|
//featuredContent struct{}
|
|
//files struct{}
|
|
//news struct{}
|
|
|
|
//packageWarnings struct{} think about it
|
|
}
|
|
|
|
func (state FoundryState) GetRelease() Release {
|
|
return state.Release
|
|
}
|
|
|
|
func ParseSetupModel(data []byte) (*FoundryState, error) {
|
|
var modelSetup []FoundryState
|
|
err := json.Unmarshal(data, &modelSetup)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if len(modelSetup) > 1 {
|
|
return nil, ErrorSetupMoreThanOne
|
|
}
|
|
return &modelSetup[0], nil
|
|
}
|