adaptivecards

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: MIT Imports: 1 Imported by: 1

README

Go SDK for Authoring AdaptiveCards

Build Status Go Report Card Docs License

Golang implementation of AdaptiveCards.

Schema

The following have been implemented.

  • Cards
    • AdaptiveCard
  • Card Elements
    • TextBlock
    • Image
    • Media
    • MediaSource
    • RichTextBlock
    • TextRun
  • Containers
    • ActionSet
    • Container
    • ColumnSet
    • Column
    • FactSet
    • Fact
    • ImageSet
  • Actions
    • Action.OpenUrl
    • Action.Submit
    • Action.ShowCard
    • Action.ToggleVisibility
    • TargetElement
    • Action.Execute
  • Inputs
    • Input.Text
    • Input.Numbers
    • Input.Date
    • Input.Time
    • Input.Toggle
    • Input.ChoiceSet
    • Input.Choice
  • Types
    • BackgroundImage
    • Refresh
    • Authentication
    • TokenExchangeResource
    • AuthCardButton

Documentation

Index

Constants

View Source
const (
	TypeAdaptiveCard = "AdaptiveCard"
	SchemaURL        = "http://adaptivecards.io/schemas/adaptive-card.json"
	SchemaVersion13  = "1.3"
)
View Source
const (
	ColorDefault   Colors = "default"
	ColorDark             = "dark"
	ColorLight            = "light"
	ColorAccent           = "accent"
	ColorGood             = "good"
	ColorWarning          = "warning"
	ColorAttention        = "attention"
)
View Source
const (
	FontSizeDefault    FontType = ""
	FontSizeSmall               = "Small"
	FontSizeMedium              = "Medium"
	FontSizeLarge               = "Large"
	FontSizeExtraLarge          = "ExtraLarge"
)
View Source
const (
	FontWeightDefault FontWeight = ""
	FontWeightLighter            = "Lighter"
	FontWeightBolder             = "Bolder"
)
View Source
const (
	HorizontalAlignmentLeft   ImageSize = "left"
	HorizontalAlignmentCenter           = "center"
	HorizontalAlignmentRight            = "right"
)
View Source
const (
	ISelectActionOpenURL          ISelectAction = "Action.OpenUrl"
	ISelectActionSubmit                         = "Action.Submit"
	ISelectActionToggleVisibility               = "Action.ToggleVisibility"
)
View Source
const (
	ImageSizeAuto    ImageSize = "auto"
	ImageSizeStretch           = "stretch"
	ImageSizeSmall             = "small"
	ImageSizeMedium            = "medium"
	ImageSizeLarge             = "large"
)
View Source
const (
	SpacingDefault    Spacing = "default"
	SpacingNone               = "none"
	SpacingSmall              = "small"
	SpacingMedium             = "medium"
	SpacingLarge              = "large"
	SpacingExtraLarge         = "extraLarge"
	SpacingPadding            = "padding"
)
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"
)
View Source
const (
	TypeTextBlock = "TextBlock"
)

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         []Element `json:"body"`
	Actions      []Action  `json:"actions"`
	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 (*AdaptiveCard) Inflate

func (card *AdaptiveCard) Inflate()

type BackgroundImage

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

type BlockElementHeight

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

type ChoiceInputStyle

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

type Colors

type Colors string

type Element

type Element interface {
	ElementID() string
}

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,omitoption"`
	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

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,omitoption"`
	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

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

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 FontSize

type FontSize string

type FontType

type FontType string
const (
	FontTypeDefault   FontType = "default"
	FontTypeMonospace          = "monospace"
)

type FontWeight

type FontWeight string

type HorizontalAlignment

type HorizontalAlignment string

type ISelectAction

type ISelectAction string

type ImageFillMode

type ImageFillMode string

type ImageSize

type ImageSize string
const (
	ImageSizeDefault ImageSize = "default"
	ImageSizePerson            = "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

type TextInputStyle

type TextInputStyle string

Jump to

Keyboard shortcuts

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