Class: Paycom::Menu

Inherits:
Object
  • Object
show all
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

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 = 
  Paycom.http_start(URL) do |http|
    request = Net::HTTP::Get.new URL.path
    request['Referer'] = REFERER
    request['Cookie'] = .cookies
    @response = http.request request
  end
end

Instance Method Details

#responseObject



50
51
52
# File 'lib/paycom.rb', line 50

def response
  @response
end

#single_punchObject



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.cookies
    response = http.request request
  end
  response
end

#single_punch_uriObject



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_sheetObject



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.cookies
    response = http.request request
  end
  response
end

#time_sheet_uriObject



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