Module: JustimmoClient::Employee

Extended by:
Utils
Defined in:
lib/justimmo_client/employee.rb

Overview

Public employee query interface

Class Method Summary collapse

Methods included from Utils

api, autoload_dir, model, representer, request, versioned_api

Class Method Details

.detail(id) ⇒ Object

Retrieve detailed information about a single employee.

Parameters:

  • id (Integer)

    The ID of the employee

Returns:

  • (Object)


23
24
25
26
27
28
29
# File 'lib/justimmo_client/employee.rb', line 23

def detail(id)
  xml_response = request(:employee).detail(id)
  model = model(:employee).new
  representer(:employee).new(model).from_xml(xml_response)
rescue JustimmoClient::RetrievalFailed
  nil
end

.idsArray<Integer>

Returns An array of employee IDs.

Returns:

  • (Array<Integer>)

    An array of employee IDs



32
33
34
35
36
37
# File 'lib/justimmo_client/employee.rb', line 32

def ids
  json_response = request(:employee).ids
  ::JSON.parse(json_response).map(&:to_i)
rescue JustimmoClient::RetrievalFailed
  []
end

.listArray<Object>

Retrieve a list of employee data.

Returns:

  • (Array<Object>)


12
13
14
15
16
17
18
# File 'lib/justimmo_client/employee.rb', line 12

def list
  xml_response = request(:employee).list
  model = Struct.new(:employees).new
  representer(:employee_list).new(model).from_xml(xml_response).employees
rescue JustimmoClient::RetrievalFailed
  []
end