Last active
February 21, 2017 13:50
-
-
Save bastjan/0f59e199a014d1691ef4 to your computer and use it in GitHub Desktop.
quickadd ta holidays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'date' | |
require 'rest-client' | |
ENDPOINT = "https://ssop.terreactive.ch/erp/ext/db1/terreActive-Info/worktime/moddo.htm.new" | |
def post date, rest_client | |
rest_client.post \ | |
index: '682011.169', | |
name: 'Sebastian Widmer', | |
date: date.strftime('%Y%m%d'), | |
hours: '8.4', | |
kind: 'Misc', | |
project: 'tA Ferien', | |
option: 'Ferien', | |
saveasnew: 1 | |
end | |
puts "Username:" | |
user = gets.chomp | |
puts "Password:" | |
password = gets.chomp | |
puts "Holiday start:" | |
holiday_start = Date.parse(gets.chomp) | |
puts "Holiday end:" | |
holiday_end = Date.parse(gets.chomp) | |
rest_client = RestClient::Resource.new ENDPOINT, | |
user: user, | |
password: password, | |
verify_ssl: OpenSSL::SSL::VERIFY_NONE | |
(holiday_start..holiday_end).each do |date| | |
unless date.saturday? or date.sunday? | |
post date, rest_client | |
end | |
end | |
puts "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment