Module: PeopleGroup::Connectors::Workday::XML::Helpers

Defined in:
lib/peoplegroup/connectors/workday/xml/helpers.rb

Overview

Common wrapper components for Workday XML queries

Constant Summary collapse

MAX_RESULTS_PER_PAGE =
999

Class Method Summary collapse

Class Method Details

.construct_options(operation, message) ⇒ Object

Contructs a hash that we can pass into the #call Savon client method.



43
44
45
46
47
48
49
# File 'lib/peoplegroup/connectors/workday/xml/helpers.rb', line 43

def self.construct_options(operation, message)
  operation = operation.to_s.split('_').collect(&:capitalize).join('_') unless operation.is_a?(String)
  {
    message_tag: "#{operation}_Request",
    message: message
  }
end

.default_response_group(additional = {}) ⇒ Object



37
38
39
40
# File 'lib/peoplegroup/connectors/workday/xml/helpers.rb', line 37

def self.default_response_group(additional = {})
  groups = { 'Include_Hierarchy_Data' => false, **additional }
  response_group groups
end

.pagination_parameters(page = 1, results_per_page = MAX_RESULTS_PER_PAGE) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/peoplegroup/connectors/workday/xml/helpers.rb', line 51

def self.pagination_parameters(page = 1, results_per_page = MAX_RESULTS_PER_PAGE)
  response_filter(
    {
      'Page' => page,
      'Count' => results_per_page
    }
  )
end

.request_criteria(criteria = {}) ⇒ Hash

Default Request Criteria XML Wrapper

Parameters:

  • criteria (Hash) (defaults to: {})

    A list of key value pair XML attributes.

Returns:

  • (Hash)
    • The <wd:Request_Criteria> XML Component containing a set of options.



27
28
29
30
31
# File 'lib/peoplegroup/connectors/workday/xml/helpers.rb', line 27

def self.request_criteria(criteria = {})
  {
    'Request_Criteria' => criteria
  }
end

.request_references(refs = {}) ⇒ Object



11
12
13
14
15
# File 'lib/peoplegroup/connectors/workday/xml/helpers.rb', line 11

def self.request_references(refs = {})
  {
    'Request_References' => refs
  }
end

.response_filter(filters = {}) ⇒ Object



17
18
19
20
21
# File 'lib/peoplegroup/connectors/workday/xml/helpers.rb', line 17

def self.response_filter(filters = {})
  {
    'Response_Filter' => filters
  }
end

.response_group(group = {}) ⇒ Object



33
34
35
# File 'lib/peoplegroup/connectors/workday/xml/helpers.rb', line 33

def self.response_group(group = {})
  { 'Response_Group' => group }
end

.team_member_reference(id) ⇒ Hash

The <wd:Employee_Reference> object wrapper.

Parameters:

  • id (Integer)

    The employee number of the team member.

Returns:

  • (Hash)

    The <wd:Employee_Reference> XML wrapper component.



63
64
65
66
67
68
69
70
# File 'lib/peoplegroup/connectors/workday/xml/helpers.rb', line 63

def self.team_member_reference(id)
  {
    'Employee_Reference' => {
      'ID' => id,
      attributes!: { 'ID' => { 'wd:type' => 'Employee_ID' } }
    }
  }
end