msteams_hermes 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/complex_example.rb +1 -1
- data/lib/msteams_hermes/components/adaptive_card.rb +7 -3
- data/lib/msteams_hermes/components/base.rb +0 -2
- data/lib/msteams_hermes/msteams/entities/base.rb +14 -0
- data/lib/msteams_hermes/msteams/entities/mention.rb +38 -0
- data/lib/msteams_hermes/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b669c1e292e83f5cd4ade218b5746fd43d510992f5a5b2ef8db6c0fa50d8799
|
4
|
+
data.tar.gz: a188b10e541fc0c5d471b872c20c2cc15a0852c95bea444da8d0bd2b179c2dc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d320bd149716475e1be084bede6a3443a53263cfb77df1a8f163f8257465f9422d71ca7149447a769bf1860efe3ceb95f38e5b2a0a3ac3b993565d7abfa7e9b9
|
7
|
+
data.tar.gz: 5d68eea1cdb86d0c2383881f4a334c8952650513c51aa883e06f2290fd366a9758fae12503d270350b40390102e3009b8c878b1d15150f1585663c178508dd01
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/complex_example.rb
CHANGED
@@ -12,14 +12,17 @@ module MsTeamsHermes
|
|
12
12
|
# https://adaptivecards.io/explorer/AdaptiveCard.html
|
13
13
|
##
|
14
14
|
class AdaptiveCard < Base
|
15
|
-
attr_reader :body, :actions
|
15
|
+
attr_reader :body, :actions, :entities
|
16
16
|
|
17
|
-
def initialize(body:, actions: nil)
|
17
|
+
def initialize(body:, actions: nil, entities: [])
|
18
18
|
@body = body
|
19
19
|
raise "AdaptiveCard `body` must be an Array" unless @body.is_a? Array
|
20
20
|
|
21
21
|
@actions = actions
|
22
22
|
raise "AdaptiveCard `actions` must be an Array" unless @actions.nil? || @actions.is_a?(Array)
|
23
|
+
|
24
|
+
@entities = entities
|
25
|
+
raise "AdaptiveCard `entities` must be an Array" unless @entities.nil? || @entities.is_a?(Array)
|
23
26
|
end
|
24
27
|
|
25
28
|
def to_hash
|
@@ -27,7 +30,8 @@ module MsTeamsHermes
|
|
27
30
|
type: "AdaptiveCard",
|
28
31
|
version: "1.5",
|
29
32
|
body: body.map(&:to_hash),
|
30
|
-
actions: actions&.map(&:to_hash)
|
33
|
+
actions: actions&.map(&:to_hash),
|
34
|
+
msteams: { entities: entities.map(&:to_hash) }
|
31
35
|
}
|
32
36
|
end
|
33
37
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MsTeamsHermes
|
4
|
+
module MsTeams
|
5
|
+
module Entities
|
6
|
+
# Super class for entities to enforce overridding the `to_hash` method
|
7
|
+
class Base
|
8
|
+
def to_hash
|
9
|
+
raise "Should be implemented on the subclass"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "msteams_hermes/msteams/entities/base"
|
4
|
+
|
5
|
+
module MsTeamsHermes
|
6
|
+
module MsTeams
|
7
|
+
module Entities
|
8
|
+
##
|
9
|
+
# A class representing Microsoft's Msteams.Mention object
|
10
|
+
# https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cconnector-html#user-mention-in-incoming-webhook-with-adaptive-cards
|
11
|
+
##
|
12
|
+
class Mention < Base
|
13
|
+
attr_reader :mention_reference, :mention_string, :user_id
|
14
|
+
|
15
|
+
def initialize(text:, name:, id:)
|
16
|
+
raise "`text` must be a string" unless text.is_a? String
|
17
|
+
raise "`text` must contain <at>...</at>" unless text.include?("<at>") && text.include?("</at>")
|
18
|
+
raise "`id` must be a string" unless text.is_a? String
|
19
|
+
|
20
|
+
@mention_reference = text # String surrounded by <at>string</at> that marks the mention section in a text
|
21
|
+
@mention_string = name # allows for overriding the mention_reference
|
22
|
+
@user_id = id
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_hash
|
26
|
+
{
|
27
|
+
type: "mention",
|
28
|
+
text: mention_reference,
|
29
|
+
mentioned: {
|
30
|
+
id: user_id,
|
31
|
+
name: mention_string
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msteams_hermes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Rocha
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem helps you sending messages to your Microsoft Teams channels.
|
14
14
|
With autonomy to create your own layouts, like UI kits such as React, Flutter, SwiftUI
|
@@ -45,6 +45,8 @@ files:
|
|
45
45
|
- lib/msteams_hermes/components/fact_set.rb
|
46
46
|
- lib/msteams_hermes/components/text_block.rb
|
47
47
|
- lib/msteams_hermes/message.rb
|
48
|
+
- lib/msteams_hermes/msteams/entities/base.rb
|
49
|
+
- lib/msteams_hermes/msteams/entities/mention.rb
|
48
50
|
- lib/msteams_hermes/style.rb
|
49
51
|
- lib/msteams_hermes/style/colors.rb
|
50
52
|
- lib/msteams_hermes/style/container_style.rb
|
@@ -75,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
77
|
- !ruby/object:Gem::Version
|
76
78
|
version: '0'
|
77
79
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
80
|
+
rubygems_version: 3.3.7
|
79
81
|
signing_key:
|
80
82
|
specification_version: 4
|
81
83
|
summary: Send messages to any Microsoft Teams' channel as easy as possible.
|