bobhr 0.5.15 → 0.5.18

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: 8fbc4a2d88ccb3778bf83513c95f4606124535d1aeff8fe84732c5ebf269b6f7
4
- data.tar.gz: 4f307468c30e25e38a7b1bcc3d32c9d4689563975f4740adf9e449f97bbbe217
3
+ metadata.gz: ba27fbf4804e19318ce9f39e7dfe5488955a19b68f337da4407ce52824b71db3
4
+ data.tar.gz: 82a0ce36154590d31b0ddbd605c20baf31432f94c996c6a0dd90e9b97cf85d60
5
5
  SHA512:
6
- metadata.gz: d35199c9347fe57876644c4c674fe4a04a78160c2e20beffbfb0408534e886ed6cb4850d28758522af052271ff7e6cc2e80b864df37b17bbbbe618e34c2a8cf9
7
- data.tar.gz: 27191a97466465ca5ebf761ed6f7642e139f1777dc1e1c52ba9b4a6408b37b110993c501bda136a8c2aba444fe275eabafed5b2c5d6a2fefae73d11d1f52ff14
6
+ metadata.gz: 5c0a58de9a8c6c7cb8ea9df7baf40393dc49ae84c808573e080dba5a0ffb0f6e2a0cc59506d9845d8d7ab79b9657a38eb7e1427586cd563463f790dd88fbce40
7
+ data.tar.gz: 6181082e0b3f51da521f108f84735fed2c74cd6656629d1cdd356e69129a8aba279dca52db939720a4cdbbbf037854447dca800abad5158e78c97cfc4a35fc3f
data/lib/bob/api/api.rb CHANGED
@@ -34,7 +34,7 @@ module Bob
34
34
  response.code
35
35
  end
36
36
 
37
- def self.post_file(endpoint, file_path)
37
+ def self.post_file(endpoint, file_path) # rubocop:disable Metrics/MethodLength
38
38
  url = build_url(endpoint)
39
39
  payload = {
40
40
  multipart: true,
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bob
4
+ module Employee
5
+ class EmploymentHistory < API
6
+ def self.all(employee_id)
7
+ response = get("people/#{employee_id}/employment")
8
+ EmploymentHistoryParser.new(response).work_histories
9
+ end
10
+
11
+ def self.create(employee_id, params)
12
+ post("people/#{employee_id}/employment", params)
13
+ end
14
+
15
+ def self.update(employee_id, employment_entry_id, params)
16
+ put(
17
+ "people/#{employee_id}/employment/#{employment_entry_id}",
18
+ params,
19
+ use_api_key: true
20
+ )
21
+ end
22
+
23
+ def self.remove(employee_id, employment_entry_id)
24
+ delete("people/#{employee_id}/employment/#{employment_entry_id}")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -12,8 +12,12 @@ module Bob
12
12
  post("people/#{employee_id}/equities", params)
13
13
  end
14
14
 
15
+ def self.update(employee_id, entry_id, params)
16
+ put("people/#{employee_id}/equities/#{entry_id}", params)
17
+ end
18
+
15
19
  def self.remove(employee_id, entry_id)
16
- delete("people/#{employee_id}/salaries/#{entry_id}")
20
+ delete("people/#{employee_id}/equities/#{entry_id}")
17
21
  end
18
22
  end
19
23
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bob
4
+ module Employee
5
+ class TimeOff < API
6
+ def self.balance(employee_id:, policy_type:, date:)
7
+ response = get("timeoff/employees/#{employee_id}/balance", { policyType: policy_type, date: date })
8
+ BaseParser.new(response).fields
9
+ end
10
+ end
11
+ end
12
+ end
@@ -8,6 +8,10 @@ module Bob
8
8
  WorkHistoryParser.new(response).work_histories
9
9
  end
10
10
 
11
+ def self.create(employee_id, params)
12
+ post("people/#{employee_id}/work", params)
13
+ end
14
+
11
15
  def self.update(employee_id, work_history_id, params)
12
16
  put(
13
17
  "people/#{employee_id}/work/#{work_history_id}",
@@ -15,6 +19,10 @@ module Bob
15
19
  use_api_key: true
16
20
  )
17
21
  end
22
+
23
+ def self.remove(employee_id, work_history_id)
24
+ delete("people/#{employee_id}/work/#{work_history_id}")
25
+ end
18
26
  end
19
27
  end
20
28
  end
@@ -8,6 +8,8 @@ require_relative 'employee/documents'
8
8
  require_relative 'employee/variable_payments'
9
9
  require_relative 'employee/work_history'
10
10
  require_relative 'employee/lifecycle_history'
11
+ require_relative 'employee/time_off'
12
+ require_relative 'employee/employment_history'
11
13
 
12
14
  module Bob
13
15
  class Employees < API
@@ -16,6 +18,15 @@ module Bob
16
18
  EmployeeParser.new(response).employees
17
19
  end
18
20
 
21
+ def self.all_leavers(start_date:, end_date:)
22
+ all({ includeHumanReadable: true, showInactive: true }).select do |employee|
23
+ next unless employee.internal.status == 'Inactive' && employee.internal.termination_date.present?
24
+
25
+ termination_date = Date.parse(employee.internal.termination_date)
26
+ (start_date..end_date).include?(termination_date)
27
+ end
28
+ end
29
+
19
30
  def self.all_people_managers(params = { includeHumanReadable: true })
20
31
  response = get('people', params)
21
32
  EmployeeParser.new(response).managers
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Models
4
4
  class Base
5
- def initialize(raw)
5
+ def initialize(raw) # rubocop:disable Metrics/AbcSize
6
6
  attributes = Bob::Util.underscorize_hash(raw)
7
7
 
8
8
  attributes.each do |k, v|
9
- k = "field_#{k}" if k.class == String && k.to_i > 0
9
+ k = "field_#{k}" if k.instance_of?(String) && k.to_i.positive?
10
10
  instance_variable_set("@#{k}", v.is_a?(Hash) ? Models::Base.new(v) : v)
11
11
  self.class.send(:define_method, k, proc { instance_variable_get("@#{k}") })
12
12
  self.class.send(:define_method, "#{k}=", proc { |val| instance_variable_set("@#{k}", val) })
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Models
4
+ class EmploymentHistory < Models::Base
5
+ end
6
+ end
data/lib/bob/models.rb CHANGED
@@ -12,3 +12,4 @@ require_relative 'models/company_field'
12
12
  require_relative 'models/onboarding_wizard'
13
13
  require_relative 'models/work_history'
14
14
  require_relative 'models/lifecycle_history'
15
+ require_relative 'models/employment_history'
@@ -6,4 +6,8 @@ class BaseParser
6
6
  def initialize(json_response)
7
7
  @json_response = json_response
8
8
  end
9
+
10
+ def fields
11
+ Models::Base.new(json_response)
12
+ end
9
13
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class EmploymentHistoryParser < BaseParser
4
+ def employment_histories
5
+ json_response['values'].map { |attributes| Models::EmploymentHistory.new(attributes) }
6
+ end
7
+ end
data/lib/bob/parsers.rb CHANGED
@@ -12,3 +12,4 @@ require_relative 'parsers/company_field_parser'
12
12
  require_relative 'parsers/onboarding_wizard_parser'
13
13
  require_relative 'parsers/work_history_parser'
14
14
  require_relative 'parsers/lifecycle_history_parser'
15
+ require_relative 'parsers/employment_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.15'
4
+ VERSION = '0.5.18'
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.15
4
+ version: 0.5.18
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-07-26 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -64,10 +64,12 @@ files:
64
64
  - lib/bob.rb
65
65
  - lib/bob/api/api.rb
66
66
  - lib/bob/api/employee/documents.rb
67
+ - lib/bob/api/employee/employment_history.rb
67
68
  - lib/bob/api/employee/equity_grants.rb
68
69
  - lib/bob/api/employee/invites.rb
69
70
  - lib/bob/api/employee/lifecycle_history.rb
70
71
  - lib/bob/api/employee/salaries.rb
72
+ - lib/bob/api/employee/time_off.rb
71
73
  - lib/bob/api/employee/trainings.rb
72
74
  - lib/bob/api/employee/variable_payments.rb
73
75
  - lib/bob/api/employee/work_history.rb
@@ -84,6 +86,7 @@ files:
84
86
  - lib/bob/models/company_field.rb
85
87
  - lib/bob/models/company_list.rb
86
88
  - lib/bob/models/employee.rb
89
+ - lib/bob/models/employment_history.rb
87
90
  - lib/bob/models/equity_grant.rb
88
91
  - lib/bob/models/lifecycle_history.rb
89
92
  - lib/bob/models/onboarding_wizard.rb
@@ -97,6 +100,7 @@ files:
97
100
  - lib/bob/parsers/company_field_parser.rb
98
101
  - lib/bob/parsers/company_list_parser.rb
99
102
  - lib/bob/parsers/employee_parser.rb
103
+ - lib/bob/parsers/employment_history_parser.rb
100
104
  - lib/bob/parsers/equity_grant_parser.rb
101
105
  - lib/bob/parsers/lifecycle_history_parser.rb
102
106
  - lib/bob/parsers/onboarding_wizard_parser.rb
@@ -129,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
133
  - !ruby/object:Gem::Version
130
134
  version: '0'
131
135
  requirements: []
132
- rubygems_version: 3.3.7
136
+ rubygems_version: 3.2.31
133
137
  signing_key:
134
138
  specification_version: 4
135
139
  summary: Ruby gem for Bob API