Skip to content

Commit

Permalink
Merge pull request #13 from ericnewkirk/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ericnewkirk authored Apr 8, 2021
2 parents 56a8637 + 44cbb4f commit 8151674
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 77 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export(ats_post)
export(ats_select_collars)
export(ats_trans_dates)
export(check_cookie)
export(clear_cookie)
export(cllr_add_id)
export(cllr_remove_header)
export(cllr_rename_id)
Expand Down
37 changes: 0 additions & 37 deletions R/ats_auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,6 @@ check_cookie <- function(url, cookie) {

}

# * 2.2 - clear_cookie ----------------------------------------------------

#' @title Remove Cookie
#'
#' @description Remove a certain cookie from a request handle
#'
#' @param url http hostname (base url)
#' @param cookie name of the cookie to remove
#'
#' @return named character vector for \code{httr::set_cookies}
#'
#' @export
#'
#' @keywords internal
#'
#' @examples
#' \dontrun{
#'
#' httr::GET(
#' url = ats_base_url,
#' path = list(
#' "download_all_transmission",
#' "download_all_transmission.aspx?dw=new"
#' ),
#' httr::set_cookies(clear_cookie(ats_base_url, "cgca"))
#' )
#'
#' }
#'
clear_cookie <- function(url, cookie) {

cookies <- httr::cookies(httr::handle_find(url)) %>%
dplyr::filter(.data$name != cookie) %>%
dplyr::pull(.data$value, name = .data$name)

}

# 3 - Visible Functions ---------------------------------------------------

# * 3.1 - ats_login -------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions R/fetch_ats.R
Original file line number Diff line number Diff line change
Expand Up @@ -1312,10 +1312,11 @@ fetch_ats_positions <- function(device_id = NULL,
}
}

# post request only works with collars selected
if (!check_cookie(ats_base_url, "cgca")) {
if (any(missing(device_id), length(device_id) == 0)) {
# post request only works with collars selected
ats_select_collars(fetch_ats_devices())
}
# otherwise collars are selected in fetch_ats_transmissions

# send request and parse
ats_post(
Expand Down Expand Up @@ -1415,8 +1416,7 @@ fetch_ats_transmissions <- function(device_id = NULL, new = FALSE) {
"download_all_transmission",
paste0("download_all_transmission.aspx?dw=", type)
),
task = "download transmission data",
httr::set_cookies(clear_cookie(ats_base_url, "cgca"))
task = "download transmission data"
) %>%
ats_parse_trans()

Expand Down
35 changes: 0 additions & 35 deletions man/clear_cookie.Rd

This file was deleted.

0 comments on commit 8151674

Please sign in to comment.