Class: Paycom::Menu
- Inherits:
-
Object
- Object
- Paycom::Menu
- Defined in:
- lib/paycom.rb
Constant Summary collapse
- REFERER =
'https://www.paycomonline.net/v4/ee/ee-menu.php'
- URL =
URI(REFERER)
- BASE =
'https://www.paycomonline.net/v4/ee/'
Instance Method Summary collapse
-
#initialize(login) ⇒ Menu
constructor
A new instance of Menu.
- #response ⇒ Object
- #single_punch ⇒ Object
- #single_punch_uri ⇒ Object
- #time_sheet ⇒ Object
- #time_sheet_uri ⇒ Object
Constructor Details
#initialize(login) ⇒ Menu
Returns a new instance of Menu.
40 41 42 43 44 45 46 47 48 |
# File 'lib/paycom.rb', line 40 def initialize(login) @login = login Paycom.http_start(URL) do |http| request = Net::HTTP::Get.new URL.path request['Referer'] = REFERER request['Cookie'] = login. @response = http.request request end end |
Instance Method Details
#response ⇒ Object
50 51 52 |
# File 'lib/paycom.rb', line 50 def response @response end |
#single_punch ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/paycom.rb', line 83 def single_punch response = nil Paycom.http_start(single_punch_uri) do |http| request = Net::HTTP::Get.new "#{single_punch_uri.path}?#{single_punch_uri.query}" request['Referer'] = REFERER request['Cookie'] = @login. response = http.request request end response end |
#single_punch_uri ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/paycom.rb', line 74 def single_punch_uri @single_punch ||= if time_sheet.body =~ /(ee-tawebsheet.php\?[=0-9a-zA-Z&_-]*cmdshowaddpunch=1[=0-9a-zA-Z&_-]*)/ URI("#{BASE}#{$1}") else raise 'MenuMismatch' end end |
#time_sheet ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/paycom.rb', line 63 def time_sheet response = nil Paycom.http_start(time_sheet_uri) do |http| request = Net::HTTP::Get.new "#{time_sheet_uri.path}?#{time_sheet_uri.query}" request['Referer'] = REFERER request['Cookie'] = @login. response = http.request request end response end |
#time_sheet_uri ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/paycom.rb', line 54 def time_sheet_uri @time_sheet_uri ||= if @response.body =~ /(ee-tawebsheet.php\?[=0-9a-zA-Z&]*)/ URI("#{BASE}#{$1}") else raise 'MenuMismatch' end end |