peoplegroup-connectors 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/peoplegroup/connectors.rb +2 -0
- data/lib/peoplegroup/connectors/bamboo.rb +146 -0
- data/lib/peoplegroup/connectors/greenhouse.rb +81 -0
- data/lib/peoplegroup/connectors/version.rb +1 -1
- metadata +47 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 800a61edd755dd71ab5990d2f53df313a78c42cfac1cc6be206dd9e0f1555cb7
|
4
|
+
data.tar.gz: f8213430bfa0fe919aa8e1fcb229d0655ca9514d8827b3c304ff4dbc6047c59a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9eebb60b4bc441afdfa164a7c911bb58f48e47358ada3fe75595f5cb9102f2d50f0f5f9b8ce164d89aaf8aff8527720950de02075e16b3b62a0ccf2039dc8be
|
7
|
+
data.tar.gz: a4a709ad17b6e14fd09117fc15810c9354279780264a7721e785ea11c355dea655ee4054790a3dfa6db20443743d5947832c41e1c5721f4a5fca2b3626f82835
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# PeopleGroup::Connectors
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
The gem contains wrapper code for all the services we sync with. The reason we bundled this in a separate gem is to not have duplicate code in our different projects.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,10 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
```ruby
|
24
|
+
gitlab_client = PeopleGroup::Connectors::GitLab.new
|
25
|
+
gitlab_client.find_gitlabber(:email, 'some-email@domain.com')
|
26
|
+
```
|
26
27
|
|
27
28
|
## Development
|
28
29
|
|
@@ -4,6 +4,8 @@ require_relative 'connectors/version'
|
|
4
4
|
require_relative 'connectors/gitlab'
|
5
5
|
require_relative 'connectors/slack'
|
6
6
|
require_relative 'connectors/pto_roots'
|
7
|
+
require_relative 'connectors/bamboo'
|
8
|
+
require_relative 'connectors/greenhouse'
|
7
9
|
|
8
10
|
module PeopleGroup
|
9
11
|
module Connectors
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bamboozled'
|
4
|
+
|
5
|
+
module PeopleGroup
|
6
|
+
module Connectors
|
7
|
+
class Bamboo
|
8
|
+
MAX_RETRIES = 3
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@client = Bamboozled.client(subdomain: 'gitlab', api_key: ENV['BAMBOO_API_KEY'])
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_employee_details(id)
|
15
|
+
employees.find { |emp| emp['id'] == id.to_s }
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_employee(id)
|
19
|
+
@client.employee.find(id, %w[firstName lastName jobTitle supervisor hireDate country location department division workEmail customCostCenter])
|
20
|
+
end
|
21
|
+
|
22
|
+
def search_employee(name)
|
23
|
+
return if name.empty?
|
24
|
+
|
25
|
+
employees.find { |emp| [emp['displayName'], "#{emp['firstName']} #{emp['lastName']}", "#{emp['preferredName']} #{emp['lastName']}", emp['fullName5']].include?(name) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def search_employee_by_field(field:, value:)
|
29
|
+
employees.find { |employee| employee[field] == value.to_s }
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_employee(employee_details_hash)
|
33
|
+
@client.employee.add(employee_details_hash)
|
34
|
+
end
|
35
|
+
|
36
|
+
def update_employee(employee_id, employee_details_hash)
|
37
|
+
@client.employee.update(employee_id, employee_details_hash)
|
38
|
+
end
|
39
|
+
|
40
|
+
def departments
|
41
|
+
meta_fields.detect { |res| res['name'] == 'Department' }.dig('options').each_with_object([]) { |option, array| array << option['name'] if option['archived'] == 'no' } || []
|
42
|
+
end
|
43
|
+
|
44
|
+
def divisions
|
45
|
+
meta_fields.detect { |res| res['name'] == 'Division' }.dig('options').each_with_object([]) { |option, array| array << option['name'] if option['archived'] == 'no' } || []
|
46
|
+
end
|
47
|
+
|
48
|
+
def fields
|
49
|
+
@fields ||= (Bamboozled::API::FieldCollection.all_names + @client.meta.fields.map { |f| f['alias'] }).compact.uniq
|
50
|
+
end
|
51
|
+
|
52
|
+
def employees
|
53
|
+
retries = 0
|
54
|
+
|
55
|
+
begin
|
56
|
+
@employees ||= @client.report.custom(fields, 'JSON').reject { |employee| employee['lastName'] == 'Test-Gitlab' }
|
57
|
+
rescue Net::ReadTimeout
|
58
|
+
retry if (retries += 1) < MAX_RETRIES
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def active_employees
|
63
|
+
employees.select { |employee| employee['status'] == 'Active' }
|
64
|
+
end
|
65
|
+
alias_method :active_team_members, :active_employees
|
66
|
+
|
67
|
+
def add_stock_options(employee_id, data)
|
68
|
+
@client.employee.add_table_row(employee_id, 'customEquity', data)
|
69
|
+
end
|
70
|
+
|
71
|
+
def stock_options_data(employee_id)
|
72
|
+
@client.employee.table_data(employee_id, 'customEquity')
|
73
|
+
end
|
74
|
+
|
75
|
+
def update_job_details(employee_id, data)
|
76
|
+
current_data = job_details(employee_id) # it should only be one row as we just created this user
|
77
|
+
row_id = current_data.first.dig('id')
|
78
|
+
@client.employee.update_table_row(employee_id, 'jobInfo', row_id, data)
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_compensation_details(employee_id, data)
|
82
|
+
@client.employee.add_table_row(employee_id, 'compensation', data)
|
83
|
+
end
|
84
|
+
|
85
|
+
def employment_statuses(employee_id)
|
86
|
+
@client.employee.table_data(employee_id, 'employmentStatus')
|
87
|
+
end
|
88
|
+
|
89
|
+
def job_details(employee_id)
|
90
|
+
@client.employee.table_data(employee_id, 'jobInfo')
|
91
|
+
end
|
92
|
+
|
93
|
+
def resumes_folder_id(employee_id)
|
94
|
+
@resumes_folder_id ||= files(employee_id).dig('categories').find { |folder| folder['name'] == 'Resumes and Applications' }.dig('id')
|
95
|
+
end
|
96
|
+
|
97
|
+
def contract_folder_id(employee_id)
|
98
|
+
@contract_folder_id ||= files(employee_id).dig('categories').find { |folder| folder['name'] == 'Contracts & Changes' }.dig('id')
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_file(employee_id, file_name, file, folder_id)
|
102
|
+
options = {
|
103
|
+
category: folder_id,
|
104
|
+
fileName: file_name,
|
105
|
+
share: 'yes',
|
106
|
+
file: file
|
107
|
+
}
|
108
|
+
@client.employee.add_file(employee_id, options)
|
109
|
+
end
|
110
|
+
|
111
|
+
def add_employment_status(employee_id, data)
|
112
|
+
@client.employee.add_table_row(employee_id, 'employmentStatus', data)
|
113
|
+
end
|
114
|
+
|
115
|
+
def add_currency_conversion(employee_id, data)
|
116
|
+
@client.employee.add_table_row(employee_id, 'customCurrencyConversion', data)
|
117
|
+
end
|
118
|
+
|
119
|
+
def add_on_target_earnings(employee_id, data)
|
120
|
+
@client.employee.add_table_row(employee_id, 'customOnTargetEarnings', data)
|
121
|
+
end
|
122
|
+
|
123
|
+
def add_signing_bonus(employee_id, data)
|
124
|
+
@client.employee.add_table_row(employee_id, 'customBonus', data)
|
125
|
+
end
|
126
|
+
|
127
|
+
def add_family_member(employee_id, data)
|
128
|
+
@client.employee.add_table_row(employee_id, 'customFamilyMember', data)
|
129
|
+
end
|
130
|
+
|
131
|
+
def add_additional_data(employee_id, data)
|
132
|
+
@client.employee.add_table_row(employee_id, 'customAdditionalInformation1', data)
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def meta_fields
|
138
|
+
@meta_fields ||= @client.meta.lists
|
139
|
+
end
|
140
|
+
|
141
|
+
def files(employee_id)
|
142
|
+
@files ||= @client.employee.files(employee_id)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'greenhouse_io'
|
4
|
+
|
5
|
+
module PeopleGroup
|
6
|
+
module Connectors
|
7
|
+
class Greenhouse
|
8
|
+
MAX_RETRIES = 3
|
9
|
+
|
10
|
+
def initialize(use_users_api_key: false)
|
11
|
+
api_key = use_users_api_key ? ENV['GREENHOUSE_API_KEY_USERS'] : ENV['GREENHOUSE_API_KEY']
|
12
|
+
@client = GreenhouseIo::Client.new(api_key)
|
13
|
+
end
|
14
|
+
|
15
|
+
def offer_for_application(application_id)
|
16
|
+
@client.offers_for_application(application_id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def hired_candidates(updated_since)
|
20
|
+
page = 1
|
21
|
+
candidates = []
|
22
|
+
retries = 0
|
23
|
+
|
24
|
+
loop do
|
25
|
+
begin
|
26
|
+
results = @client.candidates(nil, updated_after: updated_since, page: page)
|
27
|
+
break if results.empty?
|
28
|
+
|
29
|
+
results.each do |candidate|
|
30
|
+
candidates << candidate if hired_non_active?(candidate)
|
31
|
+
end
|
32
|
+
rescue GreenhouseIo::Error
|
33
|
+
p [updated_since, page]
|
34
|
+
retry if (retries += 1) < MAX_RETRIES
|
35
|
+
end
|
36
|
+
page += 1
|
37
|
+
end
|
38
|
+
|
39
|
+
candidates
|
40
|
+
end
|
41
|
+
|
42
|
+
def candidate(candidate_id)
|
43
|
+
@client.candidates(candidate_id)
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_sync_note_to_candidate(candidate_id)
|
47
|
+
note = {
|
48
|
+
user_id: ENV['GREENHOUSE_AUTHOR_ID'],
|
49
|
+
body: "This person was synced at #{Time.now} by the Employee Bot",
|
50
|
+
visibility: 'public'
|
51
|
+
}
|
52
|
+
@client.create_candidate_note(candidate_id, note, ENV['GREENHOUSE_AUTHOR_ID'])
|
53
|
+
end
|
54
|
+
|
55
|
+
def users
|
56
|
+
page = 1
|
57
|
+
users = []
|
58
|
+
|
59
|
+
loop do
|
60
|
+
results = @client.users(nil, page: page)
|
61
|
+
break if results.empty?
|
62
|
+
|
63
|
+
users += results
|
64
|
+
page += 1
|
65
|
+
end
|
66
|
+
|
67
|
+
users
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def hired_non_active?(candidate)
|
73
|
+
# If the candidate has any application that is active, we don't sync.
|
74
|
+
return false if candidate['applications'].any? { |application| application['status'] == 'active' }
|
75
|
+
|
76
|
+
# Check if candidate is hired for just one of their applications
|
77
|
+
candidate['applications'].one? { |application| application['status'] == 'hired' }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peoplegroup-connectors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lien van den steen
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bamboozled-gitlab
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.2.9
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.2.9
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: greenhouse_io-gitlab
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.5'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.5'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rspec
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +100,28 @@ dependencies:
|
|
72
100
|
requirements:
|
73
101
|
- - "~>"
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
103
|
+
version: 0.91.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.91.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: gitlab-styles
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '6.0'
|
76
118
|
type: :development
|
77
119
|
prerelease: false
|
78
120
|
version_requirements: !ruby/object:Gem::Requirement
|
79
121
|
requirements:
|
80
122
|
- - "~>"
|
81
123
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
124
|
+
version: '6.0'
|
83
125
|
- !ruby/object:Gem::Dependency
|
84
126
|
name: rubocop-packaging
|
85
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +160,9 @@ files:
|
|
118
160
|
- LICENSE.txt
|
119
161
|
- README.md
|
120
162
|
- lib/peoplegroup/connectors.rb
|
163
|
+
- lib/peoplegroup/connectors/bamboo.rb
|
121
164
|
- lib/peoplegroup/connectors/gitlab.rb
|
165
|
+
- lib/peoplegroup/connectors/greenhouse.rb
|
122
166
|
- lib/peoplegroup/connectors/pto_roots.rb
|
123
167
|
- lib/peoplegroup/connectors/slack.rb
|
124
168
|
- lib/peoplegroup/connectors/version.rb
|