bobhr 0.5.6 → 0.5.9

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: fd82730426161001e491b5231b6c352cea55a2ca26e6484d69ede72efc91b358
4
- data.tar.gz: 7c1b2c0062c6b5c781a05c508727d6d87cf821e89eca59e541703a569e2a3f07
3
+ metadata.gz: ffda2d8bd0f7e6ea7a53b1a8f92fe6c247fa3702737960c2f84a9bd2e2f28942
4
+ data.tar.gz: ad09a4e4594864444610990d6d78c0c4581770f189c31f34220afa3da514ee2a
5
5
  SHA512:
6
- metadata.gz: 5a4a4a2c923ce1edab07ad958b1d440b5912973118f3c2b7bb7b1f57dae96a9119fb76a4622b703431874444d3f0c430321fcf2c31946c494f074e609af28b8f
7
- data.tar.gz: 3284dbc7c578633bb45fca89843ccd85738244c20a66110b8984d0c28779708cb13802e87a7926fbb98e8c4b28012d68a29d345f13981f079dd1d1c74e443a3f
6
+ metadata.gz: e6f747a56836825f25805490d6f83050c1b9dd86ad983231719791a05206cb069686ede379cca34e7f6acd6a0b8723e5c176a1b0715c3b0ace57b41e6a5abd29
7
+ data.tar.gz: ea9aba347455c16c27a74d174046b1899253b856457b87026b9353dda13d63ee4b78cb4b9b8852df184fa29a650fcb6bc2edbcc045889e410c5598db08033e5a
data/lib/bob/api/api.rb CHANGED
@@ -12,15 +12,25 @@ module Bob
12
12
 
13
13
  def self.get(endpoint, params = {}, csv_response: false)
14
14
  url = build_url(endpoint, params)
15
- response = RestClient.get(url, headers)
15
+ response = RestClient.get(url, authorization_header)
16
16
  return create_csv(response.body) if csv_response
17
17
 
18
18
  JSON.parse(response.body)
19
19
  end
20
20
 
21
- def self.post(endpoint, params = {})
21
+ def self.post(endpoint, params = {}, use_api_key: false)
22
22
  url = build_url(endpoint)
23
- response = RestClient.post(url, params.to_json, headers.merge(content_headers))
23
+ response = RestClient.post(
24
+ url,
25
+ params.to_json,
26
+ authorization_header(use_api_key: use_api_key).merge(content_headers)
27
+ )
28
+ response.code
29
+ end
30
+
31
+ def self.post_media(endpoint, params = {})
32
+ url = build_url(endpoint)
33
+ response = RestClient.post(url, params.to_json, authorization_header.merge(content_headers))
24
34
  response.code
25
35
  end
26
36
 
@@ -30,16 +40,26 @@ module Bob
30
40
  response.code
31
41
  end
32
42
 
33
- def self.put(endpoint, params = {})
43
+ def self.put(endpoint, params = {}, use_api_key: false)
34
44
  url = build_url(endpoint)
35
- response = RestClient.put(url, params.to_json, headers.merge(content_headers))
45
+ response = RestClient.put(
46
+ url,
47
+ params.to_json,
48
+ authorization_header(use_api_key: use_api_key).merge(content_headers)
49
+ )
36
50
  response.code
37
51
  end
38
52
 
39
- def self.headers
40
- {
41
- Authorization: "Basic #{Base64.strict_encode64("#{Bob.access_user_name}:#{Bob.access_token}")}"
42
- }
53
+ def self.authorization_header(use_api_key: false)
54
+ if use_api_key
55
+ {
56
+ Authorization: Bob.api_key
57
+ }
58
+ else
59
+ {
60
+ Authorization: "Basic #{Base64.strict_encode64("#{Bob.access_user_name}:#{Bob.access_token}")}"
61
+ }
62
+ end
43
63
  end
44
64
 
45
65
  def self.content_headers
@@ -4,11 +4,11 @@ module Bob
4
4
  module Employee
5
5
  class Documents < API
6
6
  def self.add_public_document(employee_id, params = {})
7
- post("docs/people/#{employee_id}/shared", params)
7
+ post("docs/people/#{employee_id}/shared", params, use_api_key: true)
8
8
  end
9
9
 
10
10
  def self.add_private_document(employee_id, params = {})
11
- post("docs/people/#{employee_id}/confidential", params)
11
+ post("docs/people/#{employee_id}/confidential", params, use_api_key: true)
12
12
  end
13
13
  end
14
14
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bob
4
+ module Employee
5
+ class WorkHistory < API
6
+ def self.all(employee_id)
7
+ response = get("people/#{employee_id}/work")
8
+ WorkHistoryParser.new(response).work_histories
9
+ end
10
+
11
+ def self.update(employee_id, work_history_id, params)
12
+ put(
13
+ "people/#{employee_id}/work/#{work_history_id}",
14
+ params,
15
+ use_api_key: true
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
@@ -6,6 +6,7 @@ require_relative 'employee/salaries'
6
6
  require_relative 'employee/equity_grants'
7
7
  require_relative 'employee/documents'
8
8
  require_relative 'employee/variable_payments'
9
+ require_relative 'employee/work_history'
9
10
 
10
11
  module Bob
11
12
  class Employees < API
@@ -19,6 +20,11 @@ module Bob
19
20
  EmployeeParser.new(response).managers
20
21
  end
21
22
 
23
+ def self.starts_on(date = Date.current.to_s, params = { includeHumanReadable: true })
24
+ response = get('people', params)
25
+ EmployeeParser.new(response).starters_on(date)
26
+ end
27
+
22
28
  def self.find(employee_id_or_email, params: { includeHumanReadable: true })
23
29
  response = get("people/#{employee_id_or_email}", params)
24
30
  EmployeeParser.new(response).employee
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Bob
4
4
  module Configuration
5
- VALID_OPTIONS_KEYS = %i[access_token access_user_name api_version].freeze
5
+ VALID_OPTIONS_KEYS = %i[access_token access_user_name api_version api_key].freeze
6
6
  attr_accessor(*VALID_OPTIONS_KEYS)
7
7
 
8
8
  # Sets all configuration options to their default values
@@ -26,6 +26,7 @@ module Bob
26
26
  self.api_version = 'v1'
27
27
  self.access_token = ENV['ACCESS_TOKEN']
28
28
  self.access_user_name = ENV['ACCESS_USER_NAME']
29
+ self.api_key = ENV['API_KEY']
29
30
  end
30
31
  end
31
32
  end
@@ -34,6 +34,10 @@ module Models
34
34
  address.site_city || address.city
35
35
  end
36
36
 
37
+ def country
38
+ address.country || address.site_country
39
+ end
40
+
37
41
  def role_level
38
42
  human_readable.work.custom_columns.column_1629151373898
39
43
  end
@@ -73,5 +77,13 @@ module Models
73
77
  def cost_center
74
78
  payroll.custom.field_1634476091511
75
79
  end
80
+
81
+ def personal_email
82
+ home.private_email
83
+ end
84
+
85
+ def linkedin_profile
86
+ human_readable.about.social_data&.linkedin
87
+ end
76
88
  end
77
89
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Models
4
+ class WorkHistory < Models::Base
5
+ end
6
+ end
data/lib/bob/models.rb CHANGED
@@ -10,3 +10,4 @@ require_relative 'models/time_off'
10
10
  require_relative 'models/company_list'
11
11
  require_relative 'models/company_field'
12
12
  require_relative 'models/onboarding_wizard'
13
+ require_relative 'models/work_history'
@@ -14,4 +14,10 @@ class EmployeeParser < BaseParser
14
14
  .select { |employee| employee['work']['isManager'] }
15
15
  .map { |attributes| Models::Employee.new(attributes) }
16
16
  end
17
+
18
+ def starters_on(date)
19
+ json_response['employees']
20
+ .select { |employee| employee['work']['startDate'] == date }
21
+ .map { |attributes| Models::Employee.new(attributes) }
22
+ end
17
23
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class WorkHistoryParser < BaseParser
4
+ def work_histories
5
+ json_response['values'].map { |attributes| Models::WorkHistory.new(attributes) }
6
+ end
7
+ end
data/lib/bob/parsers.rb CHANGED
@@ -10,3 +10,4 @@ require_relative 'parsers/time_off_parser'
10
10
  require_relative 'parsers/company_list_parser'
11
11
  require_relative 'parsers/company_field_parser'
12
12
  require_relative 'parsers/onboarding_wizard_parser'
13
+ require_relative 'parsers/work_history_parser'
data/lib/bob/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bob
4
- VERSION = '0.5.6'
4
+ VERSION = '0.5.9'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bobhr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.9
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-23 00:00:00.000000000 Z
11
+ date: 2022-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -69,6 +69,7 @@ files:
69
69
  - lib/bob/api/employee/salaries.rb
70
70
  - lib/bob/api/employee/trainings.rb
71
71
  - lib/bob/api/employee/variable_payments.rb
72
+ - lib/bob/api/employee/work_history.rb
72
73
  - lib/bob/api/employees.rb
73
74
  - lib/bob/api/metadata.rb
74
75
  - lib/bob/api/metadata/company_fields.rb
@@ -88,6 +89,7 @@ files:
88
89
  - lib/bob/models/time_off.rb
89
90
  - lib/bob/models/training.rb
90
91
  - lib/bob/models/variable_payment.rb
92
+ - lib/bob/models/work_history.rb
91
93
  - lib/bob/parsers.rb
92
94
  - lib/bob/parsers/base_parser.rb
93
95
  - lib/bob/parsers/company_field_parser.rb
@@ -99,6 +101,7 @@ files:
99
101
  - lib/bob/parsers/time_off_parser.rb
100
102
  - lib/bob/parsers/training_parser.rb
101
103
  - lib/bob/parsers/variable_payment_parser.rb
104
+ - lib/bob/parsers/work_history_parser.rb
102
105
  - lib/bob/util.rb
103
106
  - lib/bob/version.rb
104
107
  - lib/bob/webhooks.rb
@@ -123,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
126
  - !ruby/object:Gem::Version
124
127
  version: '0'
125
128
  requirements: []
126
- rubygems_version: 3.3.7
129
+ rubygems_version: 3.2.31
127
130
  signing_key:
128
131
  specification_version: 4
129
132
  summary: Ruby gem for Bob API