-
Dorchies David authored7d60f6d0
#' Add a day time in "Feuille de pointage"
#'
#' 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")
#' @param commentaire [character] Comment for the regularisation
#' @param cfg network configuration using config package facilities (package configuration by default)
#'
#' @details
#' If `cookies` is provided in a single [character] format, [set_cookie] is automatically called.
#'
#' @return the return of the [httr::POST] function
#' @importFrom httr POST set_cookies user_agent
#' @export
#'
#' @examples
#' \dontrun{
#' library(hatata)
#' session <- login("pnom", "my_password")
#' add_temps(session, "15/04/2021")
#' }
add_temps <- function(
session,
date,
duree = "+07h44",
type_regulation = "22",
commentaire = "",
cfg = config::get(file = system.file("config.yml", package = "hatata"))
) {
if(!inherits(session, "hatata_pointage")) {
session <- jump_to_pointage(session)
}
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
)
)
}