# NOT RUN {
# }
# NOT RUN {
# Comlpexities arise converting the list created in R into the correct JSON for GTM,
# specifically for the Monitoring Metadata in Tags, so this is brought out, converted
# separately and then included in the tag before it is resolved.
accountId <- 1234567
containerId <- 7654321
workspaceId <- 10
mergeConflicts <- gtm_workspaces_sync(accountId, containerId, workspaceId)
for(i in 1:nrow(mergeConflicts$mergeConflict$entityInWorkspace)){
tag <- NULL
trigger <- NULL
variable <- NULL
folder <- NULL
obj <- mergeConflicts$mergeConflict$entityInWorkspace[i,]
if(!is.na(obj$tag$path)){
tag <- obj$tag
if(is.null(tag$monitoringMetadata$map)){
tag <- tag %>% select(-monitoringMetadata)
tag <- as.list(tag) %>%
lapply(function(x){if(is.null(x[[1]])){x<-NA}else{x<-x}}) %>%
lapply(function(x) x[!is.na(x)])
} else{
metadataMap <- tag$monitoringMetadata$map[[1]]
metadata <- list(
type = 'map',
map = metadataMap
)
tag <- as.list(tag) %>%
lapply(function(x){if(is.null(x[[1]])){x<-NA}else{x<-x}}) %>%
lapply(function(x) x[!is.na(x)])
tag$monitoringMetadata <- metadata
}
}
if(!is.na(obj$trigger$path)){
trigger <- obj$trigger
trigger <- as.list(trigger) %>%
lapply(function(x){if(is.null(x[[1]])){x<-NA}else{x<-x}}) %>%
lapply(function(x) x[!is.na(x)])
}
if(!is.na(obj$variable$path)){
variable <- obj$variable
variable <- as.list(variable) %>%
lapply(function(x){if(is.null(x[[1]])){x<-NA}else{x<-x}}) %>%
lapply(function(x) x[!is.na(x)])
}
if(!is.na(obj$folder$path)){
folder <- obj$folder
folder <- as.list(folder) %>%
lapply(function(x){if(is.null(x[[1]])){x<-NA}else{x<-x}}) %>%
lapply(function(x) x[!is.na(x)])
}
changeStatus <- obj$changeStatus
resolve <- gtm_workspaces_resolve(account_id = accountId,
container_id = containerId,
workspace_id = workspaceId,
tag = tag,
trigger = trigger,
variable = variable,
folder = folder,
changeStatus = changeStatus)
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab