Commit 7d60f6d0 authored by Dorchies David's avatar Dorchies David
Browse files

debug: try old fashion form post by getting cookies from the session (not working)

parent 5f16d33f
#' Title
#' Add a day time in "Feuille de pointage"
#'
#' @param cookies Connection cookies in string format or key/value vector
#' (See [set_cookie])
#' @param user_id ID of the user
#' session a [rvest::session] provided by [login] function
#' @param date Date to fill
#' @param duree Duration of the working day
#' @param type_regulation Regularisation type (default 22 for "Heures normales")
......@@ -19,11 +17,8 @@
#' @examples
#' \dontrun{
#' library(hatata)
#' login("pnom", "my_password")
#' add_temps(
#' user_id = "4242",
#' date = "15/04/2021"
#' )
#' session <- login("pnom", "my_password")
#' add_temps(session, "15/04/2021")
#' }
add_temps <- function(
session,
......@@ -31,21 +26,27 @@ add_temps <- function(
duree = "+07h44",
type_regulation = "22",
commentaire = "",
user_id = get_user_id(session),
cfg = config::get(file = system.file("config.yml", package = "hatata"))
) {
if(!inherits(session, "hatata_pointage")) {
session <- jump_to_pointage(session)
}
rs <- rvest::read_html(system.file("form_add.html", package = "hatata"))
rf <- rvest::html_form(rs)[[1]]
# Define proper url for form action
rf$action <- paste(cfg$url_post_add, cfg$param_add, sep = "?")
# Set form fields
rf <- rf %>% rvest::html_form_set(date = date,
type_regulation = type_regulation,
commentaire = commentaire,
user_id = user_id,
duree = duree)
rvest::session_submit(session, rf)
cookies <- session$response$cookies$value
names(cookies) <- session$response$cookies$name
POST(
paste(cfg$url_post_add, cfg$param_add, sep = "?"),
#user_agent(cfg$user_agent),
set_cookies(.cookies = cookies),
body = list(
date = date,
type_regulation = type_regulation,
commentaire = commentaire,
user_id = attr(session, "user_id"),
id_form = "form_add_regul",
duree = duree
)
)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment