// Package model models the SW data package model import ( "encoding/json" "time" "gopkg.in/yaml.v2" ) type Company struct { Name string `json:"name" yaml:"name"` NIF string `json:"nif" yaml:"nif"` } // 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 Company `json:"developer" yaml:"developer"` CertNo int `json:"certNo" yaml:"certNo"` State string `json:"state" yaml:"state"` 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) }