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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cf0e67a3baf8adb2febaabec358bc95bdbb4bd05b22a9cd3f73f2b3438690ab
4
- data.tar.gz: 28004b92b73f486f1f7a4cdc9a182989bb6b89ee0cb440d88b9cf972e35c82f5
3
+ metadata.gz: 9b669c1e292e83f5cd4ade218b5746fd43d510992f5a5b2ef8db6c0fa50d8799
4
+ data.tar.gz: a188b10e541fc0c5d471b872c20c2cc15a0852c95bea444da8d0bd2b179c2dc1
5
5
  SHA512:
6
- metadata.gz: f175e08b3de73132ac2b5893ae66e7f6e2312e76fa1018a0ea5a319f65f3a707ed9e8d01169e71e40eca42d5e1d5bcf52610c522cb905be631536924027b8e9c
7
- data.tar.gz: 8d41d5c53012d6e3aff9d830283026762e30e81d87b289e559fde21377660090108ae1c14a84fa59d544fced6a8729aab01f1f6b4670668bcd13e3855d9f681c
6
+ metadata.gz: d320bd149716475e1be084bede6a3443a53263cfb77df1a8f163f8257465f9422d71ca7149447a769bf1860efe3ceb95f38e5b2a0a3ac3b993565d7abfa7e9b9
7
+ data.tar.gz: 5d68eea1cdb86d0c2383881f4a334c8952650513c51aa883e06f2290fd366a9758fae12503d270350b40390102e3009b8c878b1d15150f1585663c178508dd01
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Changelog
2
2
 
3
+ ## [1.1.0] - 2023-01-24
4
+ - Add support for @mentions
5
+
3
6
  ## [1.0.0] - 2022-09-02
4
7
 
5
8
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- msteams_hermes (1.0.0)
4
+ msteams_hermes (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/complex_example.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "msteams_hermes/actions/open_url"
@@ -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
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "msteams_hermes/components/base"
4
-
5
3
  module MsTeamsHermes
6
4
  ##
7
5
  # Module containing Microsoft's components representations
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MsTeamsHermes
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  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.0.0
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: 2022-11-01 00:00:00.000000000 Z
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.2.33
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.