peoplegroup-connectors 0.1.9 → 0.1.14

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: 800a61edd755dd71ab5990d2f53df313a78c42cfac1cc6be206dd9e0f1555cb7
4
- data.tar.gz: f8213430bfa0fe919aa8e1fcb229d0655ca9514d8827b3c304ff4dbc6047c59a
3
+ metadata.gz: ff078596371e7e0e9324604a6c2dc7d61707865468ec123667497e95b98d4351
4
+ data.tar.gz: f13a2a16ffe994b7a5a5e2753860d11d640d4a25e42e8ed8ab0a8027de11184b
5
5
  SHA512:
6
- metadata.gz: d9eebb60b4bc441afdfa164a7c911bb58f48e47358ada3fe75595f5cb9102f2d50f0f5f9b8ce164d89aaf8aff8527720950de02075e16b3b62a0ccf2039dc8be
7
- data.tar.gz: a4a709ad17b6e14fd09117fc15810c9354279780264a7721e785ea11c355dea655ee4054790a3dfa6db20443743d5947832c41e1c5721f4a5fca2b3626f82835
6
+ metadata.gz: 7b58df402d826a8388205eeafdd6c0f26babc7516a27edd92f0771bf32ef0858d458503ee3c6a7e49e209faa2cc9c025102f912f0cc728d4318f66ae1a4b85f3
7
+ data.tar.gz: 818217d780930b5ee2a63ac232924f6d40a172471a220b8fe06101250f6686c0833f952c53f1563d07c8ffba03e9b3281e0da9c50e7c2f783310aa2669cf510b
@@ -22,12 +22,30 @@ module PeopleGroup
22
22
  def search_employee(name)
23
23
  return if name.empty?
24
24
 
25
- employees.find { |emp| [emp['displayName'], "#{emp['firstName']} #{emp['lastName']}", "#{emp['preferredName']} #{emp['lastName']}", emp['fullName5']].include?(name) }
25
+ employees.find do |emp|
26
+ [
27
+ emp['displayName']&.downcase,
28
+ "#{emp['firstName']&.downcase} #{emp['lastName']&.downcase}",
29
+ "#{emp['preferredName']&.downcase} #{emp['lastName']&.downcase}",
30
+ "#{emp['firstName']&.downcase} #{emp['customPreferredLastName']&.downcase}",
31
+ "#{emp['preferredName']&.downcase} #{emp['customPreferredLastName']&.downcase}"
32
+ ].include?(name.downcase)
33
+ end
26
34
  end
35
+ alias_method :search_team_member, :search_employee
27
36
 
28
37
  def search_employee_by_field(field:, value:)
29
38
  employees.find { |employee| employee[field] == value.to_s }
30
39
  end
40
+ alias_method :search_team_member_by_field, :search_employee_by_field
41
+
42
+ def fetch_manager(team_member)
43
+ active_team_members.find { |tm| tm['id'] == team_member['supervisorEId'] }
44
+ end
45
+
46
+ def fetch_second_level_manager(team_member)
47
+ fetch_manager(fetch_manager(team_member))
48
+ end
31
49
 
32
50
  def create_employee(employee_details_hash)
33
51
  @client.employee.add(employee_details_hash)
@@ -54,7 +72,7 @@ module PeopleGroup
54
72
 
55
73
  begin
56
74
  @employees ||= @client.report.custom(fields, 'JSON').reject { |employee| employee['lastName'] == 'Test-Gitlab' }
57
- rescue Net::ReadTimeout
75
+ rescue Net::ReadTimeout, Bamboozled::GatewayError
58
76
  retry if (retries += 1) < MAX_RETRIES
59
77
  end
60
78
  end
@@ -132,6 +150,17 @@ module PeopleGroup
132
150
  @client.employee.add_table_row(employee_id, 'customAdditionalInformation1', data)
133
151
  end
134
152
 
153
+ def add_bonus(team_member_id, comment)
154
+ data = {
155
+ customBonusdate: Date.today.to_s,
156
+ customBonusamount: { value: 1_000, currency: 'USD' },
157
+ customBonustype: 'Discretionary Bonus',
158
+ customBonuscomments: comment
159
+ # customNominatedBy: 'TODO'
160
+ }
161
+ @client.employee.add_table_row(team_member_id, 'customBonus', data)
162
+ end
163
+
135
164
  private
136
165
 
137
166
  def meta_fields
@@ -45,7 +45,25 @@ module PeopleGroup
45
45
  epic || @client.create_epic(group_id, title, options)
46
46
  end
47
47
 
48
- def commit_change_to_new_merge_request_v2(project_id, branch_name, commit_message, description = '', files_to_delete = [], files_to_update = [])
48
+ def commit_new_files_to_new_merge_request(project_id, branch_name, new_files, commit_message, description = nil)
49
+ @client.create_branch(project_id, branch_name, 'master')
50
+ actions = []
51
+ new_files.each do |file|
52
+ actions << {
53
+ action: 'create',
54
+ file_path: file.sub('tmp', '/data/team_members/person'),
55
+ content: File.read(file)
56
+ }
57
+ end
58
+
59
+ @client.create_commit(project_id, branch_name, commit_message, actions)
60
+
61
+ options = { source_branch: branch_name, target_branch: 'master', remove_source_branch: true }
62
+ options[:description] = description if description
63
+ @client.create_merge_request(project_id, commit_message, options)
64
+ end
65
+
66
+ def commit_change_to_new_merge_request_v2(project_id, branch_name, commit_message, description = nil, files_to_delete = [], files_to_update = [])
49
67
  actions = []
50
68
 
51
69
  files_to_delete.each do |file|
@@ -60,7 +78,7 @@ module PeopleGroup
60
78
  action = {
61
79
  action: 'update',
62
80
  file_path: file[:file_path],
63
- content: file[:file_with_change]
81
+ content: File.read(file[:tmp_file_path])
64
82
  }
65
83
  actions << action
66
84
  end
@@ -71,7 +89,7 @@ module PeopleGroup
71
89
  @client.create_commit(project_id, branch_name, commit_message, actions)
72
90
 
73
91
  options = { source_branch: branch_name, target_branch: 'master', remove_source_branch: true }
74
- options[:description] = description if description.present?
92
+ options[:description] = description if description
75
93
  @client.create_merge_request(project_id, commit_message, options)
76
94
  end
77
95
 
@@ -12,20 +12,38 @@ module PeopleGroup
12
12
  @client = ::Slack::Web::Client.new
13
13
  end
14
14
 
15
- def send_message(channel, message)
16
- @client.chat_postMessage(channel: channel, text: message, as_user: true)
17
- end
18
-
19
15
  def find_user(email)
20
16
  @client.users_lookupByEmail(email: email)
21
17
  rescue ::Slack::Web::Api::Errors::SlackError
22
18
  nil
23
19
  end
24
20
 
21
+ def find_user_by_id(id)
22
+ @client.users_info(user: id)
23
+ rescue ::Slack::Web::Api::Errors::SlackError
24
+ nil
25
+ end
26
+
25
27
  def list_public_channels
26
28
  channels = @client.channels_list(exclude_archived: true).channels
27
29
  channels.reject(&:is_private)&.map(:name)
28
30
  end
31
+
32
+ def send_message(channel:, text:, as_user: true, attachments: [])
33
+ @client.chat_postMessage(channel: channel, text: text, as_user: true, attachments: attachments, unfurl_links: false)
34
+ end
35
+
36
+ def update_message(channel:, timestamp:, text:)
37
+ @client.chat_update(channel: channel, text: text, ts: timestamp, as_user: true, attachments: [])
38
+ end
39
+
40
+ def send_modal_message(trigger:, view:)
41
+ @client.views_open(trigger_id: trigger, view: view)
42
+ end
43
+
44
+ def publish_view(user_id:, trigger:, view:)
45
+ @client.views_publish(user_id: user_id, trigger_id: trigger, view: view)
46
+ end
29
47
  end
30
48
  end
31
49
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PeopleGroup
4
4
  module Connectors
5
- VERSION = '0.1.9'
5
+ VERSION = '0.1.14'
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.9
4
+ version: 0.1.14
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: 2021-02-02 00:00:00.000000000 Z
11
+ date: 2021-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab