#' jira_projects
#'
#' Extract project data from the JIRA API
#' @param project_url The JIRA project ULR
#' @export
jira_projects <- function(project_url) {
require(tidyverse)
require(httr)
require(purrr)
require(neugelbtools)
#get the API credentials
jira_creds <- jira_auth_check()
#generate the url
jira_url <- paste(project_url,"/rest/api/2/project/?expand=lead,description",sep='')
#call the API and extract the content
call <- GET(jira_url,authenticate(jira_creds$user,jira_creds$pass))
x <- content(call,"parsed")
#extract the lead data and turn it into its own DF
lead <- map(x,~.x[['lead']])
lead <- map(lead, ~ discard(.x, names(.x) %in% c('self','avatarUrls')))
lead <- do.call('bind_rows',map(lead,as_tibble)) %>%
tidycols() %>%
mutate(display_name = trimws(display_name))
colnames(lead) <- paste('lead',names(lead),sep='_')
p <- map(x, ~ discard(.x, names(.x) %in% c('self','lead','avatarUrls')))
#create a df of the project data
p <- do.call('bind_rows',map(nullToNA(p),as_tibble)) %>%
tidycols() %>%
mutate(description = ifelse(description == '',NA,description),
id = as.numeric(id),
name = trimws(name)) %>%
select(-expand)
colnames(p) <- ifelse(str_detect(names(p),'project')==FALSE,paste('project',names(p),sep='_'),names(p))
#join the project and lead data
project <- bind_cols(p,lead)
return(project)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.