peoplegroup-connectors 0.1.51 → 0.1.56

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: fe36fe6e0862602fb04bcbe25d28cff7fa9d9d612488c87d75efc955f8ec618f
4
- data.tar.gz: aee161b1c35e49f8bdeea8a9195f397c0b6bfeb936dc40f4b613845d665590f5
3
+ metadata.gz: 9d2a5d424a458d4df18899e8807f0c0138eca9ff7bd344c31d52c8c2be68bbfb
4
+ data.tar.gz: 3228ab2eb7fee96004b277688e66f5a69092d2d76f923579876513cd217eef7f
5
5
  SHA512:
6
- metadata.gz: 2465eb22e2ddf6dcf576dfe3e414930487eed61c7a78730177732687cf27ef0b473f214bf1ddf58c3a9a9ab9fbd19115170ac8a5114381157227538b1de77a82
7
- data.tar.gz: 32edaf4889de86695cf93b3e161e26b386764def98cff4532924f5a2ffe9ff61157f2353ed00255c3a09779fadc2b4b37669aaf0c56d20f2f3c17f4fa9515602
6
+ metadata.gz: 0d016213cc5f5dc4f1f1d40165bd258b6ed06de02e317d7062062c9f27263f09a9aa787544c1165518a68d84f4a42443a5670e586debe606956ed0f3def5258f
7
+ data.tar.gz: afc8bed39c8a6d48b455e75383bea04f7a38fb47147d19e03b60fa29c01dfde2b642e51fa18468ac163e5e601b7eb41c97ed638cf67d685cea7ccd0a08c9a8d1
@@ -5,6 +5,8 @@ require 'bamboozled'
5
5
  module PeopleGroup
6
6
  module Connectors
7
7
  class Bamboo
8
+ attr_accessor :client
9
+
8
10
  EmployeeNotFoundError = Class.new(StandardError)
9
11
 
10
12
  def initialize(use_report: false)
@@ -15,6 +17,7 @@ module PeopleGroup
15
17
  def get_employee_details(id)
16
18
  employees.find { |emp| emp['id'] == id.to_s }
17
19
  end
20
+ alias_method :get_team_member_details, :get_employee_details
18
21
 
19
22
  def get_employee_details!(id)
20
23
  employee_details = get_employee_details(id)
@@ -87,6 +90,14 @@ module PeopleGroup
87
90
  employee
88
91
  end
89
92
 
93
+ def team_members_by_department(department)
94
+ active_and_current_team_members.select { |team_member| team_member['department'] == department }
95
+ end
96
+
97
+ def team_members_by_division(division)
98
+ active_and_current_team_members.select { |team_member| team_member['division'] == division }
99
+ end
100
+
90
101
  def fetch_manager(team_member)
91
102
  active_team_members.find { |tm| tm['id'] == team_member['supervisorEId'] }
92
103
  end
@@ -121,6 +132,45 @@ module PeopleGroup
121
132
  manager
122
133
  end
123
134
 
135
+ def people_managers_in_functions(departments: [], divisions: [])
136
+ active_and_current_team_members.select do |team_member|
137
+ (departments.include?(team_member['department']) || divisions.include?(team_member['division'])) && has_direct_reports?(team_member['id'])
138
+ end
139
+ end
140
+
141
+ def all_reports_for(id)
142
+ direct_reports_to_check = direct_reports_for(id)
143
+ reports_to_return = []
144
+ while direct_reports_to_check.present?
145
+ current_node = direct_reports_to_check.shift
146
+ reports_to_return << current_node
147
+ direct_reports_to_check.concat(direct_reports_for(current_node['id']))
148
+ end
149
+ reports_to_return
150
+ end
151
+
152
+ def direct_reports_for(id)
153
+ active_and_current_team_members.select { |team_member| team_member['supervisorEId'] == id.to_s }
154
+ end
155
+
156
+ def has_direct_reports?(id)
157
+ active_and_current_team_members.any? { |team_member| team_member['supervisorEId'] == id.to_s }
158
+ end
159
+
160
+ def reports_in_departments(departments, exclude_email)
161
+ active_and_current_team_members.select do |team_member|
162
+ # exclude_email is for example to filter out the PBP itself in case their department is also the department they manage
163
+ departments.include?(team_member['department']) && team_member['workEmail'] != exclude_email
164
+ end
165
+ end
166
+
167
+ def reports_in_divisions(divisions, exclude_email)
168
+ active_and_current_team_members.select do |team_member|
169
+ # exclude_email is for example to filter out the PBP itself in case their department is also the department they manage
170
+ divisions.include?(team_member['division']) && team_member['workEmail'] != exclude_email
171
+ end
172
+ end
173
+
124
174
  def create_employee(employee_details_hash)
125
175
  @client.employee.add(employee_details_hash)
126
176
  end
@@ -217,6 +267,27 @@ module PeopleGroup
217
267
  total_accruals['balance'].to_f
218
268
  end
219
269
 
270
+ def time_off_policies
271
+ @time_off_policies ||= @client.meta.time_off_policies
272
+ end
273
+
274
+ def employee_time_off_policies(employee_id)
275
+ @client.employee.time_off_policies(employee_id)
276
+ end
277
+ alias_method :team_member_time_off_policies, :employee_time_off_policies
278
+
279
+ def add_time_off_policy(employee_id, time_off_policy_id, accrual_start_date)
280
+ policies = [{ timeOffPolicyId: time_off_policy_id, accrualStartDate: accrual_start_date }]
281
+
282
+ @client.employee.add_time_off_policies(employee_id, policies)
283
+ end
284
+
285
+ def remove_time_off_policy(employee_id, time_off_policy_id)
286
+ # A nil accrual start date removes a policy assignment
287
+ # Reference: https://documentation.bamboohr.com/reference#time-off-assign-time-off-policies-for-an-employee
288
+ add_time_off_policy(employee_id, time_off_policy_id, nil)
289
+ end
290
+
220
291
  def job_details(employee_id)
221
292
  @client.employee.table_data(employee_id, 'jobInfo')
222
293
  end
@@ -282,8 +353,13 @@ module PeopleGroup
282
353
  @client.employee.add_table_row(team_member_id, 'customBonus', data)
283
354
  end
284
355
 
285
- def has_direct_reports?(id)
286
- active_team_members.any? { |team_member| team_member['supervisorEId'] == id.to_s }
356
+ def add_rating_details(team_member_id, performance, potential)
357
+ data = {
358
+ customEffectiveDate4: Date.today.to_s,
359
+ customPerformanceFactor: performance,
360
+ customPotentialFactor: potential
361
+ }
362
+ @client.employee.add_table_row(team_member_id, 'customPerformanceandPotentialTable', data)
287
363
  end
288
364
 
289
365
  private
@@ -78,8 +78,8 @@ module PeopleGroup
78
78
  new_files.each do |file|
79
79
  actions << {
80
80
  action: 'create',
81
- file_path: file.sub('tmp', '/data/team_members/person'),
82
- content: File.read(file)
81
+ file_path: file[:remote_path],
82
+ content: File.read(file[:local_path])
83
83
  }
84
84
  end
85
85
 
@@ -17,7 +17,7 @@ module PeopleGroup
17
17
  private
18
18
 
19
19
  def service_account_key
20
- StringIO.new(Base64.strict_decode64(ENV['GOOGLE_DRIVE_SERVICE_ACCOUNT_KEY']))
20
+ StringIO.new(Base64.strict_decode64(ENV['GOOGLE_SERVICE_ACCOUNT_KEY']))
21
21
  end
22
22
 
23
23
  def session
@@ -35,6 +35,12 @@ module PeopleGroup
35
35
  nil
36
36
  end
37
37
 
38
+ def find_user_profile(id:, include_labels: false)
39
+ @client.users_profile_get(user: id, include_labels: include_labels)
40
+ rescue ::Slack::Web::Api::Errors::SlackError
41
+ nil
42
+ end
43
+
38
44
  def list_public_channels
39
45
  channels = @client.channels_list(exclude_archived: true).channels
40
46
  channels.reject(&:is_private)&.map(:name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PeopleGroup
4
4
  module Connectors
5
- VERSION = '0.1.51'
5
+ VERSION = '0.1.56'
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.51
4
+ version: 0.1.56
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-06-02 00:00:00.000000000 Z
11
+ date: 2021-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.2.9
75
+ version: 0.2.11
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.2.9
82
+ version: 0.2.11
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: greenhouse_io-gitlab
85
85
  requirement: !ruby/object:Gem::Requirement