Class: Paycom::SinglePunch
- Inherits:
-
Object
- Object
- Paycom::SinglePunch
- Defined in:
- lib/paycom.rb
Constant Summary collapse
- URL =
URI('https://www.paycomonline.net/v4/ee/ee-tawebsheet.php')
Instance Method Summary collapse
- #clockid ⇒ Object
-
#initialize(login) ⇒ SinglePunch
constructor
A new instance of SinglePunch.
- #period_select ⇒ Object
- #punch ⇒ Object
- #punch_date_end=(date) ⇒ Object
- #punch_date_start=(date) ⇒ Object
- #punch_dept=(dept) ⇒ Object
- #punch_time=(time) ⇒ Object
- #punch_type ⇒ Object
- #punch_type=(type) ⇒ Object
Constructor Details
#initialize(login) ⇒ SinglePunch
Returns a new instance of SinglePunch.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/paycom.rb', line 100 def initialize(login) @login = login @single_punch = Menu.new(login).single_punch @attrs = { punchtype: '', 'addpunchtime[h]' => '', 'addpunchtime[i]' => '', 'addpunchtime[a]' => '', punchtaxprof: '0', punchdept: '', punchdateend: '', punchdatestr: '' } end |
Instance Method Details
#clockid ⇒ Object
119 120 121 |
# File 'lib/paycom.rb', line 119 def clockid @clockid ||= "#{$1}" if @single_punch.body =~ /clockid=([a-zA-Z0-9]*)/ end |
#period_select ⇒ Object
115 116 117 |
# File 'lib/paycom.rb', line 115 def period_select @period_select ||= "#{$1}" if @single_punch.body =~ /periodselect=(\d\d\d\d-\d\d-\d\d_\d\d\d\d-\d\d-\d\d)/ end |
#punch ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/paycom.rb', line 143 def punch items = { periodselect: period_select, clockid: clockid, cmdaddpunch: 'Add Punch >' } @attrs.each_pair { |k,v| items["new#{k.to_s}"] = v } response = nil Paycom.http_start(URL) do |http| request = Net::HTTP::Post.new URL.path request.set_form_data items request['Cookie'] = @login. response = http.request request end response end |
#punch_date_end=(date) ⇒ Object
135 136 137 |
# File 'lib/paycom.rb', line 135 def punch_date_end=(date) @attrs[:punchdateend] = date.strftime '%Y-%m-%d' end |
#punch_date_start=(date) ⇒ Object
131 132 133 |
# File 'lib/paycom.rb', line 131 def punch_date_start=(date) @attrs[:punchdatestr] = date.strftime '%Y-%m-%d' end |
#punch_dept=(dept) ⇒ Object
139 140 141 |
# File 'lib/paycom.rb', line 139 def punch_dept=(dept) @attrs[:punchdept] = dept end |
#punch_time=(time) ⇒ Object
126 127 128 129 |
# File 'lib/paycom.rb', line 126 def punch_time=(time) @attrs['addpunchtime[h]'] = time.strftime '%H' @attrs['addpunchtime[i]'] = time.strftime '%M' end |
#punch_type ⇒ Object
124 |
# File 'lib/paycom.rb', line 124 def punch_type; @attrs[:punchtype] end |
#punch_type=(type) ⇒ Object
123 |
# File 'lib/paycom.rb', line 123 def punch_type=(type); @attrs[:punchtype] = type end |