Documentation
¶
Index ¶
- Constants
- func CustomValidators() map[string]validator.Func
- func MarshallCgSaveGame(sg *CgSavegame) (string, error)
- func UnitForAbas(unit string) string
- type CgArticle
- type CgArticleList
- type CgColorOptionList
- type CgConfiguration
- type CgItemList
- type CgLength
- type CgMitercut
- type CgOption
- type CgPackagingUnit
- type CgPackagingUnitList
- type CgQuantity
- type CgSavegame
- type CgSystem
- type CgSystemList
- type CgTechnicOptionList
- type CgVersion
- type CgWidth
- type Sopl
- type SoplContainer
- type SoplExchangeFormat
- type SoplProduct
- type SoplSystem
- type SoplValidatorStruct
- type SoplVersion
Constants ¶
const CurrentSoplVersion = Version20
CurrentSoplVersion is the current SOPL format version Bump this when the format changes
Variables ¶
This section is empty.
Functions ¶
func CustomValidators ¶ added in v1.2.0
func CustomValidators() map[string]validator.Func
CustomValidators returns a map of tags to custom validator functions
func MarshallCgSaveGame ¶
func MarshallCgSaveGame(sg *CgSavegame) (string, error)
Types ¶
type CgArticle ¶
type CgArticle struct { Number string `xml:"number,attr"` Unit string `xml:"unit,attr"` Quantity CgQuantity `xml:"Quantity"` Length *CgLength `xml:"Length,omitempty"` Mitercut *CgMitercut `xml:"MiterCut,omitempty"` Width *CgWidth `xml:"Width,omitempty"` TechnicOptions CgTechnicOptionList `xml:"TechOptions,omitempty"` ColorOptions CgColorOptionList `xml:"ColorOptions,omitempty"` }
type CgColorOptionList ¶
type CgColorOptionList struct {
Options []CgOption `xml:"Option,omitempty"`
}
func (CgColorOptionList) Concat ¶
func (c CgColorOptionList) Concat(sep rune) string
func (CgColorOptionList) String ¶
func (c CgColorOptionList) String() string
type CgConfiguration ¶
type CgConfiguration struct { XMLName xml.Name `xml:"Configuration"` Version string `xml:"Version"` Raw []byte `xml:",innerxml"` // ignore, we are only interested in the article list }
CgConfiguration contains data used by the Clockstone configurator. The only useful field in the configuration data is the Version field that specifies the configurator version that was used.
func (CgConfiguration) GetVersion ¶ added in v1.0.2
func (c CgConfiguration) GetVersion() (CgVersion, error)
func (CgConfiguration) MarshalXML ¶ added in v1.0.2
func (c CgConfiguration) MarshalXML(e *xml.Encoder, start xml.StartElement) error
type CgItemList ¶
type CgItemList struct { XMLName xml.Name `xml:"ItemList"` SystemList CgSystemList `xml:"SystemList"` SaveDataVersion string `xml:"saveDataVersion,attr"` }
type CgLength ¶
type CgMitercut ¶ added in v1.0.3
type CgPackagingUnit ¶
type CgPackagingUnit struct { Number string `xml:"number,attr"` ArticleList CgArticleList `xml:"ArticleList"` }
type CgPackagingUnitList ¶
type CgPackagingUnitList struct {
PackagingUnits []CgPackagingUnit `xml:"PackagingUnit"`
}
type CgQuantity ¶
type CgSavegame ¶
type CgSavegame struct { XMLName xml.Name `xml:"ProlichtConfiguration"` Configuration CgConfiguration `xml:"Configuration"` ItemList CgItemList `xml:"ItemList"` }
CgSavegame is the root element (ProlichtConfiguration)
func ConvertFromOldSOPLFormat ¶ added in v1.0.4
func ConvertFromOldSOPLFormat(soplString string) (*CgSavegame, error)
ConvertFromOldSOPLFormat converts AFL(SOPL) strings to 3D configurator save-games
func UnmarshallCgSaveGame ¶
func UnmarshallCgSaveGame(xmlReader io.Reader) (*CgSavegame, error)
type CgSystem ¶
type CgSystem struct { Number string `xml:"number,attr"` Info string `xml:"Info"` DatabaseID string `xml:"DatabaseID"` RowID string `xml:"RowID"` RecordID string `xml:"RecordID"` IsValid bool `xml:"IsValid"` PackagingUnitList CgPackagingUnitList }
func (*CgSystem) ConvertToOldSOPLFormat ¶
ConvertToOldSOPLFormat generates the old import format: minimum fields lenght is 11 (legacy format without yaxisy... and yaxisx...) newer records include additional 4 fields example line: 1~~100-2075~0~m~~~~~~
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
U|xtstufe'~'U|hauptartikel'~'U|artex'~'U|mge'~'U|he'~'U|laenge'~'U|le'~'U|breite'~'U|be'~'U|technicoption'~'U|coloroption'~'U|yaxisybegin'~'U|yaxisyend'~'U|yaxiszbegin'~'U|yaxiszend
type CgTechnicOptionList ¶
type CgTechnicOptionList struct {
Options []CgOption `xml:"Option,omitempty"`
}
func (CgTechnicOptionList) Concat ¶
func (t CgTechnicOptionList) Concat(sep rune) string
func (CgTechnicOptionList) String ¶
func (t CgTechnicOptionList) String() string
type CgVersion ¶ added in v1.0.2
CgVersion represents a version string in semantic versioning schema (https://semver.org/lang/de/)
func VersionFromComparableString ¶ added in v1.0.2
VersionFromComparableString parses a given string and returns the corresponding version. Check the ComparableString() method for the accepted version format. For example:
String: 003.001.000.0123 Version: 3.1.0+123 String: 003.000.000.0123 Version: 3.0.0+123 String: 003.000.000.0005 Version: 3.0.0+5 String: 3.0.0.5 Version: 3.0.0+5
func VersionFromConfiguratorStyle ¶ added in v1.0.2
VersionFromConfiguratorStyle parses the given version string into a CgVersion struct. The given string mus comply with the Clockstone version format.
func (CgVersion) ComparableVersion ¶ added in v1.0.2
ComparableVersion returns a string representation of the version that is easily comparable via string comparison.
func (CgVersion) Compare ¶ added in v1.0.2
Compare compares the given version with another version. It returns: 1 when the other version is older -1 when the other version is newer 0 if the versions are the same
func (CgVersion) SemanticVersion ¶ added in v1.0.2
SemanticVersion formats the version number according to the semantic version schema rules (https://semver.org/lang/de/)
type CgWidth ¶
type Sopl ¶ added in v1.1.0
type Sopl struct { Version SoplVersion `yaml:"version" json:"version" validate:"sopl_version"` Systems []*SoplSystem `yaml:"systems" json:"systems" validate:"dive"` FromFormat SoplExchangeFormat `yaml:"-" json:"-" validate:"sys_sku_format_dependent"` }
Sopl (and its nested structs) is the struct that represents the SOPL file as defined on https://devdocs.prolicht.digital/en/projects/abas/sales/sopl-format#version-20
func FromAfl ¶ added in v1.1.0
FromAfl creates a new Sopl struct from a afl byte array
func FromXml ¶ added in v1.1.0
FromXml creates a new Sopl struct from a xml byte array
func FromYaml ¶ added in v1.1.0
FromYaml creates a new Sopl struct from a yaml byte array, optionally validate it
func (*Sopl) ToAfl ¶ added in v1.1.0
ToAfl creates a afl byte array from the Sopl struct
func (*Sopl) ToXml ¶ added in v1.1.0
ToXml creates a xml byte array from the Sopl struct
type SoplContainer ¶ added in v1.1.0
type SoplContainer struct { SKU string `yaml:"sku" json:"sku" validate:"required,sku"` Products []*SoplProduct `yaml:"products" json:"products" validate:"dive"` Quantity int `yaml:"quantity,omitempty" json:"quantity,omitempty" validate:"required,gte=1"` }
type SoplExchangeFormat ¶ added in v1.1.0
type SoplExchangeFormat string
const ( FormatXML SoplExchangeFormat = "xml" // configurator savegame FormatAFL SoplExchangeFormat = "afl" // old SOPL string FormatYAML SoplExchangeFormat = "yml" // new SOPL representation FormatUnknown SoplExchangeFormat = "unk" // unknown format )
func GuessSoplExchangeFormat ¶ added in v1.1.0
func GuessSoplExchangeFormat(data []byte) SoplExchangeFormat
GuessSoplExchangeFormat tries to derive the exchange format (old AFL, Configurator Savegame XML or YAML) from the given input. If no valid format was detected, FormatUnknown will be returned.
type SoplProduct ¶ added in v1.1.0
type SoplProduct struct { SKU string `yaml:"sku" json:"sku" validate:"required,sku"` EncryptedSKU string `yaml:"encrypted_sku,omitempty" json:"encrypted_sku,omitempty" validate:"enc_sku"` ColorOptions map[int]string `yaml:"color_options,omitempty" json:"color_options,omitempty" validate:"color_options"` TechnicOptions map[int]string `yaml:"technic_options,omitempty" json:"technic_options,omitempty" validate:"technic_options"` Quantity float64 `yaml:"quantity" json:"quantity" validate:"gte=0"` QuantityUnit string `yaml:"quantity_unit" json:"quantity_unit" validate:"required_with=Quantity"` Length float64 `yaml:"length,omitempty" json:"length,omitempty" validate:"gte=0.0"` LengthUnit string `yaml:"length_unit,omitempty" json:"length_unit,omitempty" validate:"required_with=Length"` SalesPriceUnit string `yaml:"sales_price_unit,omitempty" json:"sales_price_unit,omitempty"` MitercutYStart float64 `yaml:"mitercut_y_start,omitempty" json:"mitercut_y_start,omitempty" validate:"gte=-90.0,lte=90.0"` MitercutYEnd float64 `yaml:"mitercut_y_end,omitempty" json:"mitercut_y_end,omitempty" validate:"gte=-90.0,lte=90.0"` MitercutZStart float64 `yaml:"mitercut_z_start,omitempty" json:"mitercut_z_start,omitempty" validate:"gte=-90.0,lte=90.0"` MitercutZEnd float64 `yaml:"mitercut_z_end,omitempty" json:"mitercut_z_end,omitempty" validate:"gte=-90.0,lte=90.0"` Price float64 `yaml:"price" json:"price" validate:"gte=0.0"` MinimumPrice float64 `yaml:"minimum_price" json:"minimum_price" validate:"gte=0.0"` TechOptionSurcharge float64 `yaml:"tech_option_surcharge,omitempty" json:"tech_option_surcharge,omitempty" validate:"gte=0.0"` ColorOptionSurcharge float64 `yaml:"color_option_surcharge,omitempty" json:"color_option_surcharge,omitempty" validate:"gte=0.0"` }
func (SoplProduct) ColorOptionString ¶ added in v1.1.1
func (s SoplProduct) ColorOptionString(separator string) string
func (SoplProduct) TechnicOptionString ¶ added in v1.1.1
func (s SoplProduct) TechnicOptionString(separator string) string
type SoplSystem ¶ added in v1.1.0
type SoplSystem struct { SKU string `yaml:"sku" json:"sku"` Containers []*SoplContainer `yaml:"containers" json:"containers" validate:"dive"` }
type SoplValidatorStruct ¶ added in v1.1.8
type SoplValidatorStruct struct {
// contains filtered or unexported fields
}
type SoplVersion ¶ added in v1.1.0
type SoplVersion string
const ( VersionUnknown SoplVersion = "" Version10 SoplVersion = "1.0" Version15 SoplVersion = "1.5" Version20 SoplVersion = "2.0" )
A list of supported versions.
func GuessSoplVersion ¶ added in v1.1.0
func GuessSoplVersion(data []byte) SoplVersion
GuessSoplVersion guesses the SOPL format version for the given input data. If no version could be detected, an empty string is returned.