Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
Add id kw to GetUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
randyzwitch committed Dec 16, 2018
1 parent f9cd8d1 commit f3fea17
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ S3method(as.data.frame,Segment)
S3method(as.data.frame,Segments)
S3method(as.data.frame,Tag)
S3method(as.data.frame,Tags)
S3method(as.data.frame,User)
S3method(as.data.frame,Users)
export(AdobeOAuth)
export(CalcMetric)
Expand All @@ -26,4 +27,6 @@ export(ReportSuite)
export(ReportSuites)
export(Segment)
export(Segments)
export(User)
export(Users)
export(adobe_get)
53 changes: 49 additions & 4 deletions R/GetUsers.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@
#' @export
#'
#' @examples
GetUsers <- function(globalCompanyId, as.data.frame=TRUE) {
GetUsers <- function(globalCompanyId, id=NULL, as.data.frame=TRUE) {

endpoint <- sprintf("https://analytics.adobe.io/api/%s",
globalCompanyId)

r <- adobe_get(endpoint, "/users", AdobeRInternals$auth, globalCompanyId)
resource <- "/users"

if(!is.null(id)){
resource <- paste(resource, "/", id, sep="")
}

r <- adobe_get(endpoint, resource, AdobeRInternals$auth, globalCompanyId)

#Set S3 method for easier parsing later
class(r) <- "Users"
if(is.null(id)){
class(r) <- "Users"
} else {
class(r) <- "User"
}

#Return a data.frame or just an S3 object
if(as.data.frame){
Expand All @@ -35,6 +45,41 @@ as.data.frame.Users <- function(x) {

#' @export
#' @keywords internal
CompanyAccess <- function(x) {
Users <- function(x) {
UseMethod("Users", x)
}

#' @export
#' @keywords internal
as.data.frame.User <- function(x) {

filled <- lapply(x$response, function(x) ifelse(is.null(x), "NA", x))

# df <- as.data.frame(list(
# companyid = filled$companyid,
# loginId = filled$loginId,
# login = filled$login,
# admin = filled$admin,
# createDate = filled$createDate,
# disabled = filled$disabled,
# email = filled$email,
# firstName = filled$firstName,
# fullName = filled$fullName,
# imsUserId = filled$imsUserId,
# lastName = filled$lastName,
# lastLogin = filled$lastLogin,
# lastAccess = filled$lastAccess,
# phoneNumber = filled$phoneNumber,
# tempLoginEnd = filled$tempLoginEnd,
# title = filled$title
# ))

return(as.data.frame(filled))

}

#' @export
#' @keywords internal
User <- function(x) {
UseMethod("User", x)
}
2 changes: 1 addition & 1 deletion man/GetUsers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f3fea17

Please sign in to comment.