adaptivecards

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeAdaptiveCard = "AdaptiveCard"
	SchemaURL        = "http://adaptivecards.io/schemas/adaptive-card.json"
	SchemaVersion13  = "1.3"
)
View Source
const (
	ElementTypeImage         = "Image"
	ElementTypeMedia         = "Media"
	ElementTypeRichTextBlock = "RichTextBlock"
	ElementTypeTextBlock     = "TextBlock"
	ElementTypeTextRun       = "TextRun"
)
View Source
const (
	TextInputStyleText  TextInputStyle = "text"
	TextInputStyleTel                  = "tel"
	TextInputStyleURL                  = "url"
	TextInputStyleEmail                = "email"
)
View Source
const (
	ImageFillModeCover              ImageFillMode = "covers"
	ImageFillModeRepeatHorizontally               = "repeatHorizontally"
	ImageFillModeRepeatVertically                 = "repeatVertically"
	ImageFillModeRepeat                           = "repeat"
)
View Source
const (
	TypeActionOpenUrl = "Action.OpenUrl"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	Action() string
}

type ActionOpenUrl

type ActionOpenUrl struct {
	Type  string `json:"type,omitempty"`
	Title string `json:"title,omitempty"`
	URL   string `json:"url,omitempty"`
}

func NewActionOpenUrl

func NewActionOpenUrl(url, title string) ActionOpenUrl

func (ActionOpenUrl) Action

func (action ActionOpenUrl) Action() string

type AdaptiveCard

type AdaptiveCard struct {
	Type         string   `json:"type"`
	Version      string   `json:"version"`
	Body         Elements `json:"body,omitempty"`
	Actions      []Action `json:"actions,omitempty"`
	FallbackText string   `json:"fallbackText,omitempty"`
	Lang         string   `json:"lang,omitempty"`
	MinHeight    string   `json:"minHeight,omitempty"`
	Schema       string   `json:"$schema,omitempty"`
	Speak        string   `json:"speak,omitempty"`
}

func NewAdaptiveCard

func NewAdaptiveCard() *AdaptiveCard

func Parse added in v0.3.0

func Parse(card []byte) (*AdaptiveCard, error)

func ReadFile added in v0.3.0

func ReadFile(filename string) (*AdaptiveCard, error)

func (*AdaptiveCard) Inflate

func (card *AdaptiveCard) Inflate(makeVisible bool)

type BackgroundImage

type BackgroundImage struct {
	URL      string        `json:"url"`
	FillMode ImageFillMode `json:"value"`
}

type BlockElementHeight

type BlockElementHeight string
const (
	BlockElementHeightAuto    BlockElementHeight = "auto"
	BlockElementHeightStretch BlockElementHeight = "stretch"
)

type ChoiceInputStyle

type ChoiceInputStyle string
const (
	ChoiceInputStyleCompact  ChoiceInputStyle = "compact"
	ChoiceInputStyleExpanded                  = "expanded"
)

type Colors

type Colors string
const (
	ColorDefault   Colors = ""
	ColorDark      Colors = "Dark"
	ColorLight     Colors = "Light"
	ColorAccent    Colors = "Accent"
	ColorGood      Colors = "Good"
	ColorWarning   Colors = "Warning"
	ColorAttention Colors = "Attention"
)

type Element

type Element interface {
	ElementID() string
	GetType() string
	SetVisibility(visiblity bool)
}

type ElementImage

type ElementImage struct {
	AltText             string              `json:"altText,omitempty"`
	BackgroundColor     string              `json:"backgroundColor,omitempty"`
	Height              string              `json:"height,omitempty"`
	HorizontalAlignment HorizontalAlignment `json:"horizontalAlignment,omitempty"`
	SelectAction        ISelectAction       `json:"selectAction,omitempty"`
	Size                ImageSize           `json:"size,omitempty"`
	Style               ImageStyle          `json:"style,omitempty"`
	Type                string              `json:"type"`
	URL                 string              `json:"url,omitempty"`
	Width               string              `json:"width,omitempty"`

	Fallback  ElementOrFallbackOption `json:"fallback,omitempty"`
	ID        string                  `json:"id,omitempty"`
	IsVisible bool                    `json:"isVisible"`
	Requires  map[string]string       `json:"requires,omitempty"`
	Separator bool                    `json:"separator,omitempty"`
	Spacing   Spacing                 `json:"spacing,omitempty"`
}

func (ElementImage) ElementID

func (el ElementImage) ElementID() string

func (ElementImage) FallbackOption

func (el ElementImage) FallbackOption() bool

func (ElementImage) GetType added in v0.2.4

func (el ElementImage) GetType() string

func (ElementImage) SetVisibility added in v0.2.4

func (el ElementImage) SetVisibility(visible bool)

type ElementMedia

type ElementMedia struct {
	Type    string               `json:"type"`
	AltText string               `json:"altText,omitempty"`
	Poster  string               `json:"poster,omitempty"`
	Sources []ElementMediaSource `json:"sources,omitempty"`

	Fallback  ElementOrFallbackOption `json:"fallback,omitempty"`
	Height    BlockElementHeight      `json:"height,omitempty"`
	ID        string                  `json:"id,omitempty"`
	IsVisible bool                    `json:"isVisible"`
	Separator bool                    `json:"separator,omitempty"`
	Spacing   Spacing                 `json:"spacing,omitempty"`
}

func (ElementMedia) ElementID

func (el ElementMedia) ElementID() string

func (ElementMedia) FallbackOption

func (el ElementMedia) FallbackOption() bool

func (ElementMedia) GetType added in v0.2.5

func (el ElementMedia) GetType() string

func (ElementMedia) SetVisibility added in v0.2.4

func (el ElementMedia) SetVisibility(visible bool)

type ElementMediaSource

type ElementMediaSource struct {
	MimeType string `json:"mimeType,omitempty"`
	URL      string `json:"url,omitempty"`
}

type ElementOrFallbackOption

type ElementOrFallbackOption interface {
	ElementID() string
	FallbackOption() bool
}

type ElementTextBlock

type ElementTextBlock struct {
	Type                string              `json:"type"`
	Text                string              `json:"text"`
	Color               Colors              `json:"color,omitempty"`
	FontType            FontType            `json:"fontType,omitempty"`
	HorizontalAlignment HorizontalAlignment `json:"horizontalAlignment,omitempty"`
	IsSubtle            bool                `json:"isSubtle,omitempty"`
	MaxLines            int                 `json:"maxLines,omitempty"`
	Size                FontSize            `json:"size,omitempty"`
	Weight              FontWeight          `json:"weight,omitempty"`
	Wrap                bool                `json:"wrap,omitempty"`

	Fallback  ElementOrFallbackOption `json:"fallback,omitempty"`
	Height    BlockElementHeight      `json:"height,omitempty"`
	ID        string                  `json:"id,omitempty"`
	IsVisible bool                    `json:"isVisible"`
	Separator bool                    `json:"separator,omitempty"`
	Spacing   Spacing                 `json:"spacing,omitempty"`
	Requires  map[string]string       `json:"requires,omitempty"`
	Width     string                  `json:"width,omitempty"`
}

func (ElementTextBlock) ElementID

func (el ElementTextBlock) ElementID() string

func (ElementTextBlock) FallbackOption

func (el ElementTextBlock) FallbackOption() bool

func (ElementTextBlock) GetType added in v0.2.4

func (el ElementTextBlock) GetType() string

func (ElementTextBlock) SetVisibility added in v0.2.4

func (el ElementTextBlock) SetVisibility(visible bool)

type ElementTextRun

type ElementTextRun struct {
	Type          string        `json:"type"`
	Text          string        `json:"text"`
	Color         Colors        `json:"color,omitempty"`
	FontType      FontType      `json:"fontType,omitempty"`
	Highlight     bool          `json:"highlight,omitempty"`
	IsSubtle      bool          `json:"isSubtle,omitempty"`
	Italic        bool          `json:"italic,omitempty"`
	SelectAction  ISelectAction `json:"selectAction,omitempty"`
	Size          FontSize      `json:"fontSize,omitempty"`
	Strikethrough bool          `json:"strikethrough,omitempty"`
	Underline     bool          `json:"underline,omitempty"`
	Weight        FontWeight    `json:"fontWeight,omitempty"`
}

type Elements added in v0.3.0

type Elements []Element

func (*Elements) UnmarshalJSON added in v0.3.0

func (els *Elements) UnmarshalJSON(data []byte) error

type FontSize

type FontSize string
const (
	FontSizeDefault    FontSize = ""
	FontSizeSmall      FontSize = "Small"
	FontSizeMedium     FontSize = "Medium"
	FontSizeLarge      FontSize = "Large"
	FontSizeExtraLarge FontSize = "ExtraLarge"
)

type FontType

type FontType string
const (
	FontTypeDefault   FontType = ""
	FontTypeMonospace FontType = "Monospace"
)

type FontWeight

type FontWeight string
const (
	FontWeightDefault FontWeight = ""
	FontWeightLighter FontWeight = "Lighter"
	FontWeightBolder  FontWeight = "Bolder"
)

type HorizontalAlignment

type HorizontalAlignment string

type ISelectAction

type ISelectAction string
const (
	ISelectActionOpenURL          ISelectAction = "Action.OpenUrl"
	ISelectActionSubmit           ISelectAction = "Action.Submit"
	ISelectActionToggleVisibility ISelectAction = "Action.ToggleVisibility"
)

type ImageFillMode

type ImageFillMode string

type ImageSize

type ImageSize string
const (
	HorizontalAlignmentLeft   ImageSize = "left"
	HorizontalAlignmentCenter ImageSize = "center"
	HorizontalAlignmentRight  ImageSize = "right"
)
const (
	ImageSizeAuto    ImageSize = "auto"
	ImageSizeStretch ImageSize = "stretch"
	ImageSizeSmall   ImageSize = "small"
	ImageSizeMedium  ImageSize = "medium"
	ImageSizeLarge   ImageSize = "large"
)
const (
	ImageSizeDefault ImageSize = "default"
	ImageSizePerson  ImageSize = "person"
)

type ImageStyle

type ImageStyle string

type InputChoice

type InputChoice struct {
	Title string `json:"title"`
	Value string `json:"value"`
}

type InputChoiceSet

type InputChoiceSet struct {
	Type          string        `json:"type"` // must be "Input.Date"
	Choices       []InputChoice `json:"choices"`
	ID            string        `json:"id"`
	IsMultiSelect bool          `json:"isMultiSelect,omitempty"`
	Style         string        `json:"style,omitempty"`
	Value         string        `json:"value,omitempty"`
	Placeholder   string        `json:"placeholder,omitempty"`
	Wrap          bool          `json:"wrap,omitempty"`

	ErrorMessage string                  `json:"errorMessage,omitempty"`
	IsRequired   bool                    `json:"isRequired"`
	Label        string                  `json:"label,omitempty"`
	Fallback     ElementOrFallbackOption `json:"fallback,omitempty"`
	Height       BlockElementHeight      `json:"height,omitempty"`
	Separator    bool                    `json:"separator,omitempty"`
	Spacing      Spacing                 `json:"spacing,omitempty"`
	IsVisible    bool                    `json:"isVisible"`
	Requires     map[string]string       `json:"requires,omitempty"`
}

type InputDate

type InputDate struct {
	Type        string `json:"type"` // must be "Input.Date"
	ID          string `json:"id"`
	Max         string `json:"max,omitempty"`
	Min         string `json:"min,omitempty"`
	Placeholder string `json:"placeholder,omitempty"`
	Value       string `json:"value,omitempty"`

	ErrorMessage string                  `json:"errorMessage,omitempty"`
	IsRequired   bool                    `json:"isRequired"`
	Label        string                  `json:"label,omitempty"`
	Fallback     ElementOrFallbackOption `json:"fallback,omitempty"`
	Height       BlockElementHeight      `json:"height,omitempty"`
	Separator    bool                    `json:"separator,omitempty"`
	Spacing      Spacing                 `json:"spacing,omitempty"`
	IsVisible    bool                    `json:"isVisible"`
	Requires     map[string]string       `json:"requires,omitempty"`
}

type InputNumber

type InputNumber struct {
	Type        string `json:"type"` // must be "Input.Date"
	ID          string `json:"id"`
	Max         int    `json:"max,omitempty"`
	Min         int    `json:"min,omitempty"`
	Placeholder string `json:"placeholder,omitempty"`
	Value       int    `json:"value,omitempty"`

	ErrorMessage string                  `json:"errorMessage,omitempty"`
	IsRequired   bool                    `json:"isRequired"`
	Label        string                  `json:"label,omitempty"`
	Fallback     ElementOrFallbackOption `json:"fallback,omitempty"`
	Height       BlockElementHeight      `json:"height,omitempty"`
	Separator    bool                    `json:"separator,omitempty"`
	Spacing      Spacing                 `json:"spacing,omitempty"`
	IsVisible    bool                    `json:"isVisible"`
	Requires     map[string]string       `json:"requires,omitempty"`
}

type InputText

type InputText struct {
	Type         string         `json:"type"` // must be "Input.Date"
	ID           string         `json:"id"`
	IsMultiline  string         `json:"isMultiline,omitempty"`
	MaxLength    int            `json:"maxLength,omitempty"`
	Placeholder  string         `json:"placeholder,omitempty"`
	Regex        string         `json:"regex,omitempty"`
	Style        TextInputStyle `json:"style,omitempty"`
	InlineAction ISelectAction  `json:"inlineAction,omitempty"`
	Value        string         `json:"value,omitempty"`

	ErrorMessage string                  `json:"errorMessage,omitempty"`
	IsRequired   bool                    `json:"isRequired"`
	Label        string                  `json:"label,omitempty"`
	Fallback     ElementOrFallbackOption `json:"fallback,omitempty"`
	Height       BlockElementHeight      `json:"height,omitempty"`
	Separator    bool                    `json:"separator,omitempty"`
	Spacing      Spacing                 `json:"spacing,omitempty"`
	IsVisible    bool                    `json:"isVisible"`
	Requires     map[string]string       `json:"requires,omitempty"`
}

type InputTime

type InputTime struct {
	Type        string `json:"type"` // must be "Input.Date"
	ID          string `json:"id"`
	Max         string `json:"max,omitempty"`
	Min         string `json:"min,omitempty"`
	Placeholder string `json:"placeholder,omitempty"`
	Value       string `json:"value,omitempty"`

	ErrorMessage string                  `json:"errorMessage,omitempty"`
	IsRequired   bool                    `json:"isRequired"`
	Label        string                  `json:"label,omitempty"`
	Fallback     ElementOrFallbackOption `json:"fallback,omitempty"`
	Height       BlockElementHeight      `json:"height,omitempty"`
	Separator    bool                    `json:"separator,omitempty"`
	Spacing      Spacing                 `json:"spacing,omitempty"`
	IsVisible    bool                    `json:"isVisible"`
	Requires     map[string]string       `json:"requires,omitempty"`
}

type InputToggle

type InputToggle struct {
	Type     string `json:"type"` // must be "Input.Date"
	Title    string `json:"title"`
	ID       string `json:"id"`
	Value    string `json:"value,omitempty"`
	ValueOff string `json:"valueOff,omitempty"`
	ValueOn  string `json:"valueOn,omitempty"`
	Wrap     string `json:"wrap,omitempty"`

	ErrorMessage string                  `json:"errorMessage,omitempty"`
	IsRequired   bool                    `json:"isRequired"`
	Label        string                  `json:"label,omitempty"`
	Fallback     ElementOrFallbackOption `json:"fallback,omitempty"`
	Height       BlockElementHeight      `json:"height,omitempty"`
	Separator    bool                    `json:"separator,omitempty"`
	Spacing      Spacing                 `json:"spacing,omitempty"`
	IsVisible    bool                    `json:"isVisible"`
	Requires     map[string]string       `json:"requires,omitempty"`
}

type Spacing

type Spacing string
const (
	SpacingDefault    Spacing = "default"
	SpacingNone       Spacing = "none"
	SpacingSmall      Spacing = "small"
	SpacingMedium     Spacing = "medium"
	SpacingLarge      Spacing = "large"
	SpacingExtraLarge Spacing = "extraLarge"
	SpacingPadding    Spacing = "padding"
)

type TextInputStyle

type TextInputStyle string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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