Class: Agendrix::Nethris::Employee

Inherits:
Entity
  • Object
show all
Defined in:
lib/agendrix/nethris/entities/employee.rb

Defined Under Namespace

Modules: EmplStatus

Constant Summary collapse

FIELDS =
[
  "CO_NUMBER",
  "EMPL_ID",
  "EMPL_NUMBER",
  "FIRST_NAME",
  "LAST_NAME",
  "GENDER_CODE",
  "EMAIL_WORK",
  "HIRE_DATE",
  "DATE_OF_BIRTH",
  "EMPLOYEE_RATE",
  "DEPARTURE_DATE",
  "DIVISION_NO",
  "SERVICE_NO",
  "DEPARTM_NO",
  "SUBDEPARTM_NO",
  "EMPL_DISP_STATUS"
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#inspect, #method_missing, #respond_to_missing?

Constructor Details

#initialize(client, data) ⇒ Employee

Returns a new instance of Employee.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/agendrix/nethris/entities/employee.rb', line 40

def initialize(client, data)
  attributes = {}

  FIELDS.each do |field|
    attributes[field] = data&.[](field)
  end

  attributes["HIRE_DATE"] = Date.parse(attributes["HIRE_DATE"]) if attributes["HIRE_DATE"]
  attributes["DEPARTURE_DATE"] = Date.parse(attributes["DEPARTURE_DATE"]) if attributes["DEPARTURE_DATE"]
  attributes["DATE_OF_BIRTH"] = Date.parse(attributes["DATE_OF_BIRTH"]) if attributes["DATE_OF_BIRTH"]

  super(client, attributes)

  @addresses = parse_relation(Address, data["Addresses"])
  @phones = parse_relation(PhoneNumber, data["Phones"])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Agendrix::Nethris::Entity

Instance Attribute Details

#addressesObject (readonly)

Returns the value of attribute addresses.



35
36
37
# File 'lib/agendrix/nethris/entities/employee.rb', line 35

def addresses
  @addresses
end

#phonesObject (readonly)

Returns the value of attribute phones.



35
36
37
# File 'lib/agendrix/nethris/entities/employee.rb', line 35

def phones
  @phones
end

Class Method Details

.typeObject



4
5
6
# File 'lib/agendrix/nethris/entities/employee.rb', line 4

def self.type
  Request::EntityType::EMPLOYEE
end

Instance Method Details

#full_nameObject



57
58
59
# File 'lib/agendrix/nethris/entities/employee.rb', line 57

def full_name
  "#{first_name} #{last_name}"
end