From 71f92c7c62d9cd36b98d4783777037d98cb514e2 Mon Sep 17 00:00:00 2001 From: laureng-hd Date: Thu, 4 Apr 2024 10:30:28 -0700 Subject: [PATCH] # bug fixes to get_tests calls - missing Ids --- .Rhistory | 1 + R/get_access.R | 8 ++++---- R/get_tests.R | 21 +++++++++++++++------ R/get_tests_ath.R | 2 +- R/get_tests_group.R | 2 +- R/get_tests_team.R | 2 +- R/utils.R | 2 ++ 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.Rhistory b/.Rhistory index 8f513b5..37bca5b 100644 --- a/.Rhistory +++ b/.Rhistory @@ -139,3 +139,4 @@ usethis::use_pkgdown_github_pages() usethis::use_pkgdown() pkgdown::build_site() git add . +pkgdown::build_site() diff --git a/R/get_access.R b/R/get_access.R index 1c5248f..a8268c4 100644 --- a/R/get_access.R +++ b/R/get_access.R @@ -65,13 +65,13 @@ get_access <- function(refreshToken, region = "Americas") { # API Cloud URL urlCloud <- if(region == "Americas") { - "https://cloud.hawkindynamics.com/api/dev/" + "https://cloud.hawkindynamics.com/api/dev" } else if(region == "Europe") { - "https://eu.cloud.hawkindynamics.com/api/dev/" + "https://eu.cloud.hawkindynamics.com/api/dev" } else if(region == "Asia/Pacific") { - "https://apac.cloud.hawkindynamics.com/api/dev/" + "https://apac.cloud.hawkindynamics.com/api/dev" } else { - "https://cloud.dev.hawkindynamics.com/api/dev/" + "https://cloud.dev.hawkindynamics.com/api/dev" } #-----# diff --git a/R/get_tests.R b/R/get_tests.R index c9d0fbd..2c38a32 100644 --- a/R/get_tests.R +++ b/R/get_tests.R @@ -106,14 +106,23 @@ get_tests <- function(from = NULL, to = NULL, sync = FALSE, active = TRUE) { # API Cloud URL urlCloud <- base::Sys.getenv("urlRegion") - # From DateTime - fromDT <- DateTimeParam(param = 'from', value = from, sync = sync) - - # To DateTime - toDT <- DateTimeParam(param = 'to', value = to, sync = sync) + # Handle Date time args + dt <- if(is.null(to) && isFALSE(sync)) { # from + paste0('?from=',from) + } else if(is.null(from) && isFALSE(sync)) { # to + paste0('?to=',to) + } else if(is.null(to) && isTRUE(sync)) { # sync from + paste0('?syncFrom=',from) + } else if(is.null(from) && isTRUE(sync)) { # sync to + paste0('?syncTo=',to) + } else if(isFALSE(sync)) { # from to + paste0('?from=', from, '&to=', to) + } else if(isTRUE(sync)) { # sync from to + paste0('?syncFrom=', from, '&syncTo=', to) + } # Create URL for request - URL <- base::paste0(urlCloud, fromDT, toDT) + URL <- base::paste0(urlCloud, dt) #-----# diff --git a/R/get_tests_ath.R b/R/get_tests_ath.R index 35f040b..55e926b 100644 --- a/R/get_tests_ath.R +++ b/R/get_tests_ath.R @@ -98,7 +98,7 @@ get_tests_ath <- function(athleteId, from = NULL, to = NULL, sync = FALSE, activ # Athlete Id aId <- if(!is.character(athleteId)) { base::stop("Error: athleteId should be character string of an athlete ID. Example: 'athleteId'") - } + } else { athleteId } #-----# diff --git a/R/get_tests_group.R b/R/get_tests_group.R index b8694e3..1a6905b 100644 --- a/R/get_tests_group.R +++ b/R/get_tests_group.R @@ -105,7 +105,7 @@ get_tests_group <- function(groupId, from = NULL, to = NULL, sync = FALSE, activ gId <- if(!is.character(groupId)) { stop("Error: groupId should be character string of a group ID , or a comma seperated list of group IDs in a single character string. Example: 'group1Id,group2Id,group3Id'") - } + } else { groupId } # Check for Proper EPOCH Times epochArgCheck(arg.from = from, arg.to = to) diff --git a/R/get_tests_team.R b/R/get_tests_team.R index 4edf8b0..7612dd7 100644 --- a/R/get_tests_team.R +++ b/R/get_tests_team.R @@ -105,7 +105,7 @@ get_tests_team <- function(teamId, from = NULL, to = NULL, sync = FALSE, active tId <- if(!is.character(teamId)) { stop("Error: teamId should be character string of a team ID , or a comma seperated list of team IDs in a single character string. Example: 'team1Id,team2Id,team3Id'") - } + } else { teamId } # Check for Proper EPOCH Times epochArgCheck(arg.from = from, arg.to = to) diff --git a/R/utils.R b/R/utils.R index 70baad0..1afb45d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -196,6 +196,8 @@ testIdCheck <- function(arg.id){ a <- if (nrow(filtered_df) > 0) { tId <- filtered_df$id[1] + + tId } else { stop("Error: typeId incorrect. Check your entry") }