stackone_migration 1.1.1 → 1.1.3
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/Gemfile.lock +1 -1
- data/lib/stackone_migration/api/employees_api.rb +4 -0
- data/lib/stackone_migration/mappers/employees_mapper.rb +24 -3
- data/lib/stackone_migration/version.rb +1 -1
- data/spec/api/employees_api_spec.rb +13 -0
- data/spec/mappers/employees_mapper_spec.rb +14 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25950523963447ffa6f328fbe08421eee74bea1a7e1628994ee2f9466094a5d2
|
4
|
+
data.tar.gz: 607c8e0ca9a6bc7d0b758c03e53de4361dc8e22a4ba52ccf2b518a0ec831991e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3c923c543fabbdf3d5bc6b0730d2c377a3ce97bf21a669bf626252d1b3c5b057b96226adc91841601a176fdd4ecffbfaca1c8fa9f32a103945c4de3418cc536
|
7
|
+
data.tar.gz: cf932f7d1ba001587931f163195c07ff85868c7b04f71465473a8b6d9ea297e4869b72cb7fd6d352a201df78b60e9337c1ea7372ba008ca985230f40f57d6d9b
|
data/Gemfile.lock
CHANGED
@@ -9,6 +9,10 @@ module MergeHRISClient
|
|
9
9
|
def employees_list(x_account_id, opts = {})
|
10
10
|
return original_employees_list(x_account_id, opts) unless StackOneMigration::AccountHelper.stackone_account?(x_account_id)
|
11
11
|
|
12
|
+
if opts.key?(:cursor)
|
13
|
+
opts[:page] = opts.delete(:cursor)
|
14
|
+
end
|
15
|
+
|
12
16
|
if opts.key?(:remote_id)
|
13
17
|
stripped_opts = opts.reject { |k, _| k == :remote_id }
|
14
18
|
response = StackOneHRIS::EmployeesApi.new.employees_get(opts[:remote_id], x_account_id,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module StackOneMigration
|
2
4
|
class EmployeesMapper
|
3
5
|
def self.gender_enum_hash
|
@@ -108,13 +110,32 @@ module StackOneMigration
|
|
108
110
|
:hire_date => employee.hire_date,
|
109
111
|
:employment_status => MergeHRISClient::EmploymentStatusEnum.build_from_hash(employment_status_enum_hash[employee.employment_status&.to_sym]),
|
110
112
|
:termination_date => employee.termination_date,
|
111
|
-
:company => employee.company,
|
112
|
-
:home_location => employee.home_location,
|
113
|
-
:work_location => employee.work_location,
|
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),
|
114
116
|
:employments => map_employments(employee.employments),
|
115
117
|
)
|
116
118
|
end
|
117
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
|
+
|
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
|
137
|
+
end
|
138
|
+
|
118
139
|
def self.map_to_employment_model(employment)
|
119
140
|
return nil if employment.nil?
|
120
141
|
|
@@ -30,6 +30,19 @@ describe MergeHRISClient::EmployeesApi do
|
|
30
30
|
subject.employees_list('123', options)
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
context 'and the cursor param is in the options' do
|
35
|
+
it 'calls the method from the StackOne client to list employees with cursor param mapped to page' do
|
36
|
+
paginated_employees_double = double('StackOneHRIS::PaginatedEmployeeList', :data => nil, :next_page => nil)
|
37
|
+
stackone_employees_api_double = double('StackOneHRIS::EmployeesApi', :employees_list => paginated_employees_double)
|
38
|
+
allow(StackOneHRIS::EmployeesApi).to receive(:new).and_return(stackone_employees_api_double)
|
39
|
+
options = { :cursor => 'page_cursor' }
|
40
|
+
|
41
|
+
expect(stackone_employees_api_double).to receive(:employees_list).with('123', { :page => 'page_cursor' })
|
42
|
+
|
43
|
+
subject.employees_list('123', options)
|
44
|
+
end
|
45
|
+
end
|
33
46
|
end
|
34
47
|
end
|
35
48
|
|
@@ -24,19 +24,19 @@ 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 =>
|
29
|
-
:street_1 =>
|
30
|
-
:street_2 =>
|
31
|
-
:city =>
|
32
|
-
:state =>
|
33
|
-
:zip_code =>
|
34
|
-
:country =>
|
35
|
-
},
|
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
|
+
}",
|
36
36
|
:work_location => nil,
|
37
|
-
:company => {
|
38
|
-
display_name:
|
39
|
-
},
|
37
|
+
:company => "{
|
38
|
+
\"display_name\": \"StackOne\"
|
39
|
+
}",
|
40
40
|
:employments => [
|
41
41
|
{
|
42
42
|
job_title: 'Manager',
|
@@ -96,7 +96,7 @@ describe StackOneMigration::EmployeesMapper do
|
|
96
96
|
:manager => '417b5e62-e011-5e69-a906-0aefade9ded1',
|
97
97
|
:home_location => {
|
98
98
|
phone_number: '(456) 787-3508',
|
99
|
-
street_1: '123 Main St',
|
99
|
+
street_1: '123 Main\' St',
|
100
100
|
street_2: 'Apt 1',
|
101
101
|
city: 'San Francisco',
|
102
102
|
state: 'CA',
|
@@ -105,7 +105,7 @@ describe StackOneMigration::EmployeesMapper do
|
|
105
105
|
},
|
106
106
|
:work_location => nil,
|
107
107
|
:company => {
|
108
|
-
|
108
|
+
display_name: 'StackOne',
|
109
109
|
},
|
110
110
|
)
|
111
111
|
expect(target_model.gender).to have_attributes(:value => 'FEMALE')
|
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.
|
4
|
+
version: 1.1.3
|
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-
|
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
|