Skip to content

Commit

Permalink
Merge pull request #22 from HawkinDynamics/dev
Browse files Browse the repository at this point in the history
# bug fixes to get_tests calls
  • Loading branch information
qwales1 authored Apr 5, 2024
2 parents a83660b + 71f92c7 commit 16155e9
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@ usethis::use_pkgdown_github_pages()
usethis::use_pkgdown()
pkgdown::build_site()
git add .
pkgdown::build_site()
8 changes: 4 additions & 4 deletions R/get_access.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

#-----#
Expand Down
21 changes: 15 additions & 6 deletions R/get_tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

#-----#

Expand Down
2 changes: 1 addition & 1 deletion R/get_tests_ath.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

#-----#

Expand Down
2 changes: 1 addition & 1 deletion R/get_tests_group.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/get_tests_team.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 16155e9

Please sign in to comment.