paycom 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/Rakefile +1 -0
- data/gems/.gitkeep +0 -0
- data/lib/paycom.rb +185 -0
- data/lib/paycom/version.rb +3 -0
- data/paycom.gemspec +23 -0
- metadata +72 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Benjamin Falk
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Paycom
|
2
|
+
|
3
|
+
This gem interfaces with the paycom system and allows you to do
|
4
|
+
common tasks against it without having to use their website.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'paycom'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install paycom
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
|
24
|
+
require 'paycom'
|
25
|
+
|
26
|
+
login = Paycom::Login.new 'user_name', 'password', 'ssn_last_four_digits'
|
27
|
+
|
28
|
+
# This will fill out the week vanillia style
|
29
|
+
Paycom.week_punch login, Date.today
|
30
|
+
|
31
|
+
# This will fill out next week
|
32
|
+
Paycom.week_punch login, 1.week.from_now
|
33
|
+
|
34
|
+
```
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/gems/.gitkeep
ADDED
File without changes
|
data/lib/paycom.rb
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'paycom/version'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
|
6
|
+
module Paycom
|
7
|
+
|
8
|
+
class Login
|
9
|
+
|
10
|
+
URL = URI('https://www.paycomonline.net/v4/ee/ee-loginproc.php')
|
11
|
+
REFERER = 'https://www.paycomonline.net/v4/ee/ee-login.php'
|
12
|
+
|
13
|
+
def initialize(username,password,pin)
|
14
|
+
Paycom.http_start(URL) do |http|
|
15
|
+
request = Net::HTTP::Post.new URL.path
|
16
|
+
request.set_form_data signon_hash(username,password,pin)
|
17
|
+
request['Referer'] = REFERER
|
18
|
+
@response = http.request request
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def cookies
|
23
|
+
@response.to_hash['set-cookie'].reverse.map { |c| $1 if c=~ /(pcm[=0-9a-zA-Z]*)/ }.join '; '
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def signon_hash(username,password,pin)
|
29
|
+
{ :username => username, :userpass => password, :userpin => pin, :login => 'Log In >' }
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
class Menu
|
35
|
+
|
36
|
+
REFERER = 'https://www.paycomonline.net/v4/ee/ee-menu.php'
|
37
|
+
URL = URI(REFERER)
|
38
|
+
BASE = 'https://www.paycomonline.net/v4/ee/'
|
39
|
+
|
40
|
+
def initialize(login)
|
41
|
+
@login = login
|
42
|
+
Paycom.http_start(URL) do |http|
|
43
|
+
request = Net::HTTP::Get.new URL.path
|
44
|
+
request['Referer'] = REFERER
|
45
|
+
request['Cookie'] = login.cookies
|
46
|
+
@response = http.request request
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def response
|
51
|
+
@response
|
52
|
+
end
|
53
|
+
|
54
|
+
def time_sheet_uri
|
55
|
+
@time_sheet_uri ||=
|
56
|
+
if @response.body =~ /(ee-tawebsheet.php\?[=0-9a-zA-Z&]*)/
|
57
|
+
URI("#{BASE}#{$1}")
|
58
|
+
else
|
59
|
+
raise 'MenuMismatch'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def time_sheet
|
64
|
+
response = nil
|
65
|
+
Paycom.http_start(time_sheet_uri) do |http|
|
66
|
+
request = Net::HTTP::Get.new "#{time_sheet_uri.path}?#{time_sheet_uri.query}"
|
67
|
+
request['Referer'] = REFERER
|
68
|
+
request['Cookie'] = @login.cookies
|
69
|
+
response = http.request request
|
70
|
+
end
|
71
|
+
response
|
72
|
+
end
|
73
|
+
|
74
|
+
def single_punch_uri
|
75
|
+
@single_punch ||=
|
76
|
+
if time_sheet.body =~ /(ee-tawebsheet.php\?[=0-9a-zA-Z&_-]*cmdshowaddpunch=1[=0-9a-zA-Z&_-]*)/
|
77
|
+
URI("#{BASE}#{$1}")
|
78
|
+
else
|
79
|
+
raise 'MenuMismatch'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def single_punch
|
84
|
+
response = nil
|
85
|
+
Paycom.http_start(single_punch_uri) do |http|
|
86
|
+
request = Net::HTTP::Get.new "#{single_punch_uri.path}?#{single_punch_uri.query}"
|
87
|
+
request['Referer'] = REFERER
|
88
|
+
request['Cookie'] = @login.cookies
|
89
|
+
response = http.request request
|
90
|
+
end
|
91
|
+
response
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
class SinglePunch
|
97
|
+
|
98
|
+
URL = URI('https://www.paycomonline.net/v4/ee/ee-tawebsheet.php')
|
99
|
+
|
100
|
+
def initialize(login)
|
101
|
+
@login = login
|
102
|
+
@single_punch = Menu.new(login).single_punch
|
103
|
+
@attrs = {
|
104
|
+
punchtype: '',
|
105
|
+
'addpunchtime[h]' => '',
|
106
|
+
'addpunchtime[i]' => '',
|
107
|
+
'addpunchtime[a]' => '',
|
108
|
+
punchtaxprof: '0',
|
109
|
+
punchdept: '',
|
110
|
+
punchdateend: '',
|
111
|
+
punchdatestr: ''
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
def period_select
|
116
|
+
@period_select ||= "#{$1}" if @single_punch.body =~ /periodselect=(\d\d\d\d-\d\d-\d\d_\d\d\d\d-\d\d-\d\d)/
|
117
|
+
end
|
118
|
+
|
119
|
+
def clockid
|
120
|
+
@clockid ||= "#{$1}" if @single_punch.body =~ /clockid=([a-zA-Z0-9]*)/
|
121
|
+
end
|
122
|
+
|
123
|
+
def punch_type=(type); @attrs[:punchtype] = type end
|
124
|
+
def punch_type; @attrs[:punchtype] end
|
125
|
+
|
126
|
+
def punch_time=(time)
|
127
|
+
@attrs['addpunchtime[h]'] = time.strftime '%H'
|
128
|
+
@attrs['addpunchtime[i]'] = time.strftime '%M'
|
129
|
+
end
|
130
|
+
|
131
|
+
def punch_date_start=(date)
|
132
|
+
@attrs[:punchdatestr] = date.strftime '%Y-%m-%d'
|
133
|
+
end
|
134
|
+
|
135
|
+
def punch_date_end=(date)
|
136
|
+
@attrs[:punchdateend] = date.strftime '%Y-%m-%d'
|
137
|
+
end
|
138
|
+
|
139
|
+
def punch_dept=(dept)
|
140
|
+
@attrs[:punchdept] = dept
|
141
|
+
end
|
142
|
+
|
143
|
+
def punch
|
144
|
+
items = { periodselect: period_select, clockid: clockid, cmdaddpunch: 'Add Punch >' }
|
145
|
+
@attrs.each_pair { |k,v| items["new#{k.to_s}"] = v }
|
146
|
+
response = nil
|
147
|
+
Paycom.http_start(URL) do |http|
|
148
|
+
request = Net::HTTP::Post.new URL.path
|
149
|
+
request.set_form_data items
|
150
|
+
request['Cookie'] = @login.cookies
|
151
|
+
response = http.request request
|
152
|
+
end
|
153
|
+
response
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
class << self
|
158
|
+
|
159
|
+
def http_start(uri)
|
160
|
+
Net::HTTP.start uri.host, uri.port, :use_ssl => uri.scheme == 'https' do |http|
|
161
|
+
yield http
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def week_punch(login,date)
|
166
|
+
punches = {
|
167
|
+
'ID' => DateTime.now.beginning_of_day + 8.hours,
|
168
|
+
'OL' => DateTime.now.beginning_of_day + 12.hours,
|
169
|
+
'IL' => DateTime.now.beginning_of_day + 13.hours,
|
170
|
+
'OD' => DateTime.now.beginning_of_day + 17.hours
|
171
|
+
}
|
172
|
+
single = SinglePunch.new login
|
173
|
+
single.punch_date_start = date.beginning_of_week
|
174
|
+
single.punch_date_end = date.end_of_week - 2.days
|
175
|
+
punches.each_pair do |type,punch_time|
|
176
|
+
single.punch_time = punch_time
|
177
|
+
single.punch_type = type
|
178
|
+
single.punch_dept = type[0] == 'I' ? '103750' : ''
|
179
|
+
single.punch
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
data/paycom.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'paycom/version'
|
5
|
+
require 'net/http'
|
6
|
+
require 'net/https'
|
7
|
+
|
8
|
+
Gem::Specification.new do |gem|
|
9
|
+
gem.name = 'paycom'
|
10
|
+
gem.version = Paycom::VERSION
|
11
|
+
gem.authors = ['Benjamin Falk']
|
12
|
+
gem.email = ['benjamin.falk@yahoo.com']
|
13
|
+
gem.description = %q{Used to do basic interaction with the unsightly Paycom website}
|
14
|
+
gem.summary = %q{Crude Paycom Lib}
|
15
|
+
gem.homepage = 'https://github.com/benfalk/paycom'
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ['lib']
|
21
|
+
|
22
|
+
gem.add_dependency 'activesupport'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paycom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Benjamin Falk
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Used to do basic interaction with the unsightly Paycom website
|
31
|
+
email:
|
32
|
+
- benjamin.falk@yahoo.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- gems/.gitkeep
|
43
|
+
- gems/paycom-0.0.3.gem
|
44
|
+
- lib/paycom.rb
|
45
|
+
- lib/paycom/version.rb
|
46
|
+
- paycom.gemspec
|
47
|
+
homepage: https://github.com/benfalk/paycom
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.24
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Crude Paycom Lib
|
71
|
+
test_files: []
|
72
|
+
has_rdoc:
|