class ShiftNote::Shift

A shift, on the schedule. Woah!

Attributes

close[R]

I don't know what this means. @return [true, false]

cost[R]

@return [Float] the cost of this shift for the company

employee[R]

@return [String] the name of the employee working this Shift.

employee_id[R]

@return [Integer] the employee working this shift's ID.

hours[R]

@return [Float] the duration of this shift in hours.

internal_location[R]

@return [String] the internal location of this shift.

note[R]

I don't know what this means. @return [String]

on_call[R]

I don't know what this means. @return [true, false]

open[R]

I don't know what this means. Do they open? Is the shift open? What! It's true or false though. @return [true, false]

position[R]

@return [String] the position this employee is working.

position_color[R]

Probably used on the website. @return [String] the color of this position this employee is working.

raw[R]

@return [JSON] the raw data returned by ShiftNote

schedule_id[R]

@return [Integer] the shift's schedule's ID.

schedule_name[R]

@return [String] the shift's schedule's name

schedule_status_id[R]

I have absolutely no idea what the IDs mean. @return [Integer] the shift's schedule's status ID.

shift_date[R]

@return [Time] the date of this shift.

shift_id[R]

@return [Integer] the shift's ID.

time_in[R]

@return [Time] the time this employee should clock in.

time_out[R]

@return [Time] the time this employee should clock out.

volume[R]

I don't know what this means. @return [true, false]

Public Class Methods

new(data) click to toggle source
# File lib/shiftnote/shift.rb, line 3
def initialize(data)
  @raw = data
  @schedule_id = data['ScheduleId']
  @schedule_name = data['ScheduleName']
  @schedule_status_id = data['ScheduleStatusId']
  @shift_id = data['ShiftId']
  @employee_id = data['EmployeeId']
  @employee = data['Employee']
  @shift_date = Time.parse(data['ShiftDate'])
  @time_in = Time.parse(data['TimeIn'])
  @time_out = Time.parse(data['TimeOut'])
  @position = data['Position']
  @position_color = data['PositionColor']
  @internal_location = data['InternalLocation']
  @open = data['Open']
  @close = data['Close']
  @on_call = data['OnCall']
  @volume = data['Volume']
  @note = data['Note']
  @hours = data['Hours']
  @cost = data['Cost']
  @is_pending_pickup = data['IsPendingPickUp']
  @is_pending_manager_approval = data['IsPendingManagerApproval']
  @is_pending_swap = data['IsPendingSwap']
  @is_pending_swap_manager_approval = data['IsPendingSwapManagerApproval']
  @hide_end_times = data['HideEndTimes']
end

Public Instance Methods

hide_end_times?() click to toggle source

I wonder what happens when this is true. Hopefully it doesn't break. @return [true, false] to hide the end time of the shift.

# File lib/shiftnote/shift.rb, line 125
def hide_end_times?
  @hide_end_times
end
pending_manager_approval?() click to toggle source

If the shift is waiting for the manager to approve it. @return [true, false] whether this shift is pending manager approval

# File lib/shiftnote/shift.rb, line 105
def pending_manager_approval?
  @is_pending_manager_approval
end
pending_pickup?() click to toggle source

This is true if this shift is dropped. This is false if it's been picked up or never was dropped. @return [true, false] whether this shift is pending pickup

# File lib/shiftnote/shift.rb, line 99
def pending_pickup?
  @is_pending_pickup
end
pending_swap?() click to toggle source

When a shift is swapped with someone, it waits for them to accept or deny. Until that happens, this is true. @return [true, false] is the shift is pending swap.

# File lib/shiftnote/shift.rb, line 112
def pending_swap?
  @is_pending_swap
end
pending_swap_manager_approval?() click to toggle source

When the shift swap is approved, the manager needs to approve it. Until this happens, this is true. @return [true, false] is the shift is pending swap manager approval.

# File lib/shiftnote/shift.rb, line 119
def pending_swap_manager_approval?
  @is_pending_swap_manager_approval
end
release(employee = 0, reason = nil) click to toggle source

Releases the shift to an employee. @param [Integer] the employee ID of the employee to drop this to, leave blank for everyone. @param [String] the reason for dropping this shift.

# File lib/shiftnote/shift.rb, line 135
def release(employee = 0, reason = nil)
  data = {
    "ShiftID" => shift_id,
    "ScheduleID" => schedule_id,
    "EmployeeId" => employee,
    "Reason" => reason,
    "X-Requested-With" => "XMLHttpRequest"
  }
end