Files
CertifiedInvSWDB/sw/models/models.go
T

46 lines
1.2 KiB
Go

// Package model models the SW data
package model
import (
"encoding/json"
"time"
"gopkg.in/yaml.v2"
)
// SW holds the data that describe an AT certified invoicing software
type SW struct {
Name string `json:"name" yaml:"name"`
Version string `json:"version" yaml:"version"`
Developer string `json:"developer" yaml:"developer"`
CertNo int `json:"certNo" yaml:"certNo"`
State string `json:"state" yaml:"state"`
DeveloperNIF string `json:"string" yaml:"string"`
CertDate time.Time `json:"certDate" yaml:"certDate"`
}
// SWList is just a list of SW
type SWList []SW
// ToYAML returns a []byte representing the struct in YAML.
func (s *SWList) ToYAML() []byte {
yamlData, _ := yaml.Marshal(s)
return yamlData
}
// ToJSON returns a []byte representing the struct in JSON.
func (s *SWList) ToJSON() []byte {
jsondata, _ := json.Marshal(s)
return jsondata
}
// FromJSON loads a SW struct from a []byte of a SW in JSON.
func (s *SWList) FromJSON(data []byte) error {
return json.Unmarshal(data, s)
}
// FromYAML loads a SW struct from a []byte of a SW in YAML.
func (s *SWList) FromYAML(data []byte) error {
return yaml.Unmarshal(data, s)
}