Class: Cb::EmployeeTypesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/clients/employee_types_api.rb

Class Method Summary collapse

Class Method Details

.array_of_objects_from_hash(cb_response) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cb/clients/employee_types_api.rb', line 21

def self.array_of_objects_from_hash(cb_response)
  json_hash = JSON.parse(cb_response.response.body)

  employee_types = []
  unless json_hash.empty?
    if json_hash["ResponseEmployeeTypes"]["EmployeeTypes"]["EmployeeType"].is_a?(Array)
      json_hash["ResponseEmployeeTypes"]["EmployeeTypes"]["EmployeeType"].each do |et|
        employee_types << CbEmployeeType.new(et)
      end
    elsif json_hash["ResponseEmployeeTypes"]["EmployeeTypes"]["EmployeeType"].is_a?(Hash) && json_hash.length < 2
      employee_types << CbEmployeeType.new(json_hash["ResponseEmployeeTypes"]["EmployeeTypes"]["EmployeeType"])
    end
  end
  
  return employee_types
end

.searchObject



6
7
8
9
10
11
# File 'lib/cb/clients/employee_types_api.rb', line 6

def self.search
  my_api = Cb::Utils::Api.new()
  cb_response = my_api.cb_get(Cb.configuration.uri_employee_types)
  
  return array_of_objects_from_hash(cb_response)
end

.search_by_host_site(hostsite) ⇒ Object



13
14
15
16
17
18
# File 'lib/cb/clients/employee_types_api.rb', line 13

def self.search_by_host_site(hostsite)
  my_api = Cb::Utils::Api.new()
  cb_response = my_api.cb_get(Cb.configuration.uri_employee_types, :query => {:CountryCode => hostsite})

  return array_of_objects_from_hash(cb_response)
end