init
This commit is contained in:
44
internal/foundry/models/data.go
Normal file
44
internal/foundry/models/data.go
Normal file
@@ -0,0 +1,44 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user