peoplegroup-connectors 0.1.80 → 0.1.81

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: 1657c1be5b83e1b2d1f0a1e84a3c624a5ab0a83c3225501c3f4d07e38ac7f8c4
4
- data.tar.gz: b5a16f29f83019c45e384cbb82b3cf97f67d6684b113073d870ea9d6d3ce4e85
3
+ metadata.gz: 59bf4a7262edf9f57f6cb78d1af2c51f26878aa2b03c5024e0675f34f7325b2d
4
+ data.tar.gz: 4ca9690f2e103c0435cdcb2ad92ff782a2c777ffcf82aab0737f0fa0e0e8272b
5
5
  SHA512:
6
- metadata.gz: cbf02b91924e3bad79e6bcbcd03f9894e41cf28d7778d0e0086f0c9b5e319c880f8cd7b9e1a62fbf0f6f003d79826d352fb238cea291a1968a72bb2983fcabc0
7
- data.tar.gz: 4a51bfe8a81f8ebd01c3ed80b5ca638a1a7488634a77c48e8cd50c5459d20c80d4a1232a2843f6e2313b18ddaa4b125209330f04900429ce3bedb85e1adee7aa
6
+ metadata.gz: 5ac63c2ce2f22471a1ba87af06621243a0ef62ac0922ff4af153a31fa04e6bf7c6dc414c1b59a245e6120e273694f43c755e596a9930c7d51dbb9a1f8f930421
7
+ data.tar.gz: fb23d5463e6bb43775698dce503de8ccd55a2d6c30dcfdeb7e3916d5dff57e62a785c8294eafd03e633693f94bbd1df1891fcfa4c03da6aaa61bdc857d8d2f8e
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PeopleGroup
4
4
  module Connectors
5
- VERSION = '0.1.80'
5
+ VERSION = '0.1.81'
6
6
  end
7
7
  end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'savon'
4
+
5
+ module PeopleGroup
6
+ module Connectors
7
+ class Workday
8
+ attr_accessor :client, :subdomain, :tenant
9
+
10
+ API_VERSION = 'v37.0'
11
+ MAX_RESULTS_PER_PAGE = 999
12
+
13
+ EmployeeNotFoundError = Class.new(StandardError)
14
+
15
+ def initialize
16
+ @subdomain = ENV['WORKDAY_SUBDOMAIN']
17
+ @tenant = ENV['WORKDAY_TENANT']
18
+ isu_username = ENV['WORKDAY_ISU_USERNAME']
19
+ isu_password = ENV['WORKDAY_ISU_PASSWORD']
20
+ soap_debug_logs_enabled = ENV['WORKDAY_SOAP_DEBUG_LOGS'].present?
21
+
22
+ @client = Savon.client(
23
+ wsdl: "https://#{@subdomain}.workday.com/ccx/service/#{@tenant}/Human_Resources/#{API_VERSION}?wsdl",
24
+ log: soap_debug_logs_enabled,
25
+ wsse_auth: ["#{isu_username}@#{@tenant}", isu_password],
26
+ pretty_print_xml: true,
27
+ convert_request_keys_to: :camelcase,
28
+ env_namespace: :env,
29
+ namespace_identifier: nil,
30
+ namespaces: {
31
+ 'xmlns' => nil,
32
+ 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/',
33
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
34
+ 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
35
+ }
36
+ )
37
+ end
38
+
39
+ def workers
40
+ retry_on_error do
41
+ @workers ||= auto_paginated_call(:get_workers, { message_tag: 'wd:Get_Workers_Request', attributes: attributes })
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def retry_on_error(&block)
48
+ Utils.retry_on_error(errors: [Net::ReadTimeout], delay: 3, &block)
49
+ end
50
+
51
+ def auto_paginated_call(operation_name, locals = {}, &block)
52
+ data = nil
53
+ page = 1
54
+
55
+ loop do
56
+ message = locals[:message] || {}
57
+ message_with_pagination_parameters = { **message, **pagination_parameters(page) }
58
+ response = @client.call(operation_name, { **locals, message: message_with_pagination_parameters }, &block)
59
+
60
+ # The response hash contains only one key named after the operation performed
61
+ # eg. get_workers_response
62
+ _operation_response_name, operation_result = response.to_hash.first
63
+
64
+ page = operation_result.dig(:response_results, :page).to_i
65
+ total_pages = operation_result.dig(:response_results, :total_pages).to_i
66
+
67
+ # The operation data hash contains only one key named after the Workday object(s) retrieved
68
+ # eg. worker
69
+ _object_label, partial_data = operation_result[:response_data].first
70
+
71
+ if page == 1
72
+ data = partial_data
73
+ else
74
+ data.concat(partial_data)
75
+ end
76
+
77
+ break if page == total_pages
78
+
79
+ page += 1
80
+ end
81
+
82
+ data
83
+ end
84
+
85
+ def pagination_parameters(page = 1, results_per_page = MAX_RESULTS_PER_PAGE)
86
+ {
87
+ 'wd:Response_Filter' => {
88
+ 'wd:Page' => page,
89
+ 'wd:Count' => results_per_page
90
+ }
91
+ }
92
+ end
93
+
94
+ def attributes
95
+ {
96
+ 'xmlns:wd' => 'urn:com.workday/bsvc',
97
+ 'wd:version' => API_VERSION
98
+ }
99
+ end
100
+ end
101
+ end
102
+ end
@@ -7,6 +7,7 @@ require_relative 'connectors/slack'
7
7
  require_relative 'connectors/pto_roots'
8
8
  require_relative 'connectors/bamboo'
9
9
  require_relative 'connectors/greenhouse'
10
+ require_relative 'connectors/workday'
10
11
  require_relative 'utils'
11
12
 
12
13
  module PeopleGroup
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peoplegroup-connectors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.80
4
+ version: 0.1.81
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: 2021-11-11 00:00:00.000000000 Z
11
+ date: 2021-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '2.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: savon
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.12.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 2.12.1
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rspec
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -182,6 +196,7 @@ files:
182
196
  - lib/peoplegroup/connectors/pto_roots.rb
183
197
  - lib/peoplegroup/connectors/slack.rb
184
198
  - lib/peoplegroup/connectors/version.rb
199
+ - lib/peoplegroup/connectors/workday.rb
185
200
  - lib/peoplegroup/utils.rb
186
201
  homepage: https://gitlab.com/gitlab-com/people-group/peopleops-eng/connectors-gem
187
202
  licenses: