builder

package
v0.1.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	// Titles is a required field.
	// It is required to have the same length of titles as there are languages in the presentation.
	Titles map[Language]string

	// Optional defines if the Element is an optional field - which means it could have empty values.
	Optional bool

	// Format is not a required field.
	// There is no default value.
	Format ElementFormat

	// Multilanguage is not a required field.
	// Default value is false.
	Multilanguage bool

	// Value is a required field if Multilanguage is set to false.
	// It requires a pointer to a field in payload.
	//
	// Example value would be "/issuanceDate"
	Value string

	// Values is a required field if Multilanguage is set to true.
	// It requires a pointer to a field in payload.
	//
	// Example value for en would be "/issuer/legalName/en"
	Values map[Language]string
}

func (*Element) NewElement

func (e *Element) NewElement(titles map[Language]string) (*Element, error)

func (*Element) TitleContainsAllLanguages

func (e *Element) TitleContainsAllLanguages(existingLanguages []Language) bool

type ElementFormat

type ElementFormat struct {
	Type FormatType `json:"-"` // Don't serialize this field
}

ElementFormat represents the format configuration for an element

func NewDateFormat added in v0.1.29

func NewDateFormat() ElementFormat

NewDateFormat creates a new Date format

func NewDateTimeFormat

func NewDateTimeFormat() ElementFormat

NewDateTimeFormat creates a new DateTime format

func NewDurationFormat

func NewDurationFormat() ElementFormat

NewDurationFormat creates a new Duration format

func NewJpegFormat added in v0.1.23

func NewJpegFormat() ElementFormat

NewJpegFormat creates a new format for displaying base64 jpeg image

func NewPngFormat added in v0.1.23

func NewPngFormat() ElementFormat

NewPngFormat creates a new format for displaying base64 png image

func (*ElementFormat) IsEmpty

func (f *ElementFormat) IsEmpty() bool

IsEmpty returns true if the format is not set

func (*ElementFormat) MarshalJSON

func (f *ElementFormat) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface This ensures that ElementFormat serializes as a simple string value

func (*ElementFormat) String

func (f *ElementFormat) String() string

String returns the string representation of the format

func (*ElementFormat) UnmarshalJSON

func (f *ElementFormat) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type FormatType

type FormatType string

FormatType represents the type of format for an element

const (
	FormatDate     FormatType = "date"
	FormatDateTime FormatType = "date-time"
	FormatDuration FormatType = "duration"
	FormatJPEG     FormatType = "jpeg"
	FormatPNG      FormatType = "png"
)

type Group

type Group struct {
	ID       uint
	Titles   map[Language]string
	Elements []Element
}

func NewGroup

func NewGroup(elements []Element, id uint, titles map[Language]string) (*Group, error)

NewGroup creates a new Group with validation

func (*Group) Validate

func (g *Group) Validate() error

type Language

type Language struct {
	Code string
}

func NewLanguage

func NewLanguage(code string) (*Language, error)

NewLanguage creates a new Language with validation

func (Language) GetName

func (l Language) GetName() string

func (Language) IsValid

func (l Language) IsValid() bool

func (Language) Validate

func (l Language) Validate() error

Validate validates the language Code and returns an error if invalid

type Presentation

type Presentation struct {
	Languages []Language
	Groups    []Group

	Title       map[Language]string
	Description map[Language]string

	ExpirationDate string

	Issuer                string
	IssuerLogoContentType string
}

func (*Presentation) Create

func (p *Presentation) Create() ([]byte, error)

func (*Presentation) ValidateElement

func (p *Presentation) ValidateElement(element *Element) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL