Class: PeopleGroup::Connectors::Workday::Client
- Inherits:
-
Object
- Object
- PeopleGroup::Connectors::Workday::Client
- Includes:
- XML::GetOrganizations, XML::RequestOneTimePayment
- Defined in:
- lib/peoplegroup/connectors/workday/client.rb
Overview
Workday client
Constant Summary collapse
- XML_NAMESPACES =
{ 'xmlns' => nil, 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' }.freeze
- API_VERSION =
Current Workday API Version
'v37.0'
- EmployeeNotFoundError =
Class.new(StandardError)
- ClientError =
Class.new(StandardError)
Constants included from XML::RequestOneTimePayment
XML::RequestOneTimePayment::DISCRETIONARY_BONUS, XML::RequestOneTimePayment::OPERATION, XML::RequestOneTimePayment::OPERATION_AS_PARAM
Constants included from XML::GetOrganizations
XML::GetOrganizations::OPERATION
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
The client instance.
-
#options ⇒ Object
readonly
Client Options.
-
#uri ⇒ Object
readonly
service uri.
Instance Method Summary collapse
-
#attributes ⇒ Object
Default Workday specific body paramaters xmlns:wd - The URN of the XMLNS file wd:version - The API Version of workday.
- #auto_paginated_call(operation_name, options = {}, &block) ⇒ Object
- #call(operation_name, options = {}, &block) ⇒ Object
-
#debug_enabled? ⇒ Boolean
Check if workday debug is enabled for the instance.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #retry_on_error(&block) ⇒ Object
-
#wsdl_url ⇒ String
The respective XML Service WSDL URL wd2-impl-services1.workday.com/ccx/service/systemreport2/gitlab/Public_Web_Services.
Methods included from XML::RequestOneTimePayment
Methods included from XML::GetOrganizations
#departments, #locations, #pay_groups, #regions
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 36 def initialize( = {}) @options = { url: ENV.fetch('WORKDAY_SERVICE_URL', nil), username: ENV.fetch('WORKDAY_ISU_USERNAME', nil), password: ENV.fetch('WORKDAY_ISU_PASSWORD', nil), debug: ENV.fetch('WORKDAY_SOAP_DEBUG_LOGS', false) }.merge!() @uri = URI.parse(@options[:url]) @uri.query = nil @instance = client(services) rescue URI::InvalidURIError raise ClientError, "Invalid service URI: #{uri}" end |
Instance Attribute Details
#instance ⇒ Object (readonly)
The client instance
22 23 24 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 22 def instance @instance end |
#options ⇒ Object (readonly)
Client Options
25 26 27 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 25 def @options end |
#uri ⇒ Object (readonly)
service uri
28 29 30 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 28 def uri @uri end |
Instance Method Details
#attributes ⇒ Object
Default Workday specific body paramaters xmlns:wd - The URN of the XMLNS file wd:version - The API Version of workday
98 99 100 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 98 def attributes { attributes: { 'xmlns:wd' => 'urn:com.workday/bsvc', 'wd:version' => API_VERSION } } end |
#auto_paginated_call(operation_name, options = {}, &block) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 63 def auto_paginated_call(operation_name, = {}, &block) data = nil page = 1 loop do response = @instance.call(operation_name, { **, **attributes }, &block) # The response hash contains only one key named after the operation performed # eg. get_workers_response _operation_response_name, operation_result = response.to_hash.first page = operation_result.dig(:response_results, :page).to_i total_pages = operation_result.dig(:response_results, :total_pages).to_i # The operation data hash contains only one key named after the Workday object(s) retrieved # eg. worker _object_label, partial_data = operation_result[:response_data].first page == 1 ? data = partial_data : data.concat(partial_data) break if page == total_pages page += 1 end data end |
#call(operation_name, options = {}, &block) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 56 def call(operation_name, = {}, &block) response = @instance.call(operation_name, { **, **attributes }, &block) { **response.body, code: response.http.code } rescue Savon::UnknownOperationError => e raise ClientError.new(e), cause: nil end |
#debug_enabled? ⇒ Boolean
Check if workday debug is enabled for the instance.
91 92 93 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 91 def debug_enabled? @options[:debug] ? true : false end |
#retry_on_error(&block) ⇒ Object
52 53 54 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 52 def retry_on_error(&block) Utils.retry_on_error(errors: [Net::ReadTimeout], delay: 3, &block) end |
#wsdl_url ⇒ String
The respective XML Service WSDL URL wd2-impl-services1.workday.com/ccx/service/systemreport2/gitlab/Public_Web_Services
105 106 107 |
# File 'lib/peoplegroup/connectors/workday/client.rb', line 105 def wsdl_url @wsdl_url ||= "#{@uri}/#{API_VERSION}?wsdl" end |