Module: Legion::Extensions::MicrosoftTeams::Runners::AdaptiveCards
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/microsoft_teams/runners/adaptive_cards.rb
Instance Method Summary collapse
- #action_open_url(title:, url:) ⇒ Object
- #action_submit(title:, data: {}) ⇒ Object
- #build_card(body:, actions: [], version: '1.4') ⇒ Object
- #fact_set(facts:) ⇒ Object
- #message_attachment(card:) ⇒ Object
- #text_block(text:, size: 'default', weight: 'default', wrap: true) ⇒ Object
Instance Method Details
#action_open_url(title:, url:) ⇒ Object
35 36 37 |
# File 'lib/legion/extensions/microsoft_teams/runners/adaptive_cards.rb', line 35 def action_open_url(title:, url:, **) { result: { type: 'Action.OpenUrl', title: title, url: url } } end |
#action_submit(title:, data: {}) ⇒ Object
39 40 41 |
# File 'lib/legion/extensions/microsoft_teams/runners/adaptive_cards.rb', line 39 def action_submit(title:, data: {}, **) { result: { type: 'Action.Submit', title: title, data: data } } end |
#build_card(body:, actions: [], version: '1.4') ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/legion/extensions/microsoft_teams/runners/adaptive_cards.rb', line 8 def build_card(body:, actions: [], version: '1.4', **) card = { '$schema' => 'http://adaptivecards.io/schemas/adaptive-card.json', 'type' => 'AdaptiveCard', 'version' => version, 'body' => body } card['actions'] = actions unless actions.empty? { result: card } end |
#fact_set(facts:) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/legion/extensions/microsoft_teams/runners/adaptive_cards.rb', line 26 def fact_set(facts:, **) { result: { type: 'FactSet', facts: facts.map { |title, value| { title: title.to_s, value: value.to_s } } } } end |
#message_attachment(card:) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/legion/extensions/microsoft_teams/runners/adaptive_cards.rb', line 43 def (card:, **) { result: { contentType: 'application/vnd.microsoft.card.adaptive', contentUrl: nil, content: card } } end |
#text_block(text:, size: 'default', weight: 'default', wrap: true) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/legion/extensions/microsoft_teams/runners/adaptive_cards.rb', line 19 def text_block(text:, size: 'default', weight: 'default', wrap: true, **) block = { type: 'TextBlock', text: text, wrap: wrap } block[:size] = size unless size == 'default' block[:weight] = weight unless weight == 'default' { result: block } end |