Class: Dovico::Employee

Inherits:
Object
  • Object
show all
Includes:
ActiveAttr::Model
Defined in:
lib/dovico/model/employee.rb

Constant Summary collapse

URL_PATH =
'Employees'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.myselfObject



21
22
23
24
25
# File 'lib/dovico/model/employee.rb', line 21

def self.myself
  employees = ApiClient.get("#{URL_PATH}/Me")

  parse(employees["Employees"].first)
end

.parse(hash) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/dovico/model/employee.rb', line 13

def self.parse(hash)
  Employee.new(
    id:         hash["ID"],
    first_name: hash["FirstName"],
    last_name:  hash["LastName"],
  )
end

Instance Method Details

#to_sObject



27
28
29
30
31
# File 'lib/dovico/model/employee.rb', line 27

def to_s
%{ - ID:         #{id}
 - First Name: #{first_name}
 - Last Name:  #{last_name}}
end