stackone_migration 1.1.0 → 1.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 732857caccb3fcb827c3bb6b8c511432fe97d18c4b514ec2d097aa7e44f9aa7d
4
- data.tar.gz: 983207ba28ea205a5ebe029b1c26885230c6f032c30827011bd031d04bc44002
3
+ metadata.gz: 3197edeffdaf152df83de7c93ebff0545a858e052b5b93ce71ee94a763e2965c
4
+ data.tar.gz: 3119c44bbf9229ca6251730d591dcd677be5437145e952b0fdf766b480dcb7e4
5
5
  SHA512:
6
- metadata.gz: ab28e35418e92cf8385382d289b80eb94f5292e0060dc50e2f1b31d82991b61c78b23c234886914e6733d1c648f5ba4b1bc80a8c08fa2b65a57ff3b65598e68a
7
- data.tar.gz: 2915504869e7b58a8df5d6eab55f85445f34327536de752e8ff4fc1cb93aea9489bcc35366d1feb8f135398fb33f63d711d22f8fc1948ef09b899cae9e10893d
6
+ metadata.gz: 67ef8e7855f098123b1e73d9dab35f5d221e64800cdeaceb66aac58123f7b0cd06add2502e68a27e161603be2999e6927b504366fe192b136fb2f8a172bea405
7
+ data.tar.gz: 4fdc3504c3ac5b670803985f365fb888a4922d3d4fe1a37cad0a8e3b782259cbb35a611a16070cdc7ebf77c6574c36f9c577fbb97ea9c95a72cce50d09e573ce
data/Gemfile CHANGED
@@ -11,4 +11,4 @@ group :development, :test do
11
11
  end
12
12
 
13
13
  gem 'merge_hris_client', '~> 3.0'
14
- gem 'stackone_hris_client', '~> 1.2.1'
14
+ gem 'stackone_hris_client', '~> 1.2.2'
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stackone_migration (1.1.0)
4
+ stackone_migration (1.1.2)
5
5
  merge_hris_client (~> 3.0)
6
- stackone_hris_client (~> 1.2.1)
6
+ stackone_hris_client (~> 1.2.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -58,7 +58,7 @@ GEM
58
58
  rubocop-ast (1.27.0)
59
59
  parser (>= 3.2.1.0)
60
60
  ruby-progressbar (1.13.0)
61
- stackone_hris_client (1.2.0)
61
+ stackone_hris_client (1.2.2)
62
62
  typhoeus (~> 1.0, >= 1.0.1)
63
63
  typhoeus (1.4.0)
64
64
  ethon (>= 0.9.0)
@@ -73,7 +73,7 @@ DEPENDENCIES
73
73
  rake (~> 13.0.1)
74
74
  rspec (~> 3.6, >= 3.6.0)
75
75
  rubocop (~> 1.48.0)
76
- stackone_hris_client (~> 1.2.1)
76
+ stackone_hris_client (~> 1.2.2)
77
77
  stackone_migration!
78
78
 
79
79
  BUNDLED WITH
@@ -1,5 +1,93 @@
1
+ require 'json'
2
+
1
3
  module StackOneMigration
2
4
  class EmployeesMapper
5
+ def self.gender_enum_hash
6
+ {
7
+ :male => 'MALE',
8
+ :female => 'FEMALE',
9
+ :non_binary => 'NON-BINARY',
10
+ :other => 'OTHER',
11
+ :not_disclosed => 'PREFER_NOT_TO_DISCLOSE',
12
+ }
13
+ end
14
+
15
+ def self.marital_status_enum_hash
16
+ {
17
+ :single => 'SINGLE',
18
+ :married => 'MARRIED_FILING_JOINTLY',
19
+ :divorced => 'MERGE_NONSTANDARD_VALUE',
20
+ :widowed => 'QUALIFYING_WIDOW_OR_WIDOWER_WITH_DEPENDENT_CHILD',
21
+ :domestic_partnership => 'MERGE_NONSTANDARD_VALUE',
22
+ :other => 'MERGE_NONSTANDARD_VALUE',
23
+ }
24
+ end
25
+
26
+ def self.ethnicity_enum_hash
27
+ {
28
+ :white => 'WHITE',
29
+ :black_or_african_american => 'BLACK_OR_AFRICAN_AMERICAN',
30
+ :asian => 'ASIAN_OR_INDIAN_SUBCONTINENT',
31
+ :hispanic_or_latino => 'HISPANIC_OR_LATINO',
32
+ :american_indian_or_alaska_native => 'AMERICAN_INDIAN_OR_ALASKA_NATIVE',
33
+ :native_hawaiian_or_pacific_islander => 'NATIVE_HAWAIIAN_OR_OTHER_PACIFIC_ISLANDER',
34
+ :two_or_more_races => 'TWO_OR_MORE_RACES',
35
+ :not_disclosed => 'PREFER_NOT_TO_DISCLOSE',
36
+ }
37
+ end
38
+
39
+ def self.employment_status_enum_hash
40
+ {
41
+ :active => 'ACTIVE',
42
+ :pending => 'PENDING',
43
+ :terminated => 'INACTIVE',
44
+ }
45
+ end
46
+
47
+ def self.employment_type_enum_hash
48
+ {
49
+ :full_time => 'FULL_TIME',
50
+ :part_time => 'PART_TIME',
51
+ :contractor => 'CONTRACTOR',
52
+ :intern => 'INTERN',
53
+ :freelance => 'FREELANCE',
54
+ :terminated => 'MERGE_NONSTANDARD_VALUE',
55
+ }
56
+ end
57
+
58
+ def self.pay_period_enum_hash
59
+ {
60
+ :hour => 'HOUR',
61
+ :day => 'DAY',
62
+ :week => 'WEEK',
63
+ :every_two_weeks => 'EVERY_TWO_WEEKS',
64
+ :month => 'MONTH',
65
+ :quarter => 'QUARTER',
66
+ :every_six_months => 'EVERY_SIX_MONTHS',
67
+ :year => 'YEAR',
68
+ }
69
+ end
70
+
71
+ def self.pay_frequency_enum_hash
72
+ {
73
+ :weekly => 'WEEKLY',
74
+ :bi_weekly => 'BIWEEKLY',
75
+ :monthly => 'MONTHLY',
76
+ :quarterly => 'QUARTERLY',
77
+ :semi_annually => 'SEMIANNUALLY',
78
+ :yearly => 'ANNUALLY',
79
+ :thirteen_monthly => 'THIRTEEN-MONTHLY',
80
+ :pro_rata => 'PRO_RATA',
81
+ }
82
+ end
83
+
84
+ def self.location_type_enum_hash
85
+ {
86
+ :home => 'HOME',
87
+ :work => 'WORK',
88
+ }
89
+ end
90
+
3
91
  def self.map_to_employee_model(employee)
4
92
  return nil if employee.nil?
5
93
 
@@ -13,22 +101,66 @@ module StackOneMigration
13
101
  :personal_email => employee.personal_email,
14
102
  :work_email => employee.work_email,
15
103
  :mobile_phone_number => employee.personal_phone_number,
16
- :gender => employee.gender,
104
+ :gender => MergeHRISClient::GenderEnum.build_from_hash(gender_enum_hash[employee.gender&.to_sym]),
17
105
  :date_of_birth => employee.date_of_birth,
18
106
  :start_date => employee.start_date,
19
107
  :manager => employee.manager_id,
20
- :ethnicity => employee.ethnicity,
21
- :marital_status => employee.marital_status,
108
+ :ethnicity => MergeHRISClient::EthnicityEnum.build_from_hash(ethnicity_enum_hash[employee.ethnicity&.to_sym]),
109
+ :marital_status => MergeHRISClient::MaritalStatusEnum.build_from_hash(marital_status_enum_hash[employee.marital_status&.to_sym]),
22
110
  :hire_date => employee.hire_date,
23
- :employment_status => employee.employment_status,
111
+ :employment_status => MergeHRISClient::EmploymentStatusEnum.build_from_hash(employment_status_enum_hash[employee.employment_status&.to_sym]),
24
112
  :termination_date => employee.termination_date,
25
- :company => employee.company,
26
- :home_location => employee.home_location,
27
- :work_location => employee.work_location,
28
- :employments => employee.employments,
113
+ :company => json_str_to_hash(employee.company),
114
+ :home_location => json_str_to_hash(employee.home_location),
115
+ :work_location => json_str_to_hash(employee.work_location),
116
+ :employments => map_employments(employee.employments),
29
117
  )
30
118
  end
31
119
 
120
+ def self.json_str_to_hash(hash_string)
121
+ begin
122
+ return nil if hash_string.nil?
123
+
124
+ new_str = hash_string
125
+ .gsub(/:(\w+)/, '"\1"')
126
+ .gsub('=>', ':')
127
+ .gsub('nil', 'null')
128
+ .gsub(/'/, '"')
129
+
130
+ hash = JSON.parse(new_str)
131
+
132
+ hash.transform_keys(&:to_sym)
133
+ rescue JSON::ParserError => e
134
+ puts "Error parsing JSON string: #{e.message}"
135
+
136
+ hash_string
137
+ end
138
+ end
139
+
140
+ def self.map_to_employment_model(employment)
141
+ return nil if employment.nil?
142
+
143
+ MergeHRISClient::Employment.new(
144
+ :job_title => employment[:job_title],
145
+ :pay_rate => employment[:pay_rate],
146
+ :pay_period => MergeHRISClient::PayPeriodEnum.build_from_hash(pay_period_enum_hash[employment[:pay_period]&.to_sym]),
147
+ :pay_frequency => MergeHRISClient::PayFrequencyEnum.build_from_hash(pay_frequency_enum_hash[employment[:pay_frequency]&.to_sym]),
148
+ :pay_currency => MergeHRISClient::PayCurrencyEnum.build_from_hash(employment[:pay_currency]&.to_s.upcase),
149
+ :effective_date => employment[:effective_date],
150
+ :employment_type => MergeHRISClient::EmploymentTypeEnum.build_from_hash(employment_type_enum_hash[employment[:employment_type]&.to_sym]),
151
+ )
152
+ end
153
+
154
+ def self.map_employments(employments)
155
+ if employments.nil?
156
+ mapped_results = []
157
+ else
158
+ mapped_results = employments.map do |employment|
159
+ map_to_employment_model(employment)
160
+ end
161
+ end
162
+ end
163
+
32
164
  def self.map_single_employee_to_list_model(employee)
33
165
  mapped_employee = map_to_employee_model(employee)
34
166
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StackOneMigration
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.2'
5
5
  end
@@ -18,22 +18,25 @@ describe StackOneMigration::EmployeesMapper do
18
18
  :date_of_birth => '1990-01-01',
19
19
  :start_date => '2018-01-01',
20
20
  :manager_id => '417b5e62-e011-5e69-a906-0aefade9ded1',
21
+ :ethnicity => 'white',
22
+ :marital_status => 'married',
23
+ :employment_status => 'terminated',
21
24
  :work_phone_number => '(456) 787-3508',
22
25
  :job_title => 'Manager',
23
26
  :department => 'Human Resources',
24
- :home_location => {
27
+ :home_location => "{
25
28
  :phone_number => '(456) 787-3508',
26
29
  :street_1 => '123 Main St',
27
30
  :street_2 => 'Apt 1',
28
31
  :city => 'San Francisco',
29
32
  :state => 'CA',
30
33
  :zip_code => '94105',
31
- :country => 'US',
32
- },
34
+ :country => 'US'
35
+ }",
33
36
  :work_location => nil,
34
- :company => {
35
- display_name: 'StackOne',
36
- },
37
+ :company => "{
38
+ \"display_name\": 'StackOne'
39
+ }",
37
40
  :employments => [
38
41
  {
39
42
  job_title: 'Manager',
@@ -88,7 +91,6 @@ describe StackOneMigration::EmployeesMapper do
88
91
  :personal_email => 'ija@egje.wf',
89
92
  :work_email => 'kota@efpiphi.kw',
90
93
  :mobile_phone_number => '(715) 658-9486',
91
- :gender => 'female',
92
94
  :date_of_birth => '1990-01-01',
93
95
  :start_date => '2018-01-01',
94
96
  :manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
@@ -103,28 +105,61 @@ describe StackOneMigration::EmployeesMapper do
103
105
  },
104
106
  :work_location => nil,
105
107
  :company => {
106
- display_name: 'StackOne',
108
+ display_name: 'StackOne',
107
109
  },
108
- :employments => [
109
- {
110
+ )
111
+ expect(target_model.gender).to have_attributes(:value => 'FEMALE')
112
+ expect(target_model.ethnicity).to have_attributes(:value => 'WHITE')
113
+ expect(target_model.marital_status).to have_attributes(:value => 'MARRIED_FILING_JOINTLY')
114
+ expect(target_model.employment_status).to have_attributes(:value => 'INACTIVE')
115
+ end
116
+
117
+ context 'when the employee record to map is nil' do
118
+ it 'returns nil' do
119
+ target_model = described_class.map_to_employee_model(nil)
120
+
121
+ expect(target_model).to be_nil
122
+ end
123
+ end
124
+ end
125
+
126
+ context '.map_to_employment_model' do
127
+ it 'maps a employeement hash to correct class' do
128
+ sample_employment = {
110
129
  job_title: 'Manager',
111
130
  pay_rate: 100000,
112
131
  pay_period: 'yearly',
113
132
  pay_frequency: 'weekly',
114
133
  pay_currency: 'USD',
115
134
  effective_date: '2018-01-01',
116
- employee_type: 'full_time',
135
+ employment_type: 'full_time',
117
136
  }
118
- ]
119
- )
137
+
138
+ target_model = described_class.map_to_employment_model(sample_employment)
139
+
140
+ expect(target_model).to be_a(MergeHRISClient::Employment)
120
141
  end
121
142
 
122
- context 'when the employee record to map is nil' do
123
- it 'returns nil' do
124
- target_model = described_class.map_to_employee_model(nil)
143
+ it 'maps a employeement hash with the right attributes' do
144
+ sample_employment = {
145
+ job_title: 'Manager',
146
+ pay_rate: 100000,
147
+ pay_period: 'year',
148
+ pay_frequency: 'weekly',
149
+ pay_currency: 'usd',
150
+ effective_date: '2018-01-01',
151
+ employment_type: 'full_time',
152
+ }
125
153
 
126
- expect(target_model).to be_nil
127
- end
154
+ target_model = described_class.map_to_employment_model(sample_employment)
155
+
156
+ expect(target_model.job_title).to eq('Manager')
157
+ expect(target_model.pay_rate).to eq(100000)
158
+ expect(target_model.pay_period).to have_attributes(:value => 'YEAR')
159
+ expect(target_model.pay_frequency).to have_attributes(:value => 'WEEKLY')
160
+ expect(target_model.pay_currency).to have_attributes(:value => 'USD')
161
+ expect(target_model.effective_date).to eq('2018-01-01')
162
+ expect(target_model.employment_type).to have_attributes(:value => 'FULL_TIME')
128
163
  end
129
164
  end
130
165
 
@@ -140,48 +175,8 @@ describe StackOneMigration::EmployeesMapper do
140
175
 
141
176
  expect(target_model).to have_attributes(
142
177
  :_next => nil,
143
- :results => [
144
- MergeHRISClient::Employee.new(
145
- :id => '123',
146
- :remote_id => '123',
147
- :first_name => 'Jean',
148
- :last_name => 'Harrington',
149
- :display_full_name => 'Jean Harrington',
150
- :avatar => 'https://www.gravatar.com/avatar/0c1c0c1c0c1c0c1c0c1c0c1c0c1c0c1c?d=mm&s=200',
151
- :personal_email => 'ija@egje.wf',
152
- :work_email => 'kota@efpiphi.kw',
153
- :mobile_phone_number => '(715) 658-9486',
154
- :gender => 'female',
155
- :date_of_birth => '1990-01-01',
156
- :start_date => '2018-01-01',
157
- :manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
158
- :home_location => {
159
- phone_number: '(456) 787-3508',
160
- street_1: '123 Main St',
161
- street_2: 'Apt 1',
162
- city: 'San Francisco',
163
- state: 'CA',
164
- zip_code: '94105',
165
- country: 'US',
166
- },
167
- :work_location => nil,
168
- :company => {
169
- display_name: 'StackOne',
170
- },
171
- :employments => [
172
- {
173
- job_title: 'Manager',
174
- pay_rate: 100000,
175
- pay_period: 'yearly',
176
- pay_frequency: 'weekly',
177
- pay_currency: 'USD',
178
- effective_date: '2018-01-01',
179
- employee_type: 'full_time',
180
- }
181
- ]
182
- )
183
- ],
184
178
  :previous => nil)
179
+ expect(target_model).to include(:results)
185
180
  end
186
181
 
187
182
  context 'when the single employee record to map is nil' do
@@ -221,64 +216,9 @@ describe StackOneMigration::EmployeesMapper do
221
216
 
222
217
  expect(target_model).to have_attributes(
223
218
  :_next => 'next_page_token',
224
- :results => [
225
- MergeHRISClient::Employee.new(
226
- :id => '123',
227
- :remote_id => '123',
228
- :first_name => 'Jean',
229
- :last_name => 'Harrington',
230
- :display_full_name => 'Jean Harrington',
231
- :avatar => 'https://www.gravatar.com/avatar/0c1c0c1c0c1c0c1c0c1c0c1c0c1c0c1c?d=mm&s=200',
232
- :personal_email => 'ija@egje.wf',
233
- :work_email => 'kota@efpiphi.kw',
234
- :mobile_phone_number => '(715) 658-9486',
235
- :gender => 'female',
236
- :date_of_birth => '1990-01-01',
237
- :start_date => '2018-01-01',
238
- :manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
239
- :home_location => {
240
- phone_number: '(456) 787-3508',
241
- street_1: '123 Main St',
242
- street_2: 'Apt 1',
243
- city: 'San Francisco',
244
- state: 'CA',
245
- zip_code: '94105',
246
- country: 'US',
247
- },
248
- :work_location => nil,
249
- :company => {
250
- display_name: 'StackOne',
251
- },
252
- :employments => [
253
- {
254
- job_title: 'Manager',
255
- pay_rate: 100000,
256
- pay_period: 'yearly',
257
- pay_frequency: 'weekly',
258
- pay_currency: 'USD',
259
- effective_date: '2018-01-01',
260
- employee_type: 'full_time',
261
- }
262
- ]
263
- ),
264
- MergeHRISClient::Employee.new(
265
- :id => '456',
266
- :remote_id => '456',
267
- :first_name => 'Allie',
268
- :last_name => 'Shaw',
269
- :display_full_name => 'Allie Shaw',
270
- :avatar => 'https://www.gravatar.com/avatar/0c1c0c1c0c1c0c1c0c1c0c1c0c1c0c1c?d=mm&s=200',
271
- :personal_email => 'ija@egje.wf',
272
- :work_email => 'kota@efpiphi.kw',
273
- :mobile_phone_number => '(715) 658-9486',
274
- :gender => 'female',
275
- :date_of_birth => '1990-01-01',
276
- :start_date => '2018-01-01',
277
- :manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
278
- )
279
- ],
280
219
  :previous => nil
281
220
  )
221
+ expect(target_model.results.length).to eq(2)
282
222
  end
283
223
 
284
224
  context 'when the employee list to map is nil' do
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.required_ruby_version = '>= 2.7'
17
17
 
18
18
  s.add_runtime_dependency 'merge_hris_client', '~> 3.0'
19
- s.add_runtime_dependency 'stackone_hris_client', '~> 1.2.1'
19
+ s.add_runtime_dependency 'stackone_hris_client', '~> 1.2.2'
20
20
 
21
21
  s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
22
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackone_migration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - StackOne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-31 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: merge_hris_client
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.1
33
+ version: 1.2.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2.1
40
+ version: 1.2.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement