stackone_migration 1.2.0 → 1.2.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: d01ae0e3ccadc71617ac37d478e5f89262e592c743f68b5647154da2278baf23
4
- data.tar.gz: 19668886873b5d119f03626366f638f38e6c5611869cdf71ff571d563e009975
3
+ metadata.gz: 7ed058e52bc6531d4776c4309fa4a63c1f17c050cf7a3a79cbdd5cdb126314a2
4
+ data.tar.gz: dc2432ab2547c52815d94de47f2e837937e47035b0ec582f723a547c00050596
5
5
  SHA512:
6
- metadata.gz: '09e0cd27d2761358d6e282ca3ddb1a813c0c477a7aec8b90e812ff798eac8a3048aa1fb42c3f8fec69a80f33749e367bfa6488c269024960fedeac3c15fcbabc'
7
- data.tar.gz: 6424f9d55b1f7f7ff4f1189c9471ee47811c943b54cef7e40087ec1dbbf9b54dc9f06b32ddd33e3687d2fddfd0881d0616bb2db24cedca90f8d7dd5955cacc67
6
+ metadata.gz: bd971a17ee5e0ae0788e75ed6203ec7cf0907988c3e8c6ffab34bd29c1dde4487184a7161a68b3a1c7e1bbea3cf1a8f55a62a9b80a1b0d7816897752881bbce6
7
+ data.tar.gz: 799d35be2943ac5678d2bdf1c4e2ce09269c09fe736bc89480fa62d981318eec8a2ac7bf02f464145961188b868dda0a969ddf3b3aa8cc8634ecbdce2c297aa6
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.3.0'
14
+ gem 'stackone_hris_client', '~> 1.3.2'
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stackone_migration (1.2.0)
4
+ stackone_migration (1.2.2)
5
5
  merge_hris_client (~> 3.0)
6
- stackone_hris_client (~> 1.3.0)
6
+ stackone_hris_client (~> 1.3.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.3.0)
61
+ stackone_hris_client (1.3.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.3.0)
76
+ stackone_hris_client (~> 1.3.2)
77
77
  stackone_migration!
78
78
 
79
79
  BUNDLED WITH
@@ -110,43 +110,41 @@ module StackOneMigration
110
110
  :hire_date => employee.hire_date,
111
111
  :employment_status => MergeHRISClient::EmploymentStatusEnum.build_from_hash(employment_status_enum_hash[employee.employment_status&.to_sym]),
112
112
  :termination_date => employee.termination_date,
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),
113
+ :home_location => map_to_location_model(employee.home_location),
114
+ :work_location => map_to_location_model(employee.work_location),
116
115
  :employments => map_employments(employee.employments),
117
116
  )
118
117
  end
119
118
 
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
-
129
- hash = JSON.parse(new_str)
130
-
131
- hash.transform_keys(&:to_sym)
132
- rescue JSON::ParserError => e
133
- puts "Error parsing JSON string: #{e.message}"
134
-
135
- hash_string
136
- end
119
+ def self.map_to_location_model(location)
120
+ return nil if location.nil?
121
+
122
+ MergeHRISClient::Location.new(
123
+ :id => location.id,
124
+ :remote_id => location.id,
125
+ :name => location.name,
126
+ :phone_number => location.phone_number,
127
+ :street_1 => location.street_1,
128
+ :street_2 => location.street_2,
129
+ :city => location.city,
130
+ :state => location.state,
131
+ :zip_code => location.zip_code,
132
+ :country => MergeHRISClient::CountryEnum.build_from_hash(location.country),
133
+ :location_type => MergeHRISClient::LocationTypeEnum.build_from_hash(location_type_enum_hash[location.location_type&.to_sym]),
134
+ )
137
135
  end
138
136
 
139
137
  def self.map_to_employment_model(employment)
140
138
  return nil if employment.nil?
141
139
 
142
140
  MergeHRISClient::Employment.new(
143
- :job_title => employment[:job_title],
144
- :pay_rate => employment[:pay_rate],
145
- :pay_period => MergeHRISClient::PayPeriodEnum.build_from_hash(pay_period_enum_hash[employment[:pay_period]&.to_sym]),
146
- :pay_frequency => MergeHRISClient::PayFrequencyEnum.build_from_hash(pay_frequency_enum_hash[employment[:pay_frequency]&.to_sym]),
147
- :pay_currency => MergeHRISClient::PayCurrencyEnum.build_from_hash(employment[:pay_currency]&.to_s.upcase),
148
- :effective_date => employment[:effective_date],
149
- :employment_type => MergeHRISClient::EmploymentTypeEnum.build_from_hash(employment_type_enum_hash[employment[:employment_type]&.to_sym]),
141
+ :job_title => employment.job_title,
142
+ :pay_rate => employment.pay_rate,
143
+ :pay_period => MergeHRISClient::PayPeriodEnum.build_from_hash(pay_period_enum_hash[employment.pay_period&.to_sym]),
144
+ :pay_frequency => MergeHRISClient::PayFrequencyEnum.build_from_hash(pay_frequency_enum_hash[employment.pay_frequency&.to_sym]),
145
+ :pay_currency => MergeHRISClient::PayCurrencyEnum.build_from_hash(employment.pay_currency&.to_s&.upcase),
146
+ :effective_date => employment.effective_date,
147
+ :employment_type => MergeHRISClient::EmploymentTypeEnum.build_from_hash(employment_type_enum_hash[employment.employment_type&.to_sym]),
150
148
  )
151
149
  end
152
150
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StackOneMigration
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.2'
5
5
  end
@@ -24,29 +24,27 @@ describe StackOneMigration::EmployeesMapper do
24
24
  :work_phone_number => '(456) 787-3508',
25
25
  :job_title => 'Manager',
26
26
  :department => 'Human Resources',
27
- :home_location => "{
28
- :phone_number => \"(456) 787-3508\",
29
- :street_1 => \"123 Main' St\",
30
- :street_2 => \"Apt 1\",
31
- :city => \"San Francisco\",
32
- :state => \"CA\",
33
- :zip_code => \"94105\",
34
- :country => \"US\"
35
- }",
27
+ :home_location =>
28
+ StackOneHRIS::Location.new(
29
+ :phone_number => "(456) 787-3508",
30
+ :street_1 => "123 Main' St",
31
+ :street_2 => "Apt 1",
32
+ :city => "San Francisco",
33
+ :state => "CA",
34
+ :zip_code => "94105",
35
+ :country => "US"
36
+ ),
36
37
  :work_location => nil,
37
- :company => "{
38
- \"display_name\": \"StackOne\"
39
- }",
40
38
  :employments => [
41
- {
42
- job_title: 'Manager',
43
- pay_rate: 100000,
44
- pay_period: 'yearly',
45
- pay_frequency: 'weekly',
46
- pay_currency: 'USD',
47
- effective_date: '2018-01-01',
48
- employee_type: 'full_time',
49
- }
39
+ StackOneHRIS::Employment.new(
40
+ :job_title => 'Manager',
41
+ :pay_rate => 100000,
42
+ :pay_period => 'year',
43
+ :pay_frequency => 'weekly',
44
+ :pay_currency => 'USD',
45
+ :effective_date => '2018-01-01',
46
+ :employment_type => 'full_time',
47
+ )
50
48
  ]
51
49
  )
52
50
  }
@@ -94,19 +92,8 @@ describe StackOneMigration::EmployeesMapper do
94
92
  :date_of_birth => '1990-01-01',
95
93
  :start_date => '2018-01-01',
96
94
  :manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
97
- :home_location => {
98
- phone_number: '(456) 787-3508',
99
- street_1: '123 Main\' St',
100
- street_2: 'Apt 1',
101
- city: 'San Francisco',
102
- state: 'CA',
103
- zip_code: '94105',
104
- country: 'US',
105
- },
106
95
  :work_location => nil,
107
- :company => {
108
- display_name: 'StackOne',
109
- },
96
+ :company => nil,
110
97
  )
111
98
  expect(target_model.gender).to have_attributes(:value => 'FEMALE')
112
99
  expect(target_model.ethnicity).to have_attributes(:value => 'WHITE')
@@ -123,33 +110,80 @@ describe StackOneMigration::EmployeesMapper do
123
110
  end
124
111
  end
125
112
 
113
+ context '.map_to_location_model' do
114
+ it 'maps a location to correct class' do
115
+ sample_location = StackOneHRIS::Location.new(
116
+ :phone_number => "(456) 787-3508",
117
+ :street_1 => "123 Main' St",
118
+ :street_2 => "Apt 1",
119
+ :city => "San Francisco",
120
+ :state => "CA",
121
+ :zip_code => "94105",
122
+ :country => "US"
123
+ )
124
+
125
+ target_model = described_class.map_to_location_model(sample_location)
126
+
127
+ expect(target_model).to be_a(MergeHRISClient::Location)
128
+ end
129
+
130
+ it 'maps a location with the right attributes' do
131
+ sample_location = StackOneHRIS::Location.new(
132
+ :id => '123',
133
+ :name => 'David Leonard',
134
+ :phone_number => "(456) 787-3508",
135
+ :street_1 => "123 Main' St",
136
+ :street_2 => "Apt 1",
137
+ :city => "San Francisco",
138
+ :state => "CA",
139
+ :zip_code => "94105",
140
+ :country => "US",
141
+ :location_type => 'home'
142
+ )
143
+
144
+ target_model = described_class.map_to_location_model(sample_location)
145
+
146
+ expect(target_model.id).to eq('123')
147
+ expect(target_model.remote_id).to eq('123')
148
+ expect(target_model.name).to eq('David Leonard')
149
+ expect(target_model.phone_number).to eq('(456) 787-3508')
150
+ expect(target_model.street_1).to eq("123 Main' St")
151
+ expect(target_model.street_2).to eq("Apt 1")
152
+ expect(target_model.city).to eq("San Francisco")
153
+ expect(target_model.state).to eq("CA")
154
+ expect(target_model.zip_code).to eq("94105")
155
+ expect(target_model.country).to have_attributes(:raw_value => 'US')
156
+ expect(target_model.location_type).to have_attributes(:value => 'HOME')
157
+ end
158
+ end
159
+
126
160
  context '.map_to_employment_model' do
127
- it 'maps a employeement hash to correct class' do
128
- sample_employment = {
129
- job_title: 'Manager',
130
- pay_rate: 100000,
131
- pay_period: 'yearly',
132
- pay_frequency: 'weekly',
133
- pay_currency: 'USD',
134
- effective_date: '2018-01-01',
135
- employment_type: 'full_time',
136
- }
161
+ it 'maps a employeement to correct class' do
162
+ sample_employment = StackOneHRIS::Employment.new(
163
+ :job_title => 'Manager',
164
+ :pay_rate => 100000,
165
+ :pay_period => 'year',
166
+ :pay_frequency => 'weekly',
167
+ :pay_currency => 'USD',
168
+ :effective_date => '2018-01-01',
169
+ :employment_type => 'full_time',
170
+ )
137
171
 
138
172
  target_model = described_class.map_to_employment_model(sample_employment)
139
173
 
140
174
  expect(target_model).to be_a(MergeHRISClient::Employment)
141
175
  end
142
176
 
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
- }
177
+ it 'maps a employeement with the right attributes' do
178
+ sample_employment = StackOneHRIS::Employment.new(
179
+ :job_title => 'Manager',
180
+ :pay_rate => 100000,
181
+ :pay_period => 'year',
182
+ :pay_frequency => 'weekly',
183
+ :pay_currency => 'USD',
184
+ :effective_date => '2018-01-01',
185
+ :employment_type => 'full_time',
186
+ )
153
187
 
154
188
  target_model = described_class.map_to_employment_model(sample_employment)
155
189
 
@@ -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.3.0'
19
+ s.add_runtime_dependency 'stackone_hris_client', '~> 1.3.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.2.0
4
+ version: 1.2.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-04-20 00:00:00.000000000 Z
11
+ date: 2023-05-03 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.3.0
33
+ version: 1.3.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.3.0
40
+ version: 1.3.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement