Skip to content

Commit

Permalink
Merge pull request #65 from ronnyhdez/T63
Browse files Browse the repository at this point in the history
Fix errors and warnings in tests
  • Loading branch information
FvD authored Apr 1, 2022
2 parents 164e454 + c5ba92f commit 3a73648
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
7 changes: 3 additions & 4 deletions R/get_account_information.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ NULL
#' api_token = "FBHV7C")
#'}
#'
#'
#' @export
get_account_information <- function(user_code, api_token) {
if (missing(user_code)) {
Expand All @@ -35,16 +34,16 @@ get_account_information <- function(user_code, api_token) {
})


validate_json <- jsonlite::validate(httr::content(r, "text"))[1]
validate_json <- jsonlite::validate(httr::content(r, "text", encoding = "UTF-8"))[1]

if (validate_json == FALSE) {
stop("Invalid user credentials.\n Please check your user code or your api token")
}

account_info <- httr::content(r, "text")
account_info <- httr::content(r, "text", encoding = "UTF-8")
account_info <- jsonlite::fromJSON(account_info)

if (pipeline$Success[1] == FALSE) {
if (account_info$Success[1] == FALSE) {
stop("Invalid user credentials or pipeline ID.\n Please check your user code or your api token")
}

Expand Down
2 changes: 1 addition & 1 deletion R/get_contact_information.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ get_contact_information <- function(user_code, api_token, contact_id = "") {
... = contact_id)
})

content <- httr::content(r, "text")
content <- httr::content(r, "text", encoding = "UTF-8")
validate_json <- jsonlite::validate(content)

if (validate_json == FALSE) {
Expand Down
2 changes: 1 addition & 1 deletion R/get_pipeline_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ get_pipeline_report <- function(user_code, api_token, pipelineid) {
stop("Invalid user credentials or pipeline ID.\n Please check your user code or your api token")
}

pipeline <- jsonlite::fromJSON(httr::content(r, "text"),
pipeline <- jsonlite::fromJSON(httr::content(r, "text", encoding = "UTF-8"),
simplifyVector = TRUE)

if (pipeline$Success[1] == FALSE) {
Expand Down
4 changes: 2 additions & 2 deletions R/search_contacts.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ search_contacts <- function(user_code, api_token, search_term = "") {
... = search_term)
})

contenido <- httr::content(r, "text")
contenido <- httr::content(r, "text", encoding = "UTF-8")
contenido <- jsonlite::fromJSON(contenido)
contenido <- as.data.frame(contenido)

# Pull only contact names, otherwise this will pull a nested list of
# Pull only contact names, otherwise this will pull a nested list of
# companies where users were assigned as independent contacts
contenido <- contenido %>%
filter(!is.na(Result.FirstName))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-cleaning.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ testthat::test_that("Lists are removed from the contacts information", {
expect_equal(ncol(get_contact_information_test), 20)
expect_equal(nrow(get_contact_information_test), 1)
})

0 comments on commit 3a73648

Please sign in to comment.