Class: ShiftNote::Shift

Inherits:
Object
  • Object
show all
Defined in:
lib/shiftnote/shift.rb

Overview

A shift, on the schedule. Woah!

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Shift

Returns a new instance of Shift.


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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

Instance Attribute Details

#closetrue, false (readonly)

I don't know what this means.

Returns:

  • (true, false)

76
77
78
# File 'lib/shiftnote/shift.rb', line 76

def close
  @close
end

#costFloat (readonly)

Returns the cost of this shift for the company.

Returns:

  • (Float)

    the cost of this shift for the company


94
95
96
# File 'lib/shiftnote/shift.rb', line 94

def cost
  @cost
end

#employeeString (readonly)

Returns the name of the employee working this Shift.

Returns:

  • (String)

    the name of the employee working this Shift.


48
49
50
# File 'lib/shiftnote/shift.rb', line 48

def employee
  @employee
end

#employee_idInteger (readonly)

Returns the employee working this shift's ID.

Returns:

  • (Integer)

    the employee working this shift's ID.


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

def employee_id
  @employee_id
end

#hoursFloat (readonly)

Returns the duration of this shift in hours.

Returns:

  • (Float)

    the duration of this shift in hours.


91
92
93
# File 'lib/shiftnote/shift.rb', line 91

def hours
  @hours
end

#internal_locationString (readonly)

Returns the internal location of this shift.

Returns:

  • (String)

    the internal location of this shift.


67
68
69
# File 'lib/shiftnote/shift.rb', line 67

def internal_location
  @internal_location
end

#noteString (readonly)

I don't know what this means.

Returns:

  • (String)

88
89
90
# File 'lib/shiftnote/shift.rb', line 88

def note
  @note
end

#on_calltrue, false (readonly)

I don't know what this means.

Returns:

  • (true, false)

80
81
82
# File 'lib/shiftnote/shift.rb', line 80

def on_call
  @on_call
end

#opentrue, false (readonly)

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

Returns:

  • (true, false)

72
73
74
# File 'lib/shiftnote/shift.rb', line 72

def open
  @open
end

#positionString (readonly)

Returns the position this employee is working.

Returns:

  • (String)

    the position this employee is working.


60
61
62
# File 'lib/shiftnote/shift.rb', line 60

def position
  @position
end

#position_colorString (readonly)

Probably used on the website.

Returns:

  • (String)

    the color of this position this employee is working.


64
65
66
# File 'lib/shiftnote/shift.rb', line 64

def position_color
  @position_color
end

#rawJSON (readonly)

Returns the raw data returned by ShiftNote.

Returns:

  • (JSON)

    the raw data returned by ShiftNote


130
131
132
# File 'lib/shiftnote/shift.rb', line 130

def raw
  @raw
end

#schedule_idInteger (readonly)

Returns the shift's schedule's ID.

Returns:

  • (Integer)

    the shift's schedule's ID.


32
33
34
# File 'lib/shiftnote/shift.rb', line 32

def schedule_id
  @schedule_id
end

#schedule_nameString (readonly)

Returns the shift's schedule's name.

Returns:

  • (String)

    the shift's schedule's name


35
36
37
# File 'lib/shiftnote/shift.rb', line 35

def schedule_name
  @schedule_name
end

#schedule_status_idInteger (readonly)

I have absolutely no idea what the IDs mean.

Returns:

  • (Integer)

    the shift's schedule's status ID.


39
40
41
# File 'lib/shiftnote/shift.rb', line 39

def schedule_status_id
  @schedule_status_id
end

#shift_dateTime (readonly)

Returns the date of this shift.

Returns:

  • (Time)

    the date of this shift.


51
52
53
# File 'lib/shiftnote/shift.rb', line 51

def shift_date
  @shift_date
end

#shift_idInteger (readonly)

Returns the shift's ID.

Returns:

  • (Integer)

    the shift's ID.


42
43
44
# File 'lib/shiftnote/shift.rb', line 42

def shift_id
  @shift_id
end

#time_inTime (readonly)

Returns the time this employee should clock in.

Returns:

  • (Time)

    the time this employee should clock in.


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

def time_in
  @time_in
end

#time_outTime (readonly)

Returns the time this employee should clock out.

Returns:

  • (Time)

    the time this employee should clock out.


57
58
59
# File 'lib/shiftnote/shift.rb', line 57

def time_out
  @time_out
end

#volumetrue, false (readonly)

I don't know what this means.

Returns:

  • (true, false)

84
85
86
# File 'lib/shiftnote/shift.rb', line 84

def volume
  @volume
end

Instance Method Details

#hide_end_times?true, false

I wonder what happens when this is true. Hopefully it doesn't break.

Returns:

  • (true, false)

    to hide the end time of the shift.


125
126
127
# File 'lib/shiftnote/shift.rb', line 125

def hide_end_times?
  @hide_end_times
end

#pending_manager_approval?true, false

If the shift is waiting for the manager to approve it.

Returns:

  • (true, false)

    whether this shift is pending manager approval


105
106
107
# File 'lib/shiftnote/shift.rb', line 105

def pending_manager_approval?
  @is_pending_manager_approval
end

#pending_pickup?true, false

This is true if this shift is dropped. This is false if it's been picked up or never was dropped.

Returns:

  • (true, false)

    whether this shift is pending pickup


99
100
101
# File 'lib/shiftnote/shift.rb', line 99

def pending_pickup?
  @is_pending_pickup
end

#pending_swap?true, false

When a shift is swapped with someone, it waits for them to accept or deny. Until that happens, this is true.

Returns:

  • (true, false)

    is the shift is pending swap.


112
113
114
# File 'lib/shiftnote/shift.rb', line 112

def pending_swap?
  @is_pending_swap
end

#pending_swap_manager_approval?true, false

When the shift swap is approved, the manager needs to approve it. Until this happens, this is true.

Returns:

  • (true, false)

    is the shift is pending swap manager approval.


119
120
121
# File 'lib/shiftnote/shift.rb', line 119

def pending_swap_manager_approval?
  @is_pending_swap_manager_approval
end

#release(employee = 0, reason = nil) ⇒ Object

Releases the shift to an employee.

Parameters:

  • the (Integer)

    employee ID of the employee to drop this to, leave blank for everyone.

  • the (String)

    reason for dropping this shift.


135
136
137
138
139
140
141
142
143
# 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