peoplegroup-connectors 0.1.93 → 0.1.96

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: bde60b43474978b4dd611f50d5778fc0467526a025139a2c63123afd247bdca0
4
- data.tar.gz: e4a0ba0b45b6d21031d8585037f1c081654abcf3079478e9c9625ae0e93ba1af
3
+ metadata.gz: 8bf603701e7dc27da76fcc61f2a8a4047133e7933ea58ec0f2549efb1d709afe
4
+ data.tar.gz: 8e600b62d801d284c831fb69fd55430d9322594b355ce5a65fe1cca335c387ff
5
5
  SHA512:
6
- metadata.gz: d4a5bd986cfd5cc1414adf0a57e1d458c01c5fe659a3c05981b2301bb8e57b6cdf7a7819d7e01aca873f0ecc91646d6dc8ecf0031327a80ddb58599572eed895
7
- data.tar.gz: 2b3921dcec32efafe5815f841aaa195b01c65cf46f3764033cf66e8bd51471c89cb036e83e6192368919304e8e28614bdabe1cb94b0539a93194a4afb33d9581
6
+ metadata.gz: abd0763536f8eeeb9769e8ee5c2996e27ea459194613ab3e8bb6db249feb9620fc0a283f01e791adb9ecb04638775dd75ff33a37fbc7a957dfd38dff5d449a76
7
+ data.tar.gz: 07d010c5b8c01fbcfa8e2bc84e741280034974ce4e7499027f488c2af4ea0b190bfbffe55a61073a6db3a673d24a5a23c41a4209ed4cac708821c732fe74e174
@@ -67,6 +67,7 @@ module PeopleGroup
67
67
  def search_team_member_by_email(email)
68
68
  team_members.find { |team_member| team_member['workEmail']&.downcase == email&.downcase }
69
69
  end
70
+ alias_method :slack_email_lookup_with_fallback, :search_team_member_by_email
70
71
 
71
72
  def search_team_member_by_email!(email)
72
73
  team_member = search_team_member_by_email(email)
@@ -74,22 +75,7 @@ module PeopleGroup
74
75
 
75
76
  team_member
76
77
  end
77
-
78
- def slack_email_lookup_with_fallback(email)
79
- file_path = File.join(__dir__, '../../../data/email_mapper.yml')
80
- email_mapper = YAML.load_file(file_path)
81
- email_hit = email_mapper.find { |mapping| mapping['slack_email'] == email.delete_suffix('@gitlab.com') }
82
- email = "#{email_hit['bamboo_email']}@gitlab.com" if email_hit
83
-
84
- employees.find { |employee| employee['workEmail'] == email }
85
- end
86
-
87
- def slack_email_lookup_with_fallback!(email)
88
- employee = slack_email_lookup_with_fallback(email)
89
- raise EmployeeNotFoundError, "No employee found with Slack email #{email}" if employee.nil?
90
-
91
- employee
92
- end
78
+ alias_method :slack_email_lookup_with_fallback!, :search_team_member_by_email!
93
79
 
94
80
  def team_members_by_department(department)
95
81
  active_and_current_team_members.select { |team_member| team_member['department'] == department }
@@ -12,22 +12,13 @@ module PeopleGroup
12
12
  @client = ::Slack::Web::Client.new
13
13
  end
14
14
 
15
- def find_user(email)
16
- @client.users_lookupByEmail(email: email)
17
- rescue ::Slack::Web::Api::Errors::SlackError
18
- nil
19
- end
20
-
21
- def bamboo_email_lookup_with_fallback(email)
22
- file_path = File.join(__dir__, '../../../data/email_mapper.yml')
23
- email_mapper = YAML.load_file(file_path)
24
- email_hit = email_mapper.find { |mapping| mapping['bamboo_email'] == email.delete_suffix('@gitlab.com') }
25
- email = "#{email_hit['slack_email']}@gitlab.com" if email_hit
26
-
15
+ def bamboo_email_lookup(email)
27
16
  @client.users_lookupByEmail(email: email)
28
17
  rescue ::Slack::Web::Api::Errors::SlackError
29
18
  nil
30
19
  end
20
+ alias_method :bamboo_email_lookup_with_fallback, :bamboo_email_lookup
21
+ alias_method :find_user, :bamboo_email_lookup
31
22
 
32
23
  def find_user_by_id(id)
33
24
  @client.users_info(user: id)
@@ -41,33 +32,62 @@ module PeopleGroup
41
32
  nil
42
33
  end
43
34
 
35
+ # https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FConversations:conversations_list
36
+ # Defaults to only show public channels.
44
37
  def list_public_channels
45
- channels = @client.channels_list(exclude_archived: true).channels
46
- channels.reject(&:is_private)&.map(:name)
38
+ response = @client.conversations_list(exclude_archived: true)
39
+ response['channels'].map { |channel| channel['name'] }
47
40
  end
48
41
 
42
+ # https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FChat:chat_getPermalink
49
43
  def link_for_message(channel:, timestamp:)
50
44
  @client.chat_getPermalink(channel: channel, message_ts: timestamp)
51
45
  end
52
46
 
47
+ # https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FChat:chat_postMessage
53
48
  def send_message(channel:, text: '', as_user: true, attachments: [], thread_ts: nil, reply_broadcast: false, formatted_message: [])
54
- @client.chat_postMessage(channel: channel, text: text, as_user: true, attachments: attachments, unfurl_links: false, thread_ts: thread_ts, reply_broadcast: reply_broadcast, blocks: formatted_message)
49
+ options = {
50
+ channel: channel,
51
+ text: text,
52
+ as_user: true,
53
+ attachments: attachments,
54
+ unfurl_links: false,
55
+ thread_ts: thread_ts,
56
+ reply_broadcast: reply_broadcast,
57
+ blocks: formatted_message
58
+ }
59
+
60
+ @client.chat_postMessage(options)
55
61
  end
56
62
 
63
+ # https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FChat:chat_update
57
64
  def update_message(channel:, timestamp:, text: '', attachments: [], formatted_message: [])
58
- @client.chat_update(channel: channel, text: text, ts: timestamp, as_user: true, attachments: attachments, blocks: formatted_message)
65
+ options = {
66
+ channel: channel,
67
+ text: text,
68
+ ts: timestamp,
69
+ as_user: true,
70
+ attachments: attachments,
71
+ blocks: formatted_message
72
+ }
73
+
74
+ @client.chat_update(options)
59
75
  end
60
76
 
77
+ # https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FViews:views_open
61
78
  def send_modal_message(trigger:, view:)
62
79
  @client.views_open(trigger_id: trigger, view: view)
63
80
  end
64
81
 
82
+ # https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FViews:views_publish
65
83
  def publish_view(user_id:, trigger:, view:)
66
84
  @client.views_publish(user_id: user_id, trigger_id: trigger, view: view)
67
85
  end
68
86
 
87
+ # https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FConversations:conversations_history
69
88
  def get_message(channel:, timestamp:)
70
- @client.conversations_history(channel: channel, latest: timestamp, limit: 1, inclusive: true)&.messages&.first
89
+ options = { channel: channel, latest: timestamp, limit: 1, inclusive: true }
90
+ @client.conversations_history(options)&.messages&.first
71
91
  end
72
92
  end
73
93
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PeopleGroup
4
4
  module Connectors
5
- VERSION = '0.1.93'
5
+ VERSION = '0.1.96'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peoplegroup-connectors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.93
4
+ version: 0.1.96
5
5
  platform: ruby
6
6
  authors:
7
7
  - lien van den steen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-28 00:00:00.000000000 Z
11
+ date: 2022-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.14'
47
+ version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.14'
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: splinter-pto
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -229,7 +229,6 @@ extra_rdoc_files: []
229
229
  files:
230
230
  - LICENSE.txt
231
231
  - README.md
232
- - data/email_mapper.yml
233
232
  - lib/peoplegroup/connectors.rb
234
233
  - lib/peoplegroup/connectors/bamboo.rb
235
234
  - lib/peoplegroup/connectors/gitlab.rb
@@ -1,6 +0,0 @@
1
- - slack_email: cristiano
2
- bamboo_email: ccasella
3
- - slack_email: mjacob
4
- bamboo_email: mgomez
5
- - slack_email: nprecilla
6
- bamboo_email: ngarcia