class ShiftNote::User
An employee.
Attributes
@return [Time] the user's birthday
@return [String] the user's email.
@return [Time, nil] the employee's hire date, nil if they don't have one set
This is the employee's ID. Really has no use outside of Shiftnote internal data @return [Integer] the employee's internal ID
@return [Time, nil] the employee's last day, nil if they don't have one (good)
The employee's (legal) name. @return [String] the employee's name
An array containing the user's home and mobile phone numbers @return [Array<String>] the user's phone numbers.
@return [Array<String>] the positions this employee is working.
@return [JSON] the raw data returned by ShiftNote
The user's “Schedule This Week,” consider the return type for info @return [ScheduleThisWeek]
Public Class Methods
# 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
Public Instance Methods
Trading (or swapping) means the employee can trade shifts with other employees. @return [true, false] if this employee can trade (or swap) shifts at all.
# File lib/shiftnote/user.rb, line 45 def trade_shifts? @trade_shifts end
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. @return [true, false] if this employee can trade shifts for today's shifts.
# File lib/shiftnote/user.rb, line 54 def trade_shifts_current_day? @trade_shifts_current_day end