Class: ShiftNote::User

Inherits:
Employee show all
Defined in:
lib/shiftnote/user.rb

Overview

An employee.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Employee

#delete

Constructor Details

#initialize(data) ⇒ User

Returns a new instance of User.


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/shiftnote/user.rb', line 3

def initialize(data)
  @raw = data
  @id = data['EmployeeId']
  @name = data['EmployeeName']
  @phones = {
    'home' => data['HomePhone'],
    'mobile' => data['MobilePhone']
  }
  @email = data['Email']
  @birthday = data['BirthDate'] ? Time.parse(data['BirthDate']) : nil
  @schedule_this_week = ShiftNote::ScheduleThisWeek.new(data['ScheduleThisWeekViewModel'])
  @trade_shifts = data['TradeShifts']
  @trade_shifts_current_day = data['TradeShiftsCurrentDay']
  @positions = data['ThisEmployeePositions']
  @last_day = data['LastDay'] ? Time.parse(data['LastDay']) : nil
  @hire_day = data['HireDate'] ? Time.parse(data['HireDate']) : nil
end

Instance Attribute Details

#birthdayTime (readonly)

Returns the user's birthday.

Returns:

  • (Time)

    the user's birthday


37
38
39
# File 'lib/shiftnote/user.rb', line 37

def birthday
  @birthday
end

#emailString (readonly)

Returns the user's email.

Returns:

  • (String)

    the user's email.


34
35
36
# File 'lib/shiftnote/user.rb', line 34

def email
  @email
end

#hire_dayTime? (readonly)

Returns the employee's hire date, nil if they don't have one set.

Returns:

  • (Time, nil)

    the employee's hire date, nil if they don't have one set


65
66
67
# File 'lib/shiftnote/user.rb', line 65

def hire_day
  @hire_day
end

#idInteger (readonly)

This is the employee's ID. Really has no use outside of Shiftnote internal data

Returns:

  • (Integer)

    the employee's internal ID


23
24
25
# File 'lib/shiftnote/user.rb', line 23

def id
  @id
end

#last_dayTime? (readonly)

Returns the employee's last day, nil if they don't have one (good).

Returns:

  • (Time, nil)

    the employee's last day, nil if they don't have one (good)


62
63
64
# File 'lib/shiftnote/user.rb', line 62

def last_day
  @last_day
end

#nameString (readonly)

The employee's (legal) name.

Returns:

  • (String)

    the employee's name


27
28
29
# File 'lib/shiftnote/user.rb', line 27

def name
  @name
end

#phonesArray<String> (readonly)

An array containing the user's home and mobile phone numbers

Returns:

  • (Array<String>)

    the user's phone numbers.


31
32
33
# File 'lib/shiftnote/user.rb', line 31

def phones
  @phones
end

#positionsArray<String> (readonly)

Returns the positions this employee is working.

Returns:

  • (Array<String>)

    the positions this employee is working.


59
60
61
# File 'lib/shiftnote/user.rb', line 59

def positions
  @positions
end

#rawJSON (readonly)

Returns the raw data returned by ShiftNote.

Returns:

  • (JSON)

    the raw data returned by ShiftNote


68
69
70
# File 'lib/shiftnote/user.rb', line 68

def raw
  @raw
end

#schedule_this_weekScheduleThisWeek (readonly)

The user's “Schedule This Week,” consider the return type for info

Returns:


41
42
43
# File 'lib/shiftnote/user.rb', line 41

def schedule_this_week
  @schedule_this_week
end

Instance Method Details

#trade_shifts?true, false Also known as: can_swap?

Trading (or swapping) means the employee can trade shifts with other employees.

Returns:

  • (true, false)

    if this employee can trade (or swap) shifts at all.


45
46
47
# File 'lib/shiftnote/user.rb', line 45

def trade_shifts?
  @trade_shifts
end

#trade_shifts_current_day?true, false

Assuming trade_shifts? is true, this method returns if the user can trade shifts for the given day. Where I work, this is false. Should've thought of that first, Billy.

Returns:

  • (true, false)

    if this employee can trade shifts for today's shifts.


54
55
56
# File 'lib/shiftnote/user.rb', line 54

def trade_shifts_current_day?
  @trade_shifts_current_day
end